Skip to content
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

fix: #1210 #1206 - update render 'category', 'Desktop Integration Types', 'Private App' #1366

Merged
merged 5 commits into from
May 29, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,18 @@ exports[`AppContent AppContent - should match snapshot 1`] = `
</Component>
<ul />
</div>
<div
className=" "
/>
<div>
<div>
<Component>
Category
</Component>
<p>
None
</p>
</div>
<div>
<Component>
Destop Integration
Expand Down Expand Up @@ -84,7 +95,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 Expand Up @@ -147,25 +169,29 @@ exports[`AppContent renderDesktopIntegrationTypes - should match snapshot 1`] =
exports[`AppContent renderExtraMedia - should match snapshot 1`] = `
<div>
<div
key="https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/7d88729f-2366-4561-9d5c-282615f3946b.jpeg"
className=" "
>
<img
src="https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/7d88729f-2366-4561-9d5c-282615f3946b.jpeg"
/>
</div>
<div
key="https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/c4a36706-aa44-47f9-9fb6-9053eef4e581.png"
>
<img
src="https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/c4a36706-aa44-47f9-9fb6-9053eef4e581.png"
/>
</div>
<div
key="https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/65bd3b97-e78c-41cd-b75f-e06e1d2f00df.png"
>
<img
src="https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/65bd3b97-e78c-41cd-b75f-e06e1d2f00df.png"
/>
<div
key="https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/7d88729f-2366-4561-9d5c-282615f3946b.jpeg"
>
<img
src="https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/7d88729f-2366-4561-9d5c-282615f3946b.jpeg"
/>
</div>
<div
key="https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/c4a36706-aa44-47f9-9fb6-9053eef4e581.png"
>
<img
src="https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/c4a36706-aa44-47f9-9fb6-9053eef4e581.png"
/>
</div>
<div
key="https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/65bd3b97-e78c-41cd-b75f-e06e1d2f00df.png"
>
<img
src="https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/65bd3b97-e78c-41cd-b75f-e06e1d2f00df.png"
/>
</div>
</div>
</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 @@ -366,7 +394,36 @@ exports[`ClientAppDetail should not render loader when client.appDetail.data is
</Component>
<ul />
</div>
<div
className=" "
/>
<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>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>Destop Integration</H5>
<p>None</p>
</div>
)
}

return (
Expand All @@ -62,25 +72,35 @@ export const renderDesktopIntegrationTypes = (desktopIntegrationTypes: DesktopIn
)
}

export const renderExtraMedia = (media: MediaModel[] = []) =>
media.map(({ uri }) => (
<div key={uri} className={clientAppDetailStyles.gutter}>
<img src={uri} />
</div>
))
const renderExtraMediaClassNames = [clientAppDetailStyles.renderImageContainer, clientAppDetailStyles.gutter]
export const renderExtraMedia = (media: MediaModel[] = []) => (
<div className={renderExtraMediaClassNames.join(' ')}>
{media.map(({ uri }) => (
<div key={uri}>
<img src={uri} />
</div>
))}
</div>
)

const AppContent: React.FC<AppContentProps> = ({ appDetailData, desktopIntegrationTypes = [] }) => {
const { summary = '', description = '', category, scopes = [], media = [] } = appDetailData
/**
* 0 = icon
* 1 = featured media
* 2 -> nth: extra media
* 2 = bellow summary
* 3 -> nth: extra media
*/
const extraMedia = media.filter((_, index) => index > 1)
const extraMedia = media.filter((_, index) => index > 2)

return (
<div className={clientAppDetailStyles.appContentContainer}>
<div className={clientAppDetailStyles.gutter}>{summary}</div>
{media[2]?.uri && (
<div className={clientAppDetailStyles.gutter}>
<img src={media[2]?.uri} />
</div>
)}
{renderDescripion(description)}
{renderPermissions(scopes)}
{renderExtraMedia(extraMedia)}
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 All @@ -115,7 +120,7 @@ const ClientAppDetail: React.FC<ClientAppDetailProps> = () => {
isInstallBtnHidden,
)}
/>
<AppContent desktopIntegrationTypes={desktopIntegrationTypes} appDetailData={appDetailData} />
<AppContent desktopIntegrationTypes={userDesktopIntegrationTypes} appDetailData={appDetailData} />
{isVisibleUninstallConfirmation && (
<ClientAppUninstallConfirmation
visible={isVisibleUninstallConfirmation}
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 @@ -114,7 +114,7 @@ const AppContent: React.FC<AppContentProps> = ({ appDetailData }) => {
return (
<div className={clientAppDetailStyles.appContentContainer}>
{isVisibleUninstallModal && (
<Modal visible={isVisibleUninstallModal}>
<Modal renderChildren visible={isVisibleUninstallModal}>
<ConfirmUninstall
isSetAppDetailStaleAfterUninstallSuccess={false}
appName={name}
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
2 changes: 1 addition & 1 deletion packages/marketplace/src/styles/base/screen-size.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
}

@mixin for-desktop-only {
@media (min-width: 768px) { @content; }
@media (min-width: 769px) { @content; }
}

Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@

img {
background: $white;
width: 100%;
height: 100%;
}
}

Expand Down
Loading