mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-28 19:41:33 +02:00
Merge pull request #31909 from overleaf/ds-removing-useIsNewEditorEnabled-2
[Part 2] Removing the usage of `useIsNewEditorEnabled` for editor tear down GitOrigin-RevId: 864652da0edcedab4f3b1ba47d8d42fb65260118
This commit is contained in:
@@ -7,12 +7,10 @@ import * as eventTracking from '../../../infrastructure/event-tracking'
|
||||
import getMeta from '@/utils/meta'
|
||||
import { populateEditorRedesignSegmentation } from '@/shared/hooks/use-editor-analytics'
|
||||
import CompileTimeoutPaywallModal from '@/features/pdf-preview/components/compile-timeout-paywall-modal'
|
||||
import { useIsNewEditorEnabled } from '@/features/ide-redesign/utils/new-editor-utils'
|
||||
import { isSplitTestEnabled } from '@/utils/splitTestUtils'
|
||||
|
||||
function TimeoutUpgradePromptNew() {
|
||||
const { isProjectOwner } = useDetachCompileContext()
|
||||
const newEditor = useIsNewEditorEnabled()
|
||||
|
||||
const isCompileTimeoutTargetPlansEnabled = isSplitTestEnabled(
|
||||
'compile-timeout-target-plans'
|
||||
@@ -25,15 +23,12 @@ function TimeoutUpgradePromptNew() {
|
||||
|
||||
const sharedSegmentation = useMemo(
|
||||
() =>
|
||||
populateEditorRedesignSegmentation(
|
||||
{
|
||||
'is-owner': isProjectOwner,
|
||||
compileTime: compileTimeout,
|
||||
location: 'logs',
|
||||
},
|
||||
newEditor
|
||||
),
|
||||
[isProjectOwner, compileTimeout, newEditor]
|
||||
populateEditorRedesignSegmentation({
|
||||
'is-owner': isProjectOwner,
|
||||
compileTime: compileTimeout,
|
||||
location: 'logs',
|
||||
}),
|
||||
[isProjectOwner, compileTimeout]
|
||||
)
|
||||
|
||||
return (
|
||||
@@ -66,12 +61,11 @@ const CompileTimeout = memo(function CompileTimeout({
|
||||
isCompileTimeoutTargetPlansEnabled,
|
||||
}: CompileTimeoutProps) {
|
||||
const { t } = useTranslation()
|
||||
const newEditor = useIsNewEditorEnabled()
|
||||
const extraSearchParams = useMemo(() => {
|
||||
return {
|
||||
itm_content: newEditor ? 'new-editor' : 'old-editor',
|
||||
itm_content: 'new-editor',
|
||||
}
|
||||
}, [newEditor])
|
||||
}, [])
|
||||
|
||||
const handleFreeTrialClick = useCallback(
|
||||
(event: React.MouseEvent<HTMLButtonElement>) => {
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
import { FC } from 'react'
|
||||
import SplitTestBadge from '@/shared/components/split-test-badge'
|
||||
import MaterialIcon from '@/shared/components/material-icon'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import OLTooltip from '@/shared/components/ol/ol-tooltip'
|
||||
|
||||
// TODO ide-redesign-cleanup: Remove this component and only use RailPanelHeader
|
||||
export const PanelHeading: FC<
|
||||
React.PropsWithChildren<{
|
||||
title: string
|
||||
splitTestName?: string
|
||||
children?: React.ReactNode
|
||||
handleClose(): void
|
||||
}>
|
||||
> = ({ title, splitTestName, children, handleClose }) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div className="panel-heading">
|
||||
<div className="panel-heading-label">
|
||||
<span>{title}</span>
|
||||
{splitTestName && (
|
||||
<SplitTestBadge
|
||||
splitTestName={splitTestName}
|
||||
displayOnVariants={['enabled']}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{children}
|
||||
<OLTooltip
|
||||
id="close-panel"
|
||||
description={t('close')}
|
||||
overlayProps={{ placement: 'bottom' }}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
className="btn panel-heading-close-button"
|
||||
aria-label={t('close')}
|
||||
onClick={handleClose}
|
||||
>
|
||||
<MaterialIcon type="close" />
|
||||
</button>
|
||||
</OLTooltip>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import { useIsNewEditorEnabled } from '@/features/ide-redesign/utils/new-editor-utils'
|
||||
import {
|
||||
Segmentation,
|
||||
sendMB,
|
||||
@@ -10,22 +9,17 @@ import { useCallback } from 'react'
|
||||
export function populateEditorRedesignSegmentation<
|
||||
SegmentationType extends Segmentation,
|
||||
>(
|
||||
segmentation: SegmentationType | undefined = {} as SegmentationType,
|
||||
editorRedesign: boolean
|
||||
segmentation: SegmentationType | undefined = {} as SegmentationType
|
||||
): SegmentationType & { 'editor-redesign'?: 'enabled' } {
|
||||
return editorRedesign
|
||||
? { ...segmentation, 'editor-redesign': 'enabled' }
|
||||
: segmentation
|
||||
return { ...segmentation, 'editor-redesign': 'enabled' }
|
||||
}
|
||||
|
||||
export const useEditorAnalytics = () => {
|
||||
const editorRedesign = useIsNewEditorEnabled()
|
||||
|
||||
const populateSegmentation = useCallback(
|
||||
(segmentation: Segmentation | undefined = {}): Segmentation => {
|
||||
return populateEditorRedesignSegmentation(segmentation, editorRedesign)
|
||||
return populateEditorRedesignSegmentation(segmentation)
|
||||
},
|
||||
[editorRedesign]
|
||||
[]
|
||||
)
|
||||
|
||||
const sendEvent: typeof sendMB = useCallback(
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
@import 'tos';
|
||||
@import 'collapsible-file-header';
|
||||
@import 'radio-chip';
|
||||
@import 'panel-heading';
|
||||
@import 'menu-bar';
|
||||
@import 'invite';
|
||||
@import 'upgrade-prompt';
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
:root {
|
||||
--panel-heading-color: var(--content-primary);
|
||||
--panel-heading-button-hover-color: var(--bg-light-tertiary);
|
||||
|
||||
@include theme('default') {
|
||||
.ide-redesign-main {
|
||||
--panel-heading-color: var(--content-primary-dark);
|
||||
--panel-heading-button-hover-color: var(--bg-dark-tertiary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.panel-heading {
|
||||
color: var(--panel-heading-color);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: var(--spacing-03) var(--spacing-02);
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.panel-heading-label {
|
||||
font-size: var(--font-size-02);
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
flex: 1;
|
||||
text-align: start;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-02);
|
||||
}
|
||||
|
||||
.panel-heading-close-button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
color: var(--panel-heading-color);
|
||||
padding: var(--spacing-01);
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
background-color: var(--panel-heading-button-hover-color);
|
||||
}
|
||||
}
|
||||
@@ -2272,7 +2272,6 @@
|
||||
"standard": "Standard",
|
||||
"start_a_free_trial": "Start a free trial",
|
||||
"start_by_adding_your_email": "Start by adding your email address.",
|
||||
"start_by_fixing_the_first_error_in_your_doc": "Start by fixing the first error in your doc to avoid problems later on.",
|
||||
"start_by_fixing_the_first_error_in_your_document": "Start by fixing the first error in the document to avoid cascading problems later on.",
|
||||
"start_free_trial": "Start Free Trial!",
|
||||
"start_free_trial_without_exclamation": "Start Free Trial",
|
||||
@@ -2586,7 +2585,6 @@
|
||||
"trial_remaining_days": "__days__ more days on your <b>Overleaf Premium</b> trial",
|
||||
"tried_to_log_in_with_email": "You’ve tried to log in with <b>__email__</b>.",
|
||||
"tried_to_register_with_email": "You’ve tried to register with <b>__email__</b>, which is already registered with <b>__appName__</b> as an institutional account.",
|
||||
"troubleshooting_tip": "Troubleshooting tip",
|
||||
"try_again": "Please try again",
|
||||
"try_for_free": "Try for free",
|
||||
"try_it_for_free": "Try it for free",
|
||||
@@ -2856,8 +2854,6 @@
|
||||
"you_cant_reset_password_due_to_sso": "You can’t reset your password because your group or organization uses SSO. <0>Log in with SSO</0>.",
|
||||
"you_dont_have_any_add_ons_on_your_account": "You don’t have any add-ons on your account.",
|
||||
"you_dont_have_any_repositories": "You don’t have any repositories",
|
||||
"you_have_0_free_suggestions_left": "You have 0 free suggestions left",
|
||||
"you_have_1_free_suggestion_left": "You have 1 free suggestion left",
|
||||
"you_have_1_license_and_your_plan_supports_up_to_y": "You have allocated 1 license and your plan supports up to __groupSize__.",
|
||||
"you_have_added_x_of_group_size_y": "You have added <0>__addedUsersSize__</0> of <1>__groupSize__</1> available members",
|
||||
"you_have_been_invited_to_transfer_management_of_your_account": "You have been invited to transfer management of your account.",
|
||||
|
||||
@@ -28,14 +28,12 @@ import { useUserSettingsContext } from '@/shared/context/user-settings-context'
|
||||
import { FullProjectMatchCounts } from './full-project-match-counts'
|
||||
import { FullProjectSearchModifiers } from './full-project-search-modifiers'
|
||||
import { isMac } from '@/shared/utils/os'
|
||||
import { PanelHeading } from '@/shared/components/panel-heading'
|
||||
import { useEditorManagerContext } from '@/features/ide-react/context/editor-manager-context'
|
||||
import { createRegExp } from '@/features/source-editor/utils/regexp'
|
||||
import { useEditorOpenDocContext } from '@/features/ide-react/context/editor-open-doc-context'
|
||||
import { useFileTreePathContext } from '@/features/file-tree/contexts/file-tree-path'
|
||||
import { FullProjectSearchResults } from './full-project-search-results'
|
||||
import { signalWithTimeout } from '@/utils/abort-signal'
|
||||
import { useIsNewEditorEnabled } from '@/features/ide-redesign/utils/new-editor-utils'
|
||||
import RailPanelHeader from '@/features/ide-react/components/rail/rail-panel-header'
|
||||
import { useActiveOverallTheme } from '@/shared/hooks/use-active-overall-theme'
|
||||
|
||||
@@ -45,7 +43,6 @@ const FullProjectSearchUI: FC = () => {
|
||||
const { projectSnapshot } = useProjectContext()
|
||||
const { openDocs } = useEditorManagerContext()
|
||||
const { pathInFolder } = useFileTreePathContext()
|
||||
const newEditor = useIsNewEditorEnabled()
|
||||
|
||||
const { currentDocument: currentDoc } = useEditorOpenDocContext()
|
||||
|
||||
@@ -111,11 +108,7 @@ const FullProjectSearchUI: FC = () => {
|
||||
|
||||
await projectSnapshot.refresh()
|
||||
if (!abortControllerRef.current.signal.aborted) {
|
||||
const results = await searchSnapshot(
|
||||
projectSnapshot,
|
||||
searchQuery,
|
||||
newEditor
|
||||
)
|
||||
const results = await searchSnapshot(projectSnapshot, searchQuery)
|
||||
setMatchedFiles(results)
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -125,7 +118,7 @@ const FullProjectSearchUI: FC = () => {
|
||||
setLoading(false)
|
||||
}
|
||||
},
|
||||
[openDocs, projectSnapshot, t, newEditor]
|
||||
[openDocs, projectSnapshot, t]
|
||||
)
|
||||
|
||||
const searchInputRef = useRef<HTMLInputElement>(null)
|
||||
@@ -191,15 +184,7 @@ const FullProjectSearchUI: FC = () => {
|
||||
style={variableStyle}
|
||||
data-bs-theme={activeOverallTheme === 'light' ? 'light' : 'dark'}
|
||||
>
|
||||
{newEditor ? (
|
||||
<RailPanelHeader title={t('search')} />
|
||||
) : (
|
||||
<PanelHeading
|
||||
title={t('search')}
|
||||
handleClose={() => setProjectSearchIsOpen(false)}
|
||||
splitTestName="full-project-search"
|
||||
/>
|
||||
)}
|
||||
<RailPanelHeader title={t('search')} />
|
||||
|
||||
<div // eslint-disable-line jsx-a11y/no-static-element-interactions
|
||||
className="full-project-search-form"
|
||||
|
||||
@@ -21,8 +21,7 @@ const toLowerCase = (string: string) => string.toLowerCase()
|
||||
|
||||
export const searchSnapshot = async (
|
||||
projectSnapshot: ProjectSnapshot,
|
||||
searchQuery: SearchQuery,
|
||||
newEditor: boolean
|
||||
searchQuery: SearchQuery
|
||||
) => {
|
||||
if (!searchQuery.search.trim().length) {
|
||||
return
|
||||
@@ -86,14 +85,11 @@ export const searchSnapshot = async (
|
||||
|
||||
sendSearchEvent(
|
||||
'search-execute',
|
||||
populateEditorRedesignSegmentation(
|
||||
{
|
||||
searchType: 'full-project',
|
||||
totalDocs: docPaths.length,
|
||||
totalResults: results.flatMap(file => file.hits).length,
|
||||
},
|
||||
newEditor
|
||||
)
|
||||
populateEditorRedesignSegmentation({
|
||||
searchType: 'full-project',
|
||||
totalDocs: docPaths.length,
|
||||
totalResults: results.flatMap(file => file.hits).length,
|
||||
})
|
||||
)
|
||||
|
||||
return results
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
--matched-hit-selected-unfocused-highlight-color: var(--content-primary);
|
||||
--collapsible-file-header-count-color: var(--content-primary);
|
||||
--collapsible-file-header-count-bg-color: var(--bg-light-tertiary);
|
||||
--panel-heading-color: var(--content-primary-dark);
|
||||
--search-modifier-checked-bg: var(--green-70);
|
||||
--search-modifier-hover-color: var(--bg-dark-secondary);
|
||||
|
||||
@@ -144,7 +143,6 @@
|
||||
--matched-hit-selected-unfocused-highlight-color: var(--bg-dark-primary);
|
||||
--collapsible-file-header-count-color: var(--bs-body-color);
|
||||
--collapsible-file-header-count-bg-color: var(--bg-dark-secondary);
|
||||
--panel-heading-color: var(--content-primary-dark);
|
||||
--search-modifier-checked-bg: var(--neutral-90);
|
||||
--search-modifier-hover-color: var(--neutral-70);
|
||||
|
||||
@@ -157,15 +155,6 @@
|
||||
color: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
.panel-heading-close-button {
|
||||
color: var(--content-primary-dark);
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
color: var(--content-primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
position: absolute;
|
||||
@@ -185,10 +174,6 @@
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.panel-heading-label {
|
||||
margin-left: var(--spacing-02);
|
||||
}
|
||||
|
||||
.full-project-search-form {
|
||||
padding: 8px;
|
||||
flex-shrink: 0;
|
||||
|
||||
Reference in New Issue
Block a user