diff --git a/services/web/frontend/js/features/ide-react/context/editor-manager-context.tsx b/services/web/frontend/js/features/ide-react/context/editor-manager-context.tsx index ded2cfcdfc..b621584bda 100644 --- a/services/web/frontend/js/features/ide-react/context/editor-manager-context.tsx +++ b/services/web/frontend/js/features/ide-react/context/editor-manager-context.tsx @@ -42,7 +42,7 @@ interface OpenDocOptions forceReopen?: boolean } -type EditorManager = { +export type EditorManager = { getEditorType: () => EditorType | null showSymbolPalette: boolean currentDocument: Document diff --git a/services/web/frontend/js/features/ide-react/context/review-panel/hooks/use-review-panel-state.ts b/services/web/frontend/js/features/ide-react/context/review-panel/hooks/use-review-panel-state.ts index 22a205da0b..f6adcbad88 100644 --- a/services/web/frontend/js/features/ide-react/context/review-panel/hooks/use-review-panel-state.ts +++ b/services/web/frontend/js/features/ide-react/context/review-panel/hooks/use-review-panel-state.ts @@ -19,6 +19,10 @@ import { useIdeReactContext } from '@/features/ide-react/context/ide-react-conte import { useConnectionContext } from '@/features/ide-react/context/connection-context' import { usePermissionsContext } from '@/features/ide-react/context/permissions-context' import { useModalsContext } from '@/features/ide-react/context/modals-context' +import { + EditorManager, + useEditorManagerContext, +} from '@/features/ide-react/context/editor-manager-context' import { debugConsole } from '@/utils/debugging' import { useEditorContext } from '@/shared/context/editor-context' import { deleteJSON, getJSON, postJSON } from '@/infrastructure/fetch-json' @@ -56,7 +60,6 @@ import { ReviewPanelCommentThreadMessageApi, ReviewPanelCommentThreadsApi, } from '../../../../../../../types/review-panel/api' -import { Document } from '@/features/ide-react/editor/document' import { DateString } from '../../../../../../../types/helpers/date' const dispatchReviewPanelEvent = (type: string, payload?: any) => { @@ -129,15 +132,16 @@ function useReviewPanelState(): ReviewPanelStateReactIde { features: { trackChangesVisible, trackChanges }, } = project const { isRestrictedTokenMember } = useEditorContext() + const { openDocId, currentDocument, currentDocumentId } = + useEditorManagerContext() as MergeAndOverride< + EditorManager, + { currentDocumentId: DocId } + > // TODO permissions to be removed from the review panel context. It currently acts just as a proxy. const permissions = usePermissionsContext() const { showGenericMessageModal } = useModalsContext() const addCommentEmitter = useScopeEventEmitter('comment:start_adding') - // TODO `currentDocument` and `currentDocumentId` should be get from `useEditorManagerContext()` but that makes tests fail - const [currentDocument] = useScopeValue('editor.sharejs_doc') - const [currentDocumentId] = useScopeValue('editor.open_doc_id') - const [subView, setSubView] = useState>('cur_file') const [isOverviewLoading, setIsOverviewLoading] = @@ -167,7 +171,6 @@ function useReviewPanelState(): ReviewPanelStateReactIde { const [wantTrackChanges, setWantTrackChanges] = useScopeValue< ReviewPanel.Value<'wantTrackChanges'> >('editor.wantTrackChanges') - const openDocId = currentDocumentId const [shouldCollapse, setShouldCollapse] = useState>(true) const [lineHeight, setLineHeight] = @@ -835,8 +838,12 @@ function useReviewPanelState(): ReviewPanelStateReactIde { applyTrackChangesStateToClient ) - const [gotoEntry] = - useScopeValue>('gotoEntry') + const gotoEntry = useCallback( + (docId: DocId, entryOffset: number) => { + openDocId(docId, { gotoOffset: entryOffset }) + }, + [openDocId] + ) const view = reviewPanelOpen ? subView : 'mini' @@ -1506,7 +1513,7 @@ function useReviewPanelState(): ReviewPanelStateReactIde { subView, wantTrackChanges, isOverviewLoading, - openDocId, + openDocId: currentDocumentId, lineHeight, trackChangesState, trackChangesOnForEveryone, @@ -1533,7 +1540,7 @@ function useReviewPanelState(): ReviewPanelStateReactIde { subView, wantTrackChanges, isOverviewLoading, - openDocId, + currentDocumentId, lineHeight, trackChangesState, trackChangesOnForEveryone, diff --git a/services/web/frontend/js/features/ide-react/scope-adapters/review-panel-context-adapter.ts b/services/web/frontend/js/features/ide-react/scope-adapters/review-panel-context-adapter.ts index d0788525d6..eaf9ee5250 100644 --- a/services/web/frontend/js/features/ide-react/scope-adapters/review-panel-context-adapter.ts +++ b/services/web/frontend/js/features/ide-react/scope-adapters/review-panel-context-adapter.ts @@ -3,6 +3,5 @@ import { ReactScopeValueStore } from '@/features/ide-react/scope-value-store/rea export default function populateReviewPanelScope(store: ReactScopeValueStore) { store.set('users', {}) store.set('reviewPanel.layoutToLeft', false) - store.set('gotoEntry', () => {}) store.set('addNewComment', () => {}) }