|
|
@@ -1,4 +1,4 @@
|
|
|
-import { forwardRef, memo, MouseEventHandler, useState } from 'react'
|
|
|
+import { forwardRef, memo, MouseEventHandler, useRef, useState } from 'react'
|
|
|
import {
|
|
|
Dropdown,
|
|
|
DropdownMenu,
|
|
|
@@ -19,6 +19,9 @@ import { sendMB } from '@/infrastructure/event-tracking'
|
|
|
import { useEditorContext } from '@/shared/context/editor-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'
|
|
|
|
|
|
type Mode = 'view' | 'review' | 'edit'
|
|
|
|
|
|
@@ -141,6 +144,7 @@ const ModeSwitcherToggleButton = forwardRef<
|
|
|
iconType="edit"
|
|
|
label={t('editing')}
|
|
|
ariaExpanded={ariaExpanded}
|
|
|
+ currentMode={mode}
|
|
|
/>
|
|
|
)
|
|
|
} else if (mode === 'review') {
|
|
|
@@ -152,6 +156,7 @@ const ModeSwitcherToggleButton = forwardRef<
|
|
|
iconType="rate_review"
|
|
|
label={t('reviewing')}
|
|
|
ariaExpanded={ariaExpanded}
|
|
|
+ currentMode={mode}
|
|
|
/>
|
|
|
)
|
|
|
}
|
|
|
@@ -164,6 +169,7 @@ const ModeSwitcherToggleButton = forwardRef<
|
|
|
iconType="visibility"
|
|
|
label={t('viewing')}
|
|
|
ariaExpanded={ariaExpanded}
|
|
|
+ currentMode={mode}
|
|
|
/>
|
|
|
)
|
|
|
})
|
|
|
@@ -176,31 +182,72 @@ const ModeSwitcherToggleButtonContent = forwardRef<
|
|
|
iconType: string
|
|
|
label: string
|
|
|
ariaExpanded: boolean
|
|
|
+ currentMode: string
|
|
|
}
|
|
|
->(({ onClick, className, iconType, label, ariaExpanded }, ref) => {
|
|
|
+>(({ onClick, className, iconType, label, ariaExpanded, currentMode }, ref) => {
|
|
|
const [isFirstTimeUsed, setIsFirstTimeUsed] = usePersistedState(
|
|
|
`modeSwitcherFirstTimeUsed`,
|
|
|
true
|
|
|
)
|
|
|
|
|
|
+ const tutorialProps = useTutorial('review-mode', {
|
|
|
+ name: 'review-mode-notification',
|
|
|
+ })
|
|
|
+
|
|
|
+ const user = useUserContext()
|
|
|
+ const project = useProjectContext()
|
|
|
+ const { reviewPanelOpen } = useLayoutContext()
|
|
|
+ const { inactiveTutorials } = useEditorContext()
|
|
|
+
|
|
|
+ const hasCompletedReviewModeTutorial =
|
|
|
+ inactiveTutorials.includes('review-mode')
|
|
|
+
|
|
|
+ const canShowReviewModePromo =
|
|
|
+ reviewPanelOpen &&
|
|
|
+ currentMode !== 'review' &&
|
|
|
+ project.features.trackChanges &&
|
|
|
+ user.signUpDate &&
|
|
|
+ user.signUpDate < '2025-03-15' &&
|
|
|
+ !hasCompletedReviewModeTutorial
|
|
|
+
|
|
|
+ const containerRef = useRef<HTMLSpanElement | null>(null)
|
|
|
+
|
|
|
return (
|
|
|
- <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>
|
|
|
+ <>
|
|
|
+ <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} />
|
|
|
+ )}
|
|
|
+ </>
|
|
|
)
|
|
|
})
|
|
|
|