Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions apps/google-docs/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@ STATIC_S3_BASE=
GOOGLE_DOCS_CLOUDFRONT_DIST_ID=
CONTENTFUL_ACCESS_TOKEN=

# Frontend (Vite): dev-only UI to view a review payload from a fixture.
VITE_ENABLE_MOCK_REVIEW_PAYLOAD=

# Frontend (Vite): dev-only UI to preview the exclude/edit modal inside the mapping view.
VITE_ENABLE_MOCK_EDIT_MODAL=
Comment on lines 5 to 6
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Frontend (Vite): dev-only UI to preview the exclude/edit modal inside the mapping view.
VITE_ENABLE_MOCK_EDIT_MODAL=

Same as above

This file was deleted.

58 changes: 12 additions & 46 deletions apps/google-docs/src/locations/Page/Page.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import { useEffect, useRef, useState } from 'react';
import { useRef, useState } from 'react';
import { PageAppSDK } from '@contentful/app-sdk';
import { useSDK } from '@contentful/react-apps-toolkit';
import { Button, Layout } from '@contentful/f36-components';
import { Layout } from '@contentful/f36-components';
import {
ModalOrchestrator,
ModalOrchestratorHandle,
} from './components/mainpage/ModalOrchestrator';
import { MainPageView } from './components/mainpage/MainPageView';
import { ReviewPage } from './components/review/ReviewPage';
import { loadFixtureReviewPayload } from '../../fixtures/googleDocsReview/loadFixtureReviewPayload';
import type { MappingReviewSuspendPayload } from '@types';
import { useWorkflowAgent } from '@hooks/useWorkflowAgent';

const enableMockReviewPayload = import.meta.env.VITE_ENABLE_MOCK_REVIEW_PAYLOAD === 'true';

const Page = () => {
const sdk = useSDK<PageAppSDK>();
const modalOrchestratorRef = useRef<ModalOrchestratorHandle>(null);
Expand All @@ -24,35 +21,12 @@ const Page = () => {
payload: MappingReviewSuspendPayload;
runId?: string;
} | null>(null);
const [fixtureReviewPayload, setFixtureReviewPayload] =
useState<MappingReviewSuspendPayload | null>(null);
const { resumeWorkflow } = useWorkflowAgent({
sdk,
documentId: '',
oauthToken: '',
});

// TODO: remove fixture review payload loading before launch
useEffect(() => {
let isCancelled = false;

void loadFixtureReviewPayload()
.then((payload) => {
if (!isCancelled) {
setFixtureReviewPayload(payload);
}
})
.catch(() => {
if (!isCancelled) {
setFixtureReviewPayload(null);
}
});

return () => {
isCancelled = true;
};
}, []);

const handleOauthTokenChange = (token: string) => {
setOauthToken(token);
};
Expand Down Expand Up @@ -104,24 +78,16 @@ const Page = () => {
onReturnToMainPage={handleReturnToMainPage}
/>
) : (
<>
{/* TODO: remove mock review payload button before launch */}
{enableMockReviewPayload && fixtureReviewPayload ? (
<Button onClick={() => setMappingReviewState({ payload: fixtureReviewPayload })}>
Mock from fixture
</Button>
) : null}
<MainPageView
oauthToken={oauthToken}
isOAuthConnected={isOAuthConnected}
isOAuthLoading={isOAuthLoading}
onOAuthConnectedChange={handleOAuthConnectedChange}
onOauthTokenChange={handleOauthTokenChange}
onLoadingStateChange={handleOAuthLoadingStateChange}
onSelectFile={handleSelectFile}
sdk={sdk}
/>
</>
<MainPageView
oauthToken={oauthToken}
isOAuthConnected={isOAuthConnected}
isOAuthLoading={isOAuthLoading}
onOAuthConnectedChange={handleOAuthConnectedChange}
onOauthTokenChange={handleOauthTokenChange}
onLoadingStateChange={handleOAuthLoadingStateChange}
onSelectFile={handleSelectFile}
sdk={sdk}
/>
)}
</Layout>

Expand Down
1 change: 0 additions & 1 deletion apps/google-docs/src/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

interface ImportMetaEnv {
readonly VITE_ENABLE_MOCK_EDIT_MODAL?: string;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
readonly VITE_ENABLE_MOCK_EDIT_MODAL?: string;

I think we can remove this one as well

readonly VITE_ENABLE_MOCK_REVIEW_PAYLOAD?: string;
}

declare module '*.png' {
Expand Down
4 changes: 2 additions & 2 deletions apps/google-docs/test/locations/Page/Page.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ vi.mock('../../../src/locations/Page/components/mainpage/OAuthConnector', () =>
}));

vi.mock('../../../src/locations/Page/components/review/mapping/MappingView', () => ({
MappingView: () => <div>Mock fixture review</div>,
MappingView: () => <div>Mock MappingView</div>,
}));

const { mockModalOrchestrator } = vi.hoisted(() => ({
Expand Down Expand Up @@ -132,7 +132,7 @@ describe('Page component', () => {

await waitFor(() => {
expect(screen.getByText('Create from document "Document mapping review"')).toBeTruthy();
expect(screen.getByText('Mock fixture review')).toBeTruthy();
expect(screen.getByText('Mock MappingView')).toBeTruthy();
expect(screen.queryByRole('heading', { name: 'Drive Integration' })).toBeNull();
});
});
Expand Down
Loading