Skip to content

Commit 21ed6f8

Browse files
authored
fix(google-docs): create entries button resumes workflow [INTEG-3791] (#10884)
* refactor: resume workflow on create entries, update OverviewSection to use entryBlockGraph from mappingReviewSuspendPayload * chore: remove console logs * test: remove normalized doc from tests using PreviewPayload type * chore: remove selectedEntryTempIds from createEntries() in entry service * fix: rename PreviewPayload -> CompletedWorkflowPayload * fix: rename entryList component to overviewEntryList * fix: add error modal if create entries fails in review page * refactor: move create entries logic to ReviewPage and pass runId as prop * fix: rename previewPayload file -> createEntries and entryList->overviewEntryList
1 parent 357c0a1 commit 21ed6f8

22 files changed

Lines changed: 398 additions & 664 deletions

apps/google-docs/src/hooks/useWorkflowAgent.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
MappingReviewSuspendPayload,
66
ResumePayload,
77
TabsImagesSuspendPayload,
8-
PreviewPayload,
8+
CompletedWorkflowPayload,
99
WorkflowRunResult,
1010
RunStatus,
1111
} from '@types';
@@ -16,7 +16,7 @@ import {
1616
resumeWorkflowRun,
1717
startAgentRun,
1818
} from '../services/agents-api';
19-
import { validatePayloadShape } from '../utils/previewPayload';
19+
import { validatePayloadShape } from '../utils/createEntries';
2020

