|
|
@@ -1,4 +1,4 @@
|
|
|
-import { forwardRef, memo, MouseEventHandler, useRef, useState } from 'react'
|
|
|
+import { forwardRef, memo, MouseEventHandler, useState } from 'react'
|
|
|
import {
|
|
|
Dropdown,
|
|
|
DropdownMenu,
|
|
|
@@ -16,13 +16,9 @@ import { useTranslation } from 'react-i18next'
|
|
|
import { usePermissionsContext } from '@/features/ide-react/context/permissions-context'
|
|
|
import usePersistedState from '@/shared/hooks/use-persisted-state'
|
|
|
import { sendMB } from '@/infrastructure/event-tracking'
|
|
|
-import { useEditorContext } from '@/shared/context/editor-context'
|
|
|
import { useIdeReactContext } from '@/features/ide-react/context/ide-react-context'
|
|
|
import { useProjectContext } from '@/shared/context/project-context'
|
|
|
import UpgradeTrackChangesModal from './upgrade-track-changes-modal'
|
|
|
-import { ReviewModePromo } from '@/features/review-panel-new/components/review-mode-promo'
|
|
|
-import useTutorial from '@/shared/hooks/promotions/use-tutorial'
|
|
|
-import { useLayoutContext } from '@/shared/context/layout-context'
|
|
|
import { useCodeMirrorViewContext } from '@/features/source-editor/components/codemirror-context'
|
|
|
|
|
|
type Mode = 'view' | 'review' | 'edit'
|
|
|
@@ -161,7 +157,6 @@ const ModeSwitcherToggleButton = forwardRef<
|
|
|
iconType="edit"
|
|
|
label={t('editing')}
|
|
|
ariaExpanded={ariaExpanded}
|
|
|
- currentMode={mode}
|
|
|
/>
|
|
|
)
|
|
|
} else if (mode === 'review') {
|
|
|
@@ -173,7 +168,6 @@ const ModeSwitcherToggleButton = forwardRef<
|
|
|
iconType="rate_review"
|
|
|
label={t('reviewing')}
|
|
|
ariaExpanded={ariaExpanded}
|
|
|
- currentMode={mode}
|
|
|
/>
|
|
|
)
|
|
|
}
|
|
|
@@ -186,7 +180,6 @@ const ModeSwitcherToggleButton = forwardRef<
|
|
|
iconType="visibility"
|
|
|
label={t('viewing')}
|
|
|
ariaExpanded={ariaExpanded}
|
|
|
- currentMode={mode}
|
|
|
/>
|
|
|
)
|
|
|
})
|
|
|
@@ -199,72 +192,31 @@ const ModeSwitcherToggleButtonContent = forwardRef<
|
|
|
iconType: string
|
|
|
label: string
|
|
|
ariaExpanded: boolean
|
|
|
- currentMode: string
|
|
|
}
|
|
|
->(({ onClick, className, iconType, label, ariaExpanded, currentMode }, ref) => {
|
|
|
+>(({ onClick, className, iconType, label, ariaExpanded }, ref) => {
|
|
|
const [isFirstTimeUsed, setIsFirstTimeUsed] = usePersistedState(
|
|
|
`modeSwitcherFirstTimeUsed`,
|
|
|
true
|
|
|
)
|
|
|
|
|
|
- const tutorialProps = useTutorial('review-mode', {
|
|
|
- name: 'review-mode-notification',
|
|
|
- })
|
|
|
-
|
|
|
- const user = useUserContext()
|
|
|
- const { features } = useProjectContext()
|
|
|
- const { reviewPanelOpen } = useLayoutContext()
|
|
|
- const { inactiveTutorials } = useEditorContext()
|
|
|
-
|
|
|
- const hasCompletedReviewModeTutorial =
|
|
|
- inactiveTutorials.includes('review-mode')
|
|
|
-
|
|
|
- const canShowReviewModePromo =
|
|
|
- reviewPanelOpen &&
|
|
|
- currentMode !== 'review' &&
|
|
|
- features.trackChanges &&
|
|
|
- user.signUpDate &&
|
|
|
- user.signUpDate < '2025-03-15' &&
|
|
|
- !hasCompletedReviewModeTutorial
|
|
|
-
|
|
|
- const containerRef = useRef<HTMLSpanElement | null>(null)
|
|
|
-
|
|
|
return (
|
|
|
- <>
|
|
|
- <span ref={containerRef}>
|
|
|
- <button
|
|
|
- className={classNames(
|
|
|
- 'review-mode-switcher-toggle-button',
|
|
|
- className,
|
|
|
- {
|
|
|
- 'review-mode-switcher-toggle-button-expanded': isFirstTimeUsed,
|
|
|
- }
|
|
|
- )}
|
|
|
- ref={ref}
|
|
|
- onClick={event => {
|
|
|
- setIsFirstTimeUsed(false)
|
|
|
- if (!hasCompletedReviewModeTutorial) {
|
|
|
- tutorialProps.completeTutorial({
|
|
|
- action: 'complete',
|
|
|
- event: 'promo-click',
|
|
|
- })
|
|
|
- }
|
|
|
- onClick(event)
|
|
|
- }}
|
|
|
- aria-expanded={ariaExpanded}
|
|
|
- >
|
|
|
- <MaterialIcon className="material-symbols-outlined" type={iconType} />
|
|
|
- <div className="review-mode-switcher-toggle-label" aria-label={label}>
|
|
|
- {label}
|
|
|
- </div>
|
|
|
- <MaterialIcon type="keyboard_arrow_down" />
|
|
|
- </button>
|
|
|
- </span>
|
|
|
-
|
|
|
- {canShowReviewModePromo && (
|
|
|
- <ReviewModePromo target={containerRef} {...tutorialProps} />
|
|
|
- )}
|
|
|
- </>
|
|
|
+ <button
|
|
|
+ className={classNames('review-mode-switcher-toggle-button', className, {
|
|
|
+ 'review-mode-switcher-toggle-button-expanded': isFirstTimeUsed,
|
|
|
+ })}
|
|
|
+ ref={ref}
|
|
|
+ onClick={event => {
|
|
|
+ setIsFirstTimeUsed(false)
|
|
|
+ onClick(event)
|
|
|
+ }}
|
|
|
+ aria-expanded={ariaExpanded}
|
|
|
+ >
|
|
|
+ <MaterialIcon className="material-symbols-outlined" type={iconType} />
|
|
|
+ <div className="review-mode-switcher-toggle-label" aria-label={label}>
|
|
|
+ {label}
|
|
|
+ </div>
|
|
|
+ <MaterialIcon type="keyboard_arrow_down" />
|
|
|
+ </button>
|
|
|
)
|
|
|
})
|
|
|
|