-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #1917 Update developer preview app page
- Loading branch information
Vu Nguyen
committed
Jul 15, 2020
1 parent
63b67df
commit 96f0fd1
Showing
48 changed files
with
5,340 additions
and
70 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
packages/developer-portal/src/components/pages/app-detail-preview/app-detail-preview.tsx
This file contains 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,59 @@ | ||
import * as React from 'react' | ||
import AppContent from './client/app-content' | ||
import { Aside as AppAside } from './client/aside' | ||
import AppHeader from './common/ui-app-header' | ||
import { useParams } from 'react-router' | ||
import { AppDetailData } from '@/reducers/developer' | ||
import { Grid, Loader, GridItem, Section } from '@reapit/elements' | ||
import { BackToAppsSection } from '../app-detail/app-sections' | ||
import useReactResponsive from '@/components/hooks/use-react-responsive' | ||
|
||
export type AppDetailPreviewProps = {} | ||
|
||
export const loadAppDetailPreviewDataFromLocalStorage = ( | ||
appId: string, | ||
setAppDetailPreviewData: React.Dispatch<React.SetStateAction<AppDetailPreviewProps | null>>, | ||
) => () => { | ||
try { | ||
const appDataString = localStorage.getItem('developer-preview-app') | ||
if (!appDataString) { | ||
throw 'No app preview' | ||
} | ||
|
||
const appData = JSON.parse(appDataString) as AppDetailData | ||
if (appData?.id !== appId) { | ||
throw 'No app preview' | ||
} | ||
setAppDetailPreviewData(appData) | ||
} catch (err) {} | ||
} | ||
|
||
const AppDetailPreview: React.FC<AppDetailPreviewProps> = () => { | ||
const { isMobile } = useReactResponsive() | ||
const [appDetailPreviewData, setAppDetailPreviewData] = React.useState<AppDetailPreviewProps | null>(null) | ||
const { appId } = useParams() | ||
|
||
React.useEffect(loadAppDetailPreviewDataFromLocalStorage(appId, setAppDetailPreviewData), [appId]) | ||
|
||
return ( | ||
<Grid dataTest="client-app-detail-container"> | ||
{!appDetailPreviewData ? ( | ||
<Loader dataTest="client-app-detail-loader" /> | ||
) : ( | ||
<> | ||
<GridItem className="is-one-quarter"> | ||
<AppAside appDetailData={appDetailPreviewData} desktopIntegrationTypes={[]} /> | ||
</GridItem> | ||
<GridItem className="is-three-quarters"> | ||
<Section isFlex isFlexColumn isFullHeight> | ||
<AppHeader appDetailData={appDetailPreviewData} /> | ||
<AppContent appDetailData={appDetailPreviewData} /> | ||
{!isMobile && <BackToAppsSection onClick={() => {}} />} | ||
</Section> | ||
</GridItem> | ||
</> | ||
)} | ||
</Grid> | ||
) | ||
} | ||
export default AppDetailPreview |
21 changes: 21 additions & 0 deletions
21
...ts/pages/app-detail-preview/client/__tests__/__snapshots__/app-button-group.test.tsx.snap
This file contains 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,21 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ClientAppDetailButtonGroup should match snapshot when both buttons are hidden 1`] = ` | ||
<Fragment> | ||
<Component /> | ||
</Fragment> | ||
`; | ||
|
||
exports[`ClientAppDetailButtonGroup should match snapshot when both buttons are showing 1`] = ` | ||
<Fragment> | ||
<Component | ||
className="ml-0" | ||
dataTest="detail-modal-uninstall-button" | ||
onClick={[MockFunction]} | ||
type="button" | ||
variant="primary" | ||
> | ||
Uninstall App | ||
</Component> | ||
</Fragment> | ||
`; |
30 changes: 30 additions & 0 deletions
30
...ponents/pages/app-detail-preview/client/__tests__/__snapshots__/app-content.test.tsx.snap
This file contains 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,30 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ClientAppContent ClientAppContent - should match snapshot 1`] = ` | ||
<Component | ||
hasMargin={false} | ||
hasPadding={false} | ||
isFlex={true} | ||
isFlexColumn={true} | ||
> | ||
<Component | ||
summary="" | ||
/> | ||
<Component | ||
images={Array []} | ||
numberImages={2} | ||
splitIndex={1} | ||
/> | ||
<Component | ||
description="" | ||
/> | ||
<Component | ||
images={Array []} | ||
numberImages={2} | ||
splitIndex={3} | ||
/> | ||
<Component | ||
permissions={Array []} | ||
/> | ||
</Component> | ||
`; |
Oops, something went wrong.