diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index 3e9448f1a4..7e98e1803f 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -331,7 +331,6 @@ const _ProjectController = { 'pdfjs-40', 'personal-access-token', 'revert-file', - 'table-generator-promotion', 'track-pdf-download', !anonymous && 'writefull-oauth-promotion', 'ieee-stylesheet', diff --git a/services/web/app/src/Features/Tutorial/TutorialController.js b/services/web/app/src/Features/Tutorial/TutorialController.js index d64c33df0c..a049ff3543 100644 --- a/services/web/app/src/Features/Tutorial/TutorialController.js +++ b/services/web/app/src/Features/Tutorial/TutorialController.js @@ -4,7 +4,6 @@ const { expressify } = require('@overleaf/promise-utils') const VALID_KEYS = [ 'react-history-buttons-tutorial', - 'table-generator-promotion', 'writefull-integration', 'writefull-oauth-promotion', 'bib-file-tpr-prompt', diff --git a/services/web/frontend/js/features/source-editor/components/editor-switch.tsx b/services/web/frontend/js/features/source-editor/components/editor-switch.tsx index b06a1ff919..ec4524e259 100644 --- a/services/web/frontend/js/features/source-editor/components/editor-switch.tsx +++ b/services/web/frontend/js/features/source-editor/components/editor-switch.tsx @@ -4,7 +4,6 @@ import Tooltip from '../../../shared/components/tooltip' import { sendMB } from '../../../infrastructure/event-tracking' import isValidTeXFile from '../../../main/is-valid-tex-file' import { useTranslation } from 'react-i18next' -import { PromotionOverlay } from './table-generator/promotion/popover' function EditorSwitch() { const { t } = useTranslation() @@ -98,7 +97,7 @@ const RichTextToggle: FC<{ ) } - return {toggle} + return toggle } export default memo(EditorSwitch) diff --git a/services/web/frontend/js/features/source-editor/components/table-generator/promotion/popover.tsx b/services/web/frontend/js/features/source-editor/components/table-generator/promotion/popover.tsx deleted file mode 100644 index 3b89530a8d..0000000000 --- a/services/web/frontend/js/features/source-editor/components/table-generator/promotion/popover.tsx +++ /dev/null @@ -1,255 +0,0 @@ -import { - FC, - Ref, - forwardRef, - memo, - useCallback, - useEffect, - useMemo, - useRef, - useState, -} from 'react' -import { useEditorContext } from '../../../../../shared/context/editor-context' -import { Button, Overlay, Popover } from 'react-bootstrap' -import Close from '../../../../../shared/components/close' -import { postJSON } from '../../../../../infrastructure/fetch-json' -import { sendMB } from '../../../../../infrastructure/event-tracking' -import { useFeatureFlag } from '../../../../../shared/context/split-test-context' -import { User } from '../../../../../../../types/user' -import { useUserContext } from '../../../../../shared/context/user-context' -import grammarlyExtensionPresent from '../../../../../shared/utils/grammarly' -import { debugConsole } from '../../../../../utils/debugging' - -const DELAY_BEFORE_SHOWING_PROMOTION = 1000 -const NEW_USER_CUTOFF_TIME = new Date(2023, 8, 20).getTime() -const NOW_TIME = new Date().getTime() -const GRAMMARLY_CUTOFF_TIME = new Date(2023, 9, 10).getTime() - -export const PromotionOverlay: FC = ({ children }) => { - const ref = useRef(null) - - const { inactiveTutorials, currentPopup, setCurrentPopup } = - useEditorContext() - - const hasTableGeneratorPromotion = useFeatureFlag('table-generator-promotion') - - const user = useUserContext() as User | undefined - - const userRegistrationTime = useMemo(() => { - if (user?.signUpDate) { - return new Date(user.signUpDate).getTime() - } - }, [user]) - - const hideBecauseNewUser = - !userRegistrationTime || userRegistrationTime > NEW_USER_CUTOFF_TIME - - const popupPresent = - currentPopup && currentPopup !== 'table-generator-promotion' - - const showPromotion = - hasTableGeneratorPromotion && - !popupPresent && - !inactiveTutorials.includes('table-generator-promotion') && - !hideBecauseNewUser - - useEffect(() => { - if (showPromotion) { - setCurrentPopup('table-generator-promotion') - } - }, [showPromotion, setCurrentPopup]) - - if (!showPromotion) { - return <>{children} - } - - return ( - <> - - {children} - - ) -} - -const PromotionOverlayContent = memo( - forwardRef(function PromotionOverlayContent( - _props, - ref: Ref - ) { - const { deactivateTutorial } = useEditorContext() - const [timeoutExpired, setTimeoutExpired] = useState(false) - - const onClose = useCallback(() => { - deactivateTutorial('table-generator-promotion') - postJSON('/tutorial/table-generator-promotion/complete').catch( - debugConsole.error - ) - }, [deactivateTutorial]) - - const onDismiss = useCallback(() => { - onClose() - sendMB('table-generator-promotion-dismissed') - }, [onClose]) - - const onComplete = useCallback(() => { - onClose() - sendMB('table-generator-promotion-completed') - }, [onClose]) - - useEffect(() => { - const interval = setTimeout(() => { - setTimeoutExpired(true) - }, DELAY_BEFORE_SHOWING_PROMOTION) - return () => clearTimeout(interval) - }, []) - - const [currentPage, setCurrentPage] = useState(0) - - const nextPage = useCallback(() => { - setCurrentPage(cur => clamp(cur + 1)) - sendMB('table-generator-promotion-next-page') - }, []) - - const page = PROMOTION_PAGES[clamp(currentPage)] - const PageComponent = page.body - const pageTitle = page.title - const isAtLastPage = currentPage >= PROMOTION_PAGES.length - 1 - - const hideBecauseOfGrammarly = - grammarlyExtensionPresent() && NOW_TIME < GRAMMARLY_CUTOFF_TIME - - if ( - !timeoutExpired || - !ref || - typeof ref === 'function' || - !ref.current || - hideBecauseOfGrammarly - ) { - return null - } - - return ( - - - {pageTitle} - - - } - className="dark-themed" - > - - - -