Skip to content

Commit

Permalink
feat: #1917 Update developer preview app page
Browse files Browse the repository at this point in the history
  • Loading branch information
Vu Nguyen committed Jul 15, 2020
1 parent 63b67df commit 96f0fd1
Show file tree
Hide file tree
Showing 48 changed files with 5,340 additions and 70 deletions.
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
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>
`;
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>
`;
Loading

0 comments on commit 96f0fd1

Please sign in to comment.