-
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: #1125: Update standalone app detail layout
- Loading branch information
Showing
10 changed files
with
305 additions
and
21 deletions.
There are no files selected for viewing
76 changes: 59 additions & 17 deletions
76
packages/marketplace/src/components/pages/developer-app-detail.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
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
175 changes: 175 additions & 0 deletions
175
packages/marketplace/src/components/ui/developer-app-detail/app-content/app-content.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,175 @@ | ||
import * as React from 'react' | ||
import { CopyToClipboard } from 'react-copy-to-clipboard' | ||
import Slider, { Settings } from 'react-slick' | ||
import ChevronLeftIcon from '@/components/svg/chevron-left' | ||
import { FaCheck, FaTimes, FaCopy } from 'react-icons/fa' | ||
import { Grid, GridItem, SubTitleH6, H6, GridThreeColItem } from '@reapit/elements' | ||
import { AppDetailModel } from '@reapit/foundations-ts-definitions' | ||
import AuthFlow from '@/constants/app-auth-flow' | ||
import AppAuthenticationDetail from '../../app-authentication-detail' | ||
import styles from '@/styles/blocks/app-detail.scss?mod' | ||
import carouselStyles from '@/styles/elements/carousel.scss?mod' | ||
|
||
type AppContentProps = { | ||
appDetailData: AppDetailModel & { | ||
apiKey?: string | undefined | ||
} | ||
loginType: string | ||
} | ||
|
||
export const SlickButtonNav = ({ children, ...props }) => <button {...props}>{children}</button> | ||
|
||
export type HandleShowApiKey = { | ||
setIsShowApikey: React.Dispatch<React.SetStateAction<boolean>> | ||
isShowApiKey: boolean | ||
} | ||
|
||
export const handleShowApiKey = ({ setIsShowApikey, isShowApiKey }: HandleShowApiKey) => () => { | ||
setIsShowApikey(!isShowApiKey) | ||
} | ||
|
||
export const handleCopyAlert = () => alert('Copied') | ||
|
||
export type RenderShowApiKeyForWebComponent = HandleShowApiKey & { | ||
isWebComponent?: boolean | ||
isCurrentLoggedUserDeveloper: boolean | ||
apiKey?: string | ||
} | ||
|
||
export const renderShowApiKeyForWebComponent = ({ | ||
isWebComponent, | ||
setIsShowApikey, | ||
isShowApiKey, | ||
apiKey, | ||
isCurrentLoggedUserDeveloper, | ||
}: RenderShowApiKeyForWebComponent) => { | ||
const isShow = isWebComponent && !isCurrentLoggedUserDeveloper | ||
if (!isShow) { | ||
return null | ||
} | ||
return ( | ||
<> | ||
<SubTitleH6 className="mb-0">API key</SubTitleH6> | ||
<p> | ||
To obtain your unique API key, click on 'Show API Key' below. For installation instructions, please | ||
click here | ||
</p> | ||
<span>Authentication:</span> | ||
<span> | ||
<a onClick={handleShowApiKey({ setIsShowApikey, isShowApiKey })}> | ||
<u>{!isShowApiKey ? 'Show' : 'Hide'} API key</u> | ||
</a> | ||
</span> | ||
{isShowApiKey && ( | ||
<CopyToClipboard text={apiKey} onCopy={handleCopyAlert}> | ||
<div className="control has-icons-right"> | ||
<input className="input is-primary" id="apiKey" type="text" name="apiKey" value={apiKey || ''} readOnly /> | ||
<span className="icon is-right"> | ||
<FaCopy /> | ||
</span> | ||
</div> | ||
</CopyToClipboard> | ||
)} | ||
</> | ||
) | ||
} | ||
|
||
const AppContent: React.FC<AppContentProps> = ({ appDetailData, loginType }) => { | ||
const { | ||
externalId, | ||
developer, | ||
isListed, | ||
id, | ||
authFlow, | ||
isWebComponent, | ||
apiKey, | ||
media = [], | ||
scopes = [], | ||
description, | ||
installedOn, | ||
} = appDetailData | ||
const [isShowApiKey, setIsShowApikey] = React.useState<boolean>(false) | ||
|
||
const isCurrentLoggedUserClient = loginType === 'CLIENT' | ||
const isCurrentLoggedUserDeveloper = loginType === 'DEVELOPER' | ||
const carouselImages = media.filter(({ type }) => type === 'image') | ||
const settings: Settings = { | ||
dots: false, | ||
speed: 500, | ||
variableWidth: true, | ||
prevArrow: ( | ||
// @ts-ignore | ||
<SlickButtonNav> | ||
<ChevronLeftIcon /> | ||
</SlickButtonNav> | ||
), | ||
nextArrow: ( | ||
// @ts-ignore | ||
<SlickButtonNav> | ||
<ChevronLeftIcon /> | ||
</SlickButtonNav> | ||
), | ||
} | ||
|
||
return ( | ||
<Grid> | ||
<GridItem className="is-3"> | ||
<div className={styles.listed}> | ||
<H6>{developer}</H6> | ||
</div> | ||
{isCurrentLoggedUserDeveloper && ( | ||
<> | ||
<p className={styles.appInfo}>App Information</p> | ||
<div key="app-id" className={styles.appInfoRow}> | ||
<p className={styles.appInfoProperty}>Client ID:</p> | ||
<p>{externalId}</p> | ||
</div> | ||
<div key="app-listed" className={styles.appInfoRow}> | ||
<p className={styles.appInfoProperty}>Status:</p> | ||
<p className={styles.appInfoSpace}>{isListed ? 'Listed' : 'Not listed'}</p> | ||
{isListed ? <FaCheck className={styles.isListed} /> : <FaTimes className={styles.notListed} />} | ||
</div> | ||
{authFlow === AuthFlow.CLIENT_SECRET && id && <AppAuthenticationDetail appId={id} />} | ||
</> | ||
)} | ||
{renderShowApiKeyForWebComponent({ | ||
isWebComponent, | ||
isShowApiKey, | ||
setIsShowApikey, | ||
apiKey: apiKey, | ||
isCurrentLoggedUserDeveloper, | ||
})} | ||
</GridItem> | ||
<GridItem className="is-9"> | ||
{carouselImages.length > 0 && ( | ||
<div className={carouselStyles.container}> | ||
<Slider {...settings}> | ||
{carouselImages.map(({ uri }, index) => ( | ||
<div key={index} className={carouselStyles.slide}> | ||
<img src={uri} /> | ||
</div> | ||
))} | ||
</Slider> | ||
</div> | ||
)} | ||
<br /> | ||
<p>{description}</p> | ||
<br /> | ||
|
||
<H6> | ||
{isCurrentLoggedUserDeveloper && 'Permissions requested'} | ||
{isCurrentLoggedUserClient && (installedOn ? 'Permissions granted' : 'Permissions required')} | ||
</H6> | ||
<Grid isMultiLine> | ||
{scopes.map(item => ( | ||
<GridThreeColItem key={item.name}> | ||
<li>{item.description}</li> | ||
</GridThreeColItem> | ||
))} | ||
</Grid> | ||
</GridItem> | ||
</Grid> | ||
) | ||
} | ||
|
||
export default AppContent |
2 changes: 2 additions & 0 deletions
2
packages/marketplace/src/components/ui/developer-app-detail/app-content/index.ts
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,2 @@ | ||
import AppContent from './app-content' | ||
export default AppContent |
32 changes: 32 additions & 0 deletions
32
packages/marketplace/src/components/ui/developer-app-detail/app-header/app-header.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,32 @@ | ||
import * as React from 'react' | ||
import { Grid, GridItem, H3 } from '@reapit/elements' | ||
import { MediaModel } from '@reapit/foundations-ts-definitions' | ||
import styles from '@/styles/pages/developer-app-detail.scss?mod' | ||
|
||
type AppHeaderProps = { | ||
appIcon?: MediaModel | ||
appName?: string | ||
developer?: string | ||
} | ||
|
||
const AppHeader: React.FC<AppHeaderProps> = ({ appIcon, appName, developer }) => { | ||
return ( | ||
<Grid className="is-vcentered "> | ||
<GridItem className="is-3"> | ||
<div className={styles.appIconContainer}> | ||
<img | ||
className="image" | ||
src={(appIcon && appIcon.uri) || 'https://bulma.io/images/placeholders/48x48.png'} | ||
alt={name} | ||
/> | ||
</div> | ||
</GridItem> | ||
<GridItem className="is-9"> | ||
<H3 className={styles.appName}>{appName}</H3> | ||
<p>{developer}</p> | ||
</GridItem> | ||
</Grid> | ||
) | ||
} | ||
|
||
export default AppHeader |
2 changes: 2 additions & 0 deletions
2
packages/marketplace/src/components/ui/developer-app-detail/app-header/index.ts
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,2 @@ | ||
import AppHeader from './app-header' | ||
export default AppHeader |
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
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,13 @@ | ||
import { ReduxState } from '@/types/core' | ||
|
||
export const selectAppDetailData = (state: ReduxState) => { | ||
return state.appDetail.appDetailData?.data || {} | ||
} | ||
|
||
export const selectAppDetailAuthentication = (state: ReduxState) => { | ||
return state.appDetail.authentication | ||
} | ||
|
||
export const selectAppDetailLoading = (state: ReduxState) => { | ||
return state.appDetail.loading | ||
} |
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
18 changes: 18 additions & 0 deletions
18
packages/marketplace/src/styles/pages/developer-app-detail.scss
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,18 @@ | ||
@import '../base/colors.scss'; | ||
|
||
.appDetailContainer { | ||
width: 100%; | ||
max-width: 1012px; | ||
margin: 0 auto; | ||
padding: 0 16px; | ||
} | ||
.appIconContainer { | ||
width: 128px; | ||
height: 128px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
background-color: #fff; | ||
border-radius: 50%; | ||
margin: 0 auto; | ||
} |