Skip to content

Commit

Permalink
fix: #1210 #1206 - update render Private App
Browse files Browse the repository at this point in the history
  • Loading branch information
undefined committed May 27, 2020
1 parent e5405a5 commit 16ad7fd
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ exports[`AppContent AppContent - should match snapshot 1`] = `
<ul />
</div>
<div>
<div>
<Component>
Category
</Component>
<p>
None
</p>
</div>
<div>
<Component>
Destop Integration
Expand Down Expand Up @@ -84,7 +92,18 @@ exports[`AppContent AppContent - should match snapshot 1`] = `
</div>
`;

exports[`AppContent renderCategory - should match snapshot 1`] = `<div />`;
exports[`AppContent renderCategory - should match snapshot 1`] = `
<div>
<div>
<Component>
Category
</Component>
<p>
None
</p>
</div>
</div>
`;

exports[`AppContent renderDescripion - should match snapshot 1`] = `
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ exports[`Aside Aside - should match snapshot 1`] = `
<Component />
<Component />
<Component />
<div />
<div>
<div>
<Component>
Category
</Component>
<p>
None
</p>
</div>
</div>
<div>
<div>
<Component>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,36 @@ exports[`ClientAppDetail should not render loader when client.appDetail.data is
</div>
</Component>
</Component>
<div />
<div />
<div>
<div>
<Component>
<h5
className="title is-5 "
id=""
>
Category
</h5>
</Component>
<p>
None
</p>
</div>
</div>
<div>
<div>
<Component>
<h5
className="title is-5 "
id=""
>
Destop Integration
</h5>
</Component>
<p>
None
</p>
</div>
</div>
</div>
</div>
</Component>
Expand Down Expand Up @@ -367,6 +395,32 @@ exports[`ClientAppDetail should not render loader when client.appDetail.data is
<ul />
</div>
<div>
<div>
<Component>
<h5
className="title is-5 "
id=""
>
Category
</h5>
</Component>
<p>
None
</p>
</div>
<div>
<Component>
<h5
className="title is-5 "
id=""
>
Destop Integration
</h5>
</Component>
<p>
None
</p>
</div>
<Component
header="Developer"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ export const renderPermissions = (scopes: ScopeModel[] = []) => (

export const renderCategory = (category: CategoryModel | undefined) => {
if (!category) {
return null
return (
<div className={clientAppDetailStyles.gutter}>
<H5 className={standAloneAppDetailStyles.headerWithoutMargin}>Category</H5>
<p>None</p>
</div>
)
}

return (
Expand All @@ -49,7 +54,12 @@ export const renderCategory = (category: CategoryModel | undefined) => {

export const renderDesktopIntegrationTypes = (desktopIntegrationTypes: DesktopIntegrationTypeModel[]) => {
if (desktopIntegrationTypes.length === 0) {
return null
return (
<div className={clientAppDetailStyles.gutter}>
<H5 className={standAloneAppDetailStyles.headerWithoutMargin}>Destop Integration</H5>
<p>None</p>
</div>
)
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Loader, Button } from '@reapit/elements'
import clientAppDetailStyles from '@/styles/pages/client-app-detail.scss?mod'
import ClientAppInstallConfirmation from '@/components/ui/client-app-detail/client-app-install-confirmation'
import { Aside } from './aside'
import { getDesktopIntegrationTypes } from '@/utils/get-desktop-integration-types'

export type ClientAppDetailProps = {}

Expand Down Expand Up @@ -89,6 +90,10 @@ const ClientAppDetail: React.FC<ClientAppDetailProps> = () => {

const desktopIntegrationTypes = useSelector(selectIntegrationTypes) as DesktopIntegrationTypeModel[]
const appDetailData = useSelector(selectAppDetailData) as AppDetailDataNotNull
const userDesktopIntegrationTypes = getDesktopIntegrationTypes(
appDetailData.desktopIntegrationTypeIds || [],
desktopIntegrationTypes,
)
const isLoadingAppDetail = useSelector(selectAppDetailLoading)
const loginType = useSelector(selectLoginType)
const isAdmin = useSelector(selectIsAdmin)
Expand All @@ -103,7 +108,7 @@ const ClientAppDetail: React.FC<ClientAppDetailProps> = () => {

return (
<div data-test="client-app-detail-container" className={clientAppDetailStyles.appDetailContainer}>
<Aside appDetailData={appDetailData} desktopIntegrationTypes={desktopIntegrationTypes} />
<Aside appDetailData={appDetailData} desktopIntegrationTypes={userDesktopIntegrationTypes} />
<div className={clientAppDetailStyles.mainContainer}>
<AppHeader
appDetailData={appDetailData}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@ exports[`Aside Aside - should match snapshot 1`] = `
className=" "
>
<div>
<div />
<div>
<div>
<Component>
Category
</Component>
<p>
None
</p>
</div>
</div>
<div>
<div>
<Component>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const renderListedStatus = (isListed: boolean) => {

export const Aside: React.FC<AsideProps> = ({ desktopIntegrationTypes, appDetailState }) => {
const { data } = appDetailState
const { isDirectApi, category, isListed, pendingRevisions, id = '', limitToClientIds } = data as AppDetailModel
const { isDirectApi, category, isListed, pendingRevisions, id = '', limitToClientIds = [] } = data as AppDetailModel

return (
<div className={asideContainerClasses}>
Expand All @@ -139,7 +139,7 @@ export const Aside: React.FC<AsideProps> = ({ desktopIntegrationTypes, appDetail
{renderDesktopIntegrationTypes(desktopIntegrationTypes)}
</div>
<RenderWithHeader header="Private App">
{convertBooleanToYesNoString(Boolean(limitToClientIds))}
{convertBooleanToYesNoString(Boolean(limitToClientIds.length > 0))}
</RenderWithHeader>
<RenderWithHeader header="Direct API">{convertBooleanToYesNoString(Boolean(isDirectApi))}</RenderWithHeader>
<RenderWithHeader header="Status">{renderListedStatus(Boolean(isListed))}</RenderWithHeader>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import styles from '@/styles/pages/developer-app-detail.scss?mod'
import AppRevisionModal from '@/components/ui/developer-app-detail/app-revision-modal'
import { useHistory } from 'react-router'
import { DeveloperAppDetailState } from '@/reducers/developer'
import { getDesktopIntegrationTypes } from '@/utils/get-desktop-integration-types'

export type DeveloperAppDetailProps = {}

Expand Down Expand Up @@ -85,14 +86,18 @@ const DeveloperAppDetail: React.FC<DeveloperAppDetailProps> = () => {
const installationsData = useSelector(selectInstallationAppData) as PagedResultInstallationModel_
const unfetch = !appDetailState?.data || !installationsData?.data
const { id = '', name = '' } = appDetailData
const userDesktopIntegrationTypes = getDesktopIntegrationTypes(
appDetailData.desktopIntegrationTypeIds || [],
desktopIntegrationTypes,
)

if (isLoadingAppDetail || isLoadingInstallations || unfetch) {
return <Loader />
}

return (
<div className={styles.appDetailContainer}>
<Aside desktopIntegrationTypes={desktopIntegrationTypes} appDetailState={appDetailState} />
<Aside desktopIntegrationTypes={userDesktopIntegrationTypes} appDetailState={appDetailState} />
<div className={styles.mainContainer}>
<AppHeader appDetailData={appDetailData} />
<AppContent appDetailData={appDetailData} />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { getDesktopIntegrationTypes } from '../get-desktop-integration-types'

describe('getDesktopIntegrationTypes', () => {
it('shold working correctly', () => {
const mockDesktopIntegrationTypes = [{ id: '1' }, { id: '2' }]
expect(getDesktopIntegrationTypes(['1'], mockDesktopIntegrationTypes)).toEqual([mockDesktopIntegrationTypes[0]])
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { DesktopIntegrationTypeModel } from '@/actions/app-integration-types'

export const getDesktopIntegrationTypes = (
desktopIntegrationTypeIds: string[],
desktopIntegrationTypes: DesktopIntegrationTypeModel[],
) =>
desktopIntegrationTypes.filter(desktopIntegrationType =>
desktopIntegrationTypeIds.includes(desktopIntegrationType.id || ''),
)

0 comments on commit 16ad7fd

Please sign in to comment.