Skip to content

Commit a94d855

Browse files
committed
refactor(google-docs): remove unused resumeMappingReview and resetFlowFromPreviewCancel handlers
1 parent 69e8169 commit a94d855

9 files changed

Lines changed: 69 additions & 782 deletions

File tree

apps/google-docs/src/locations/Page/Page.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,6 @@ const Page = () => {
7272
setMappingReviewPayload(null);
7373
};
7474

75-
const handleResumeMappingReview = async () => {
76-
if (!mappingReviewPayload) {
77-
return;
78-
}
79-
80-
await modalOrchestratorRef.current?.resumeMappingReview(mappingReviewPayload);
81-
};
82-
8375
const activePreviewPayload = mappingReviewPayload;
8476

8577
return (
@@ -90,7 +82,6 @@ const Page = () => {
9082
payload={activePreviewPayload}
9183
oauthToken={oauthToken}
9284
onLeaveReview={handleReturnToMainPage}
93-
onResumeMappingReview={handleResumeMappingReview}
9485
/>
9586
) : (
9687
<>

apps/google-docs/src/locations/Page/components/mainpage/MappingReviewPage.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ interface MappingReviewPageProps {
99
payload: MappingReviewSuspendPayload;
1010
oauthToken: string;
1111
onLeaveReview: () => void;
12-
onResumeMappingReview?: () => Promise<void>;
1312
}
1413

1514
export const MappingReviewPage = ({

apps/google-docs/src/locations/Page/components/mainpage/ModalOrchestrator.tsx

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ import { useWorkflowAgent } from '@hooks/useWorkflowAgent';
2424

2525
export interface ModalOrchestratorHandle {
2626
startFlow: () => void;
27-
/** Clears in-progress flow state and returns the page to the main state. */
28-
resetFlowFromPreviewCancel: () => void;
29-
resumeMappingReview: (payload: MappingReviewSuspendPayload) => Promise<void>;
3027
}
3128

3229
enum FlowStep {
@@ -68,24 +65,6 @@ export const ModalOrchestrator = forwardRef<ModalOrchestratorHandle, ModalOrches
6865

6966
useImperativeHandle(ref, () => ({
7067
startFlow: () => setIsUploadModalOpen(true),
71-
resetFlowFromPreviewCancel: () => {
72-
resetProgress();
73-
onResetToMain();
74-
},
75-
76-
resumeMappingReview: async (payload: MappingReviewSuspendPayload) => {
77-
if (!activeRunId) {
78-
throw new Error('Workflow run id is missing for resume.');
79-
}
80-
81-
// TODO : modify the normalized document and entry block graph with the edited values
82-
const workflowRun = await resumeWorkflow(activeRunId, {
83-
editedNormalizedDocument: payload.normalizedDocument,
84-
entryBlockGraph: payload.entryBlockGraph,
85-
});
86-
87-
handleWorkflowResult(workflowRun);
88-
},
8968
}));
9069

9170
const resetDocumentScopeReview = () => {

apps/google-docs/src/locations/Page/components/review/DocumentOutline.tsx

Lines changed: 65 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ import {
4242
uniqueUsage,
4343
} from './utils/documentOutlineModel';
4444

45-
interface DocumentOutlineProps {
46-
payload: MappingReviewSuspendPayload;
47-
showChrome?: boolean;
48-
}
49-
5045
type AnchoredMappingCard = MappingCardData & {
5146
anchorId: string;
5247
};
@@ -131,7 +126,6 @@ function getTextSegmentStyle(styles?: NormalizedDocumentFlattenedRun['styles']):
131126

132127
function renderTextSegment(
133128
key: string,
134-
testId: string,
135129
segment: TextSegment,
136130
hovered: boolean,
137131
setHoveredMappings: (mappingKeys: string[]) => void
@@ -140,9 +134,6 @@ function renderTextSegment(
140134
<Box
141135
as="span"
142136
key={key}
143-
data-testid={testId}
144-
data-highlighted={segment.highlighted ? 'true' : 'false'}
145-
data-hovered={hovered ? 'true' : 'false'}
146137
onMouseEnter={segment.highlighted ? () => setHoveredMappings(segment.mappingKeys) : undefined}
147138
onMouseLeave={segment.highlighted ? () => setHoveredMappings([]) : undefined}
148139
style={{
@@ -172,7 +163,7 @@ function renderTextSegment(
172163
);
173164
}
174165

175-
export const DocumentOutline = ({ payload, showChrome = true }: DocumentOutlineProps) => {
166+
export const DocumentOutline = (payload: MappingReviewSuspendPayload): JSX.Element => {
176167
const [selectedEntryIndex, setSelectedEntryIndex] = useState<number | null>(null);
177168
const [hoveredMappingKeys, setHoveredMappingKeys] = useState<string[]>([]);
178169
const [cardOffsetsBySegment, setCardOffsetsBySegment] = useState<
@@ -320,13 +311,7 @@ export const DocumentOutline = ({ payload, showChrome = true }: DocumentOutlineP
320311
<Text as="p" marginBottom="none">
321312
{textSegments.map((seg, index) => {
322313
const hovered = isMappingHovered(seg.mappingKeys);
323-
return renderTextSegment(
324-
`${block.id}-${index}`,
325-
`block-segment-${block.id}-${index}`,
326-
seg,
327-
hovered,
328-
setHoveredMappings
329-
);
314+
return renderTextSegment(`${block.id}-${index}`, seg, hovered, setHoveredMappings);
330315
})}
331316
</Text>
332317
);
@@ -435,8 +420,6 @@ export const DocumentOutline = ({ payload, showChrome = true }: DocumentOutlineP
435420
src={image.url}
436421
alt={image.altText ?? image.title ?? 'Table image'}
437422
data-testid={`table-image-part-${part.id}`}
438-
data-highlighted={highlighted ? 'true' : 'false'}
439-
data-hovered={hovered ? 'true' : 'false'}
440423
onMouseEnter={highlighted ? () => setHoveredMappings(mappingKeys) : undefined}
441424
onMouseLeave={highlighted ? () => setHoveredMappings([]) : undefined}
442425
style={{
@@ -465,13 +448,7 @@ export const DocumentOutline = ({ payload, showChrome = true }: DocumentOutlineP
465448
<Box as="span" style={{ whiteSpace: 'pre-wrap' }}>
466449
{textSegments.map((seg, index) => {
467450
const hovered = isMappingHovered(seg.mappingKeys);
468-
return renderTextSegment(
469-
`${part.id}-${index}`,
470-
`table-text-segment-${part.id}-${index}`,
471-
seg,
472-
hovered,
473-
setHoveredMappings
474-
);
451+
return renderTextSegment(`${part.id}-${index}`, seg, hovered, setHoveredMappings);
475452
})}
476453
</Box>
477454
);
@@ -516,76 +493,72 @@ export const DocumentOutline = ({ payload, showChrome = true }: DocumentOutlineP
516493

517494
return (
518495
<Flex flexDirection="column" gap="spacingM" style={{ padding: tokens.spacingL }}>
519-
{showChrome && (
520-
// TODO: update this overview to use the overview section component
521-
<Card padding="default" style={{ border: `1px solid ${tokens.gray300}` }}>
522-
<Flex flexDirection="column" gap="spacingS">
523-
<Box>
524-
<Text fontWeight="fontWeightDemiBold">Overview</Text>
525-
<Text as="p" fontColor="gray600" marginBottom="none">
526-
Select an entry card to focus the document outline on that entry&apos;s mappings.
496+
{/* // TODO: update this overview to use the overview section component */}
497+
<Card padding="default" style={{ border: `1px solid ${tokens.gray300}` }}>
498+
<Flex flexDirection="column" gap="spacingS">
499+
<Box>
500+
<Text fontWeight="fontWeightDemiBold">Overview</Text>
501+
<Text as="p" fontColor="gray600" marginBottom="none">
502+
Select an entry card to focus the document outline on that entry&apos;s mappings.
503+
</Text>
504+
</Box>
505+
506+
<Flex gap="spacingS" flexWrap="wrap">
507+
<Box
508+
as="button"
509+
type="button"
510+
data-testid="entry-overview-card-all"
511+
aria-pressed={selectedEntryIndex === null}
512+
onClick={() => setSelectedEntryIndex(null)}
513+
style={{
514+
display: 'flex',
515+
flexDirection: 'column',
516+
gap: tokens.spacing2Xs,
517+
minWidth: 220,
518+
padding: tokens.spacingM,
519+
borderRadius: tokens.borderRadiusMedium,
520+
border: `1px solid ${
521+
selectedEntryIndex === null ? tokens.green500 : tokens.gray300
522+
}`,
523+
backgroundColor: selectedEntryIndex === null ? tokens.green100 : tokens.colorWhite,
524+
textAlign: 'left',
525+
cursor: 'pointer',
526+
}}>
527+
<Text fontWeight="fontWeightDemiBold">All mappings</Text>
528+
<Text as="span" fontColor="gray600">
529+
Show every mapped entry in the document outline.
527530
</Text>
528531
</Box>
529532

530-
<Flex gap="spacingS" flexWrap="wrap">
531-
<Box
532-
as="button"
533-
type="button"
534-
data-testid="entry-overview-card-all"
535-
aria-pressed={selectedEntryIndex === null}
536-
onClick={() => setSelectedEntryIndex(null)}
537-
style={{
538-
display: 'flex',
539-
flexDirection: 'column',
540-
gap: tokens.spacing2Xs,
541-
minWidth: 220,
542-
padding: tokens.spacingM,
543-
borderRadius: tokens.borderRadiusMedium,
544-
border: `1px solid ${
545-
selectedEntryIndex === null ? tokens.green500 : tokens.gray300
546-
}`,
547-
backgroundColor:
548-
selectedEntryIndex === null ? tokens.green100 : tokens.colorWhite,
549-
textAlign: 'left',
550-
cursor: 'pointer',
551-
}}>
552-
<Text fontWeight="fontWeightDemiBold">All mappings</Text>
553-
<Text as="span" fontColor="gray600">
554-
Show every mapped entry in the document outline.
555-
</Text>
556-
</Box>
557-
558-
{overviewEntries.map((entry) => {
559-
const isSelected = selectedEntryIndex === entry.entryIndex;
560-
return (
561-
<Box
562-
as="button"
563-
key={entry.key}
564-
type="button"
565-
data-testid={`entry-overview-card-${entry.key}`}
566-
aria-pressed={isSelected}
567-
onClick={() => setSelectedEntryIndex(entry.entryIndex)}
568-
style={{
569-
display: 'flex',
570-
flexDirection: 'column',
571-
gap: tokens.spacing2Xs,
572-
minWidth: 220,
573-
padding: tokens.spacingM,
574-
borderRadius: tokens.borderRadiusMedium,
575-
border: `1px solid ${isSelected ? tokens.green500 : tokens.gray300}`,
576-
backgroundColor: isSelected ? tokens.green100 : tokens.colorWhite,
577-
textAlign: 'left',
578-
cursor: 'pointer',
579-
}}>
580-
<Text fontWeight="fontWeightDemiBold">{entry.title}</Text>
581-
</Box>
582-
);
583-
})}
584-
</Flex>
533+
{overviewEntries.map((entry) => {
534+
const isSelected = selectedEntryIndex === entry.entryIndex;
535+
return (
536+
<Box
537+
as="button"
538+
key={entry.key}
539+
type="button"
540+
data-testid={`entry-overview-card-${entry.key}`}
541+
aria-pressed={isSelected}
542+
onClick={() => setSelectedEntryIndex(entry.entryIndex)}
543+
style={{
544+
display: 'flex',
545+
flexDirection: 'column',
546+
gap: tokens.spacing2Xs,
547+
minWidth: 220,
548+
padding: tokens.spacingM,
549+
borderRadius: tokens.borderRadiusMedium,
550+
border: `1px solid ${isSelected ? tokens.green500 : tokens.gray300}`,
551+
backgroundColor: isSelected ? tokens.green100 : tokens.colorWhite,
552+
textAlign: 'left',
553+
cursor: 'pointer',
554+
}}>
555+
<Text fontWeight="fontWeightDemiBold">{entry.title}</Text>
556+
</Box>
557+
);
558+
})}
585559
</Flex>
586-
</Card>
587-
)}
588-
560+
</Flex>
561+
</Card>
589562
<Flex
590563
flexDirection="column"
591564
gap="spacingS"

apps/google-docs/test/locations/Page/Page.spec.tsx

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,9 @@ vi.mock('../../../src/locations/Page/components/review/DocumentOutline', () => (
6161
DocumentOutline: () => <div>Mock fixture review</div>,
6262
}));
6363

64-
const { mockModalOrchestrator, mockResetFlowFromPreviewCancel, mockResumeMappingReview } =
65-
vi.hoisted(() => ({
66-
mockModalOrchestrator: vi.fn(),
67-
mockResetFlowFromPreviewCancel: vi.fn(),
68-
mockResumeMappingReview: vi.fn(),
69-
}));
64+
const { mockModalOrchestrator } = vi.hoisted(() => ({
65+
mockModalOrchestrator: vi.fn(),
66+
}));
7067

7168
vi.mock('../../../src/locations/Page/components/mainpage/ModalOrchestrator', () => ({
7269
ModalOrchestrator: require('react').forwardRef(
@@ -79,19 +76,10 @@ vi.mock('../../../src/locations/Page/components/mainpage/ModalOrchestrator', ()
7976
},
8077
ref: React.ForwardedRef<{
8178
startFlow: () => void;
82-
resetFlowFromPreviewCancel: () => void;
83-
resumeMappingReview: () => Promise<void>;
8479
}>
8580
) => {
8681
const handle = {
8782
startFlow: vi.fn(),
88-
resetFlowFromPreviewCancel: () => {
89-
mockResetFlowFromPreviewCancel();
90-
props.onResetToMain();
91-
},
92-
resumeMappingReview: async () => {
93-
mockResumeMappingReview();
94-
},
9583
};
9684
if (typeof ref === 'function') {
9785
ref(handle);
@@ -124,10 +112,7 @@ describe('Page component', () => {
124112
cleanup();
125113
});
126114

127-
beforeEach(() => {
128-
mockResetFlowFromPreviewCancel.mockClear();
129-
mockResumeMappingReview.mockClear();
130-
});
115+
beforeEach(() => {});
131116

132117
it('renders MainPageView by default', async () => {
133118
render(<Page />);

apps/google-docs/test/locations/Page/components/mainpage/ModalOrchestrator.spec.tsx

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -197,29 +197,6 @@ describe('ModalOrchestrator', () => {
197197
});
198198
});
199199

200-
it('calls onResetToMain and clears flow state when resetFlowFromPreviewCancel is invoked', async () => {
201-
const ref = createRef<ModalOrchestratorHandle>();
202-
render(<ModalOrchestrator ref={ref} {...defaultProps} />);
203-
204-
await act(async () => {
205-
ref.current?.startFlow();
206-
});
207-
fireEvent.click(screen.getByRole('button', { name: 'Pick document' }));
208-
209-
await waitFor(() => {
210-
expect(screen.getByRole('heading', { name: 'Select content type(s)' })).toBeTruthy();
211-
});
212-
213-
await act(async () => {
214-
ref.current?.resetFlowFromPreviewCancel();
215-
});
216-
217-
await waitFor(() => {
218-
expect(defaultProps.onResetToMain).toHaveBeenCalledTimes(1);
219-
expect(screen.queryByRole('heading', { name: 'Select content type(s)' })).toBeNull();
220-
});
221-
});
222-
223200
it('resets flow when confirming discard in ConfirmCancelModal', async () => {
224201
const ref = createRef<ModalOrchestratorHandle>();
225202
render(<ModalOrchestrator ref={ref} {...defaultProps} />);

apps/google-docs/test/locations/Page/components/mainpage/PreviewPageView.spec.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ describe('PreviewPageView', () => {
3838
payload={mappingReviewPayload}
3939
oauthToken="oauth-token"
4040
onLeaveReview={vi.fn()}
41-
onResumeMappingReview={vi.fn()}
4241
/>
4342
</Layout>
4443
);

0 commit comments

Comments
 (0)