2121
interface UseWorkflowParams {
2222
sdk: PageAppSDK;
@@ -56,7 +56,7 @@ const getAgentPayload = (runData: AgentRunData): string | null => {
5656
return textPart?.text || null;
5757
};
5858

59-
const previewPayloadFromCompletedRun = (runData: AgentRunData): PreviewPayload => {
59+
const previewPayloadFromCompletedRun = (runData: AgentRunData): CompletedWorkflowPayload => {
6060
const googleDocPayload = runData.metadata?.googleDocPayload;
6161
if (googleDocPayload == null) {
6262
throw new Error('Workflow completed but result payload was missing.');
@@ -84,12 +84,6 @@ const previewPayloadFromCompletedRun = (runData: AgentRunData): PreviewPayload =
8484
entries: [],
8585
assets: [],
8686
referenceGraph: {},
87-
normalizedDocument: {
88-
documentId,
89-
title,
90-
contentBlocks: [],
91-
tables: [],
92-
},
9387
};
9488
}
9589

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,11 @@ const Page = () => {
9797
<Layout withBoxShadow={true} offsetTop={10}>
9898
{mappingReviewState ? (
9999
<ReviewPage
100+
sdk={sdk}
100101
payload={mappingReviewState.payload}
102+
runId={mappingReviewState.runId}
101103
onCancelReview={handleCancelMappingReview}
104+
onReturnToMainPage={handleReturnToMainPage}
102105
/>
103106
) : (
104107
<>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { SelectTabsModal } from '../modals/step_3/SelectTabsModal';
1212
import {
1313
DocumentTabProps,
1414
MappingReviewSuspendPayload,
15-
PreviewPayload,
15+
CompletedWorkflowPayload,
1616
ResumePayload,
1717
TabsImagesSuspendPayload,
1818
RunStatus,

apps/google-docs/src/locations/Page/components/modals/SummaryModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Button, EntryCard, Flex, Modal, Paragraph } from '@contentful/f36-compo
22
import { PageAppSDK } from '@contentful/app-sdk';
33
import type { EntryProps } from 'contentful-management';
44
import { getEntryDisplayTitle } from '../../../../utils/getEntryDisplayTitle';
5-
import type { ContentTypeDisplayInfoMap } from '../../../../utils/checkboxEntryList';
5+
import type { ContentTypeDisplayInfoMap } from '../../../../utils/overviewEntryList';
66

77
export interface SummaryModalProps {
88
isOpen: boolean;

apps/google-docs/src/locations/Page/components/overview/CheckboxEntryList.tsx

Lines changed: 0 additions & 111 deletions
This file was deleted.

apps/google-docs/src/locations/Page/components/overview/CheckboxEntryList.styles.ts renamed to apps/google-docs/src/locations/Page/components/overview/OverviewEntryList.styles.ts

File renamed without changes.
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import { Box, Card, Flex, Paragraph, Text } from '@contentful/f36-components';
2+
import tokens from '@contentful/f36-tokens';
3+
import { cx } from '@emotion/css';
4+
import type { EntryListRow as OverviewEntryListRow } from '../../../../utils/overviewEntryList';
5+
import {
6+
treeChildRowBase,
7+
treeChildRowLast,
8+
treeChildRowNotLast,
9+
treeChildrenList,
10+
} from './OverviewEntryList.styles';
11+
import { truncateLabel } from '../../../../utils/utils';
12+
13+
export interface OverviewEntryListProps {
14+
rows: OverviewEntryListRow[];
15+
selectedEntryIndex: number;
16+
onSelect: (entryIndex: number) => void;
17+
}
18+
19+
interface OverviewEntryRowCardProps {
20+
row: OverviewEntryListRow;
21+
selectedEntryIndex: number;
22+
onSelect: (entryIndex: number) => void;
23+
showTreeLines: boolean;
24+
isLastRow?: boolean;
25+
}
26+
27+
function OverviewEntryRowCard({
28+
row,
29+
selectedEntryIndex,
30+
onSelect,
31+
showTreeLines,
32+
isLastRow = true,
33+
}: OverviewEntryRowCardProps) {
34+
const isSelected = row.entryIndex === selectedEntryIndex;
35+
36+
const treeLineClass =
37+
showTreeLines && cx(treeChildRowBase, isLastRow ? treeChildRowLast : treeChildRowNotLast);
38+
39+
const rowContent = (
40+
<>
41+
<Card
42+
padding="default"
43+
as="button"
44+
type="button"
45+
onClick={() => {
46+
if (!isSelected) onSelect(row.entryIndex);
47+
}}
48+
style={{
49+
border: `2px solid ${isSelected ? tokens.blue500 : tokens.gray300}`,
50+
backgroundColor: tokens.colorWhite,
51+
cursor: isSelected ? 'default' : 'pointer',
52+
textAlign: 'left',
53+
width: '100%',
54+
}}>
55+
<Paragraph marginBottom="none">
56+
<Text as="span" fontWeight="fontWeightDemiBold">
57+
{row.contentTypeName || 'Untitled'}
58+
</Text>
59+
{row.contentTypeName && row.entryTitle ? (
60+
<Text as="span" fontColor="gray600">
61+
{' '}
62+
({truncateLabel(row.entryTitle, 150)})
63+
</Text>
64+
) : null}
65+
</Paragraph>
66+
</Card>
67+
{row.children.length > 0 ? (
68+
<Box className={treeChildrenList}>
69+
{row.children.map((child, index) => (
70+
<OverviewEntryRowCard
71+
key={child.id}
72+
row={child}
73+
selectedEntryIndex={selectedEntryIndex}
74+
onSelect={onSelect}
75+
showTreeLines
76+
isLastRow={index === row.children.length - 1}
77+
/>
78+
))}
79+
</Box>
80+
) : null}
81+
</>
82+
);
83+
84+
if (treeLineClass) {
85+
return <Box className={treeLineClass}>{rowContent}</Box>;
86+
}
87+
88+
return (
89+
<Flex flexDirection="column" gap="spacingS">
90+
{rowContent}
91+
</Flex>
92+
);
93+
}
94+
95+
export function OverviewEntryList({ rows, selectedEntryIndex, onSelect }: OverviewEntryListProps) {
96+
return (
97+
<Flex flexDirection="column" gap="spacingS">
98+
{rows.map((row) => (
99+
<OverviewEntryRowCard
100+
key={row.id}
101+
row={row}
102+
selectedEntryIndex={selectedEntryIndex}
103+
onSelect={onSelect}
104+
showTreeLines={false}
105+
/>
106+
))}
107+
</Flex>
108+
);
109+
}

apps/google-docs/src/locations/Page/components/overview/OverviewSection.styles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ export const overviewSectionBox = css({
88
});
99

1010
export const overviewSectionBoxScrollable = css({
11-
maxHeight: '300px',
12-
overflowY: 'auto',
11+
maxHeight: '348px',
12+
overflow: 'scroll',
1313
});

0 commit comments

Comments
 (0)