-
Notifications
You must be signed in to change notification settings - Fork 166
Feat/google docs plan step v0 [INTEG-3341] #10360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
david-shibley-contentful
wants to merge
9
commits into
google-docs-xmas-fb
Choose a base branch
from
feat/google-docs-plan-step-v0
base: google-docs-xmas-fb
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d25d42c
feat: implementing plan preview step
david-shibley-contentful 94f8d1e
feat: plan step
david-shibley-contentful 9604493
fixing package.json
david-shibley-contentful 004aa11
moving logic to createEntriesHandler
david-shibley-contentful 6c505b7
responding to feedback, removing dead code, refactoring
david-shibley-contentful ded35d1
removing appActionUtils
david-shibley-contentful 8b123b4
removing ViewPreviewModal
david-shibley-contentful c238afd
removing create entries
david-shibley-contentful 2f7216c
more feedback
david-shibley-contentful File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { Modal, Paragraph, Spinner, Flex } from '@contentful/f36-components'; | ||
|
|
||
| interface LoadingModalProps { | ||
| isOpen: boolean; | ||
| message?: string; | ||
| } | ||
|
|
||
| export const LoadingModal = ({ isOpen, message = 'Processing...' }: LoadingModalProps) => { | ||
| return ( | ||
| <Modal | ||
| isShown={isOpen} | ||
| onClose={() => {}} | ||
| size="medium" | ||
| shouldCloseOnOverlayClick={false} | ||
| shouldCloseOnEscapePress={false}> | ||
| {() => ( | ||
| <> | ||
| <Modal.Header title="Processing" /> | ||
| <Modal.Content> | ||
| <Flex alignItems="center" gap="spacingM"> | ||
| <Spinner size="small" /> | ||
| <Paragraph marginBottom="none">{message}</Paragraph> | ||
| </Flex> | ||
| </Modal.Content> | ||
| </> | ||
| )} | ||
| </Modal> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| import { Button, Modal, Paragraph, Box, Flex, Text, Card } from '@contentful/f36-components'; | ||
| import tokens from '@contentful/f36-tokens'; | ||
| import { EntryToCreate } from '../../../functions/agents/documentParserAgent/schema'; | ||
| import { SelectedContentType } from './ContentTypePickerModal'; | ||
| import { PageAppSDK } from '@contentful/app-sdk'; | ||
|
|
||
| interface PreviewData { | ||
| summary: string; | ||
| totalEntries: number; | ||
| entries: EntryToCreate[]; | ||
| } | ||
|
|
||
| interface PreviewModalProps { | ||
| sdk: PageAppSDK; | ||
| isOpen: boolean; | ||
| onClose: () => void; | ||
| onCreateEntries: (contentTypes: SelectedContentType[]) => void; | ||
| preview: PreviewData | null; | ||
| isCreatingEntries: boolean; | ||
| isLoading: boolean; | ||
| } | ||
|
|
||
| export const PreviewModal = ({ | ||
| sdk, | ||
| isOpen, | ||
| isCreatingEntries, | ||
| onClose, | ||
| onCreateEntries, | ||
| preview, | ||
| isLoading, | ||
| }: PreviewModalProps) => { | ||
| const handleClose = () => { | ||
| if (!isLoading && !isCreatingEntries) { | ||
| onClose(); | ||
| } | ||
| }; | ||
|
|
||
| if (!preview) { | ||
| return null; | ||
| } | ||
|
|
||
| const entries = preview.entries || []; | ||
| const totalEntries = preview.totalEntries ?? entries.length; | ||
|
|
||
| return ( | ||
| <Modal | ||
| title="Create entries" | ||
| isShown={isOpen} | ||
| onClose={handleClose} | ||
| size="large" | ||
| shouldCloseOnOverlayClick={!isLoading && !isCreatingEntries} | ||
| shouldCloseOnEscapePress={!isLoading && !isCreatingEntries}> | ||
| {() => ( | ||
| <> | ||
| <Modal.Header title="Create entries" onClose={handleClose} /> | ||
| <Modal.Content> | ||
| <Paragraph marginBottom="spacingM" color="gray700"> | ||
| {preview.summary || | ||
| `Based off the document, ${totalEntries} ${ | ||
| totalEntries === 1 ? 'entry is' : 'entries are' | ||
| } being suggested:`} | ||
| </Paragraph> | ||
|
|
||
| <Box marginBottom="spacingM"> | ||
| {entries.length > 0 ? ( | ||
| <Box> | ||
| {entries.map((entry, index) => { | ||
| const title = entry.fields.displayField?.[sdk.locales.default] || ''; | ||
| return ( | ||
| <Card | ||
| key={index} | ||
| padding="default" | ||
| marginBottom="spacingS" | ||
| style={{ padding: `${tokens.spacingS} ${tokens.spacingM}` }}> | ||
| <Flex alignItems="center"> | ||
| <Box style={{ flex: 1, minWidth: 0 }}> | ||
| <Text | ||
| as="span" | ||
| fontWeight="fontWeightMedium" | ||
| fontSize="fontSizeM" | ||
| style={{ color: tokens.gray900 }}> | ||
| {title.length > 60 ? title.substring(0, 60) + '...' : title} | ||
| </Text> | ||
| <Text | ||
| as="span" | ||
| fontWeight="fontWeightNormal" | ||
| fontSize="fontSizeM" | ||
| style={{ color: tokens.gray500, marginLeft: tokens.spacingXs }}> | ||
| ({entry.contentTypeId || 'unknown'}) | ||
| </Text> | ||
| </Box> | ||
| </Flex> | ||
| </Card> | ||
| ); | ||
| })} | ||
| </Box> | ||
| ) : ( | ||
| <Paragraph color="gray600">No entries found</Paragraph> | ||
| )} | ||
| </Box> | ||
| </Modal.Content> | ||
| <Modal.Controls> | ||
| <Button | ||
| onClick={handleClose} | ||
| variant="secondary" | ||
| isDisabled={isLoading || isCreatingEntries}> | ||
| Cancel | ||
| </Button> | ||
| <Button | ||
| onClick={() => | ||
| onCreateEntries( | ||
| entries.map((entry) => ({ id: entry.contentTypeId } as SelectedContentType)) | ||
| ) | ||
| } | ||
| variant="primary" | ||
| isDisabled={isLoading || entries.length === 0}> | ||
| Create entries | ||
| </Button> | ||
| </Modal.Controls> | ||
| </> | ||
| )} | ||
| </Modal> | ||
| ); | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.