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

feat: #1125 Standalone app page #1240

Merged
merged 28 commits into from
May 14, 2020
Merged

Conversation

nphivu414
Copy link
Contributor

@nphivu414 nphivu414 commented May 13, 2020

Currently, as a user client or developer, I view app details in a modal. These modals have grown too small for their use case so require a standalone app page

@github-actions github-actions bot added elements Relates to Elements components and utilities marketplace Relates to the Marketplace labels May 13, 2020
onUninstallSuccess={closeInstallationsModal(setIsInstallationsModalOpen)}
/>

<AppRevisionModal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think should unmount and remove from DOM tree modal isAppRevisionComparisionModalOpen && <AppRevisionModal ... if we don't show it on UI

@github-actions github-actions bot requested a review from duong-se May 13, 2020 09:21
speed: 500,
variableWidth: true,
prevArrow: (
// @ts-ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can write like this

const renderSlickButton = () => {
  return (
  <SlickButtonNav>
    <ChevronLeftIcon />
  </SlickButtonNav>
  )
}
...
prevArrow: renderSlickButton(),
...

</SlickButtonNav>
),
nextArrow: (
// @ts-ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

<GridItem className="is-8">
<HTMLRender className={styles.description} html={description} />
<br />
{carouselImages.length > 0 && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this component too long pls separate to function renderCarousel

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tanphamhaiduong,
Because this view is going to be changed when building the new UI for standalone app page, refactoring these codes here will means nothing, we will still have to rework anyway

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we may not even use the carousel. It's fine to leave

)}
<br />
<Grid isMultiLine>
{scopes.map(item => (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this component too long pls separate to function renderScopes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tanphamhaiduong,
Because this view is going to be changed when building the new UI for standalone app page, refactoring these codes here will means nothing, we will still have to rework anyway


if (location && location.search) {
const pageQueryString = getParamValueFromPath(location.search, 'page')
pageNumber = Number(pageQueryString) > 0 ? Number(pageQueryString) : 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So do we need to check this Number(pageQueryString) > 0 ?

}
>
<>
{scopes.length ? (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think should move this out because function render too long.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tanphamhaiduong,
Because this view is going to be changed when building the new UI for standalone app page, refactoring these codes here will means nothing, we will still have to rework anyway

)}
</>
</Modal>
<Modal visible={isSuccessAlertVisible} afterClose={handleSuccessAlertMessageAfterClose(setIsSuccessAlertVisible)}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think should un mount if we don't use modal isSuccessAlertVisible && <Modal visible={isSuccessAlertVisible} ...


return (
<>
<Modal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

visible && Modal ...

visible={visible}
title={`Confirm ${name} installation`}
afterClose={closeUninstallConfirmationModal}
footerItems={
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This func too long pls move to renderFooterItems function


return (
<>
<Modal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unmount if we dont use it

>
<>Are you sure you wish to uninstall {name}? This action will uninstall the app for ALL platform users</>
</Modal>
<Modal visible={isSuccessAlertVisible} afterClose={handleSuccessAlertMessageAfterClose(setIsSuccessAlertVisible)}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unmount if we dont use it

visible={isConfirmationModalVisible}
title="Please confirm"
afterClose={() => setIsConfirmationModalVisible(false)}
footerItems={
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you move this to function renderItems

<p>Are you sure you wish to cancel any pending revisions for this App?</p>
</Modal>

<Modal visible={isDeclinedSuccessfully} afterClose={afterClose}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isDeclinedSuccessfully && Modal

) : (
<AppRevisionComparision appDetailData={appDetailState.data} revisionDetailState={appRevisionDetail} />
)}
<Modal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isConfirmationModalVisible && isConfirmationModalVisible

@github-actions github-actions bot requested a review from duong-se May 13, 2020 10:46
Copy link
Contributor

@willmcvay willmcvay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small tweaks but looks great, nice work 💯

@@ -1,9 +1,17 @@
import { actionCreator } from '../utils/actions'
import ActionTypes from '../constants/action-types'
import { ClientItem, ClientParams } from '../reducers/client'
import { ClientAppSummary, ClientAppSummaryParams } from '../reducers/client/app-summary'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small point but @/reducers/...

}
}

export const renderAppHeaderButtonGroup = (id, installedOn, onInstallConfirmationModal) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add definitions to these params please?

}
}

export const renderAppHeaderButtonGroup = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add definitions to these params please?

const pageNumber = match.params && !isNaN(match.params.page) ? Number(match.params.page) : 1
let pageNumber = 1

if (location && location.search) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if there was a pagination util that gets this detail from the URL where required and returns 1 as the default. Not a big deal but would be nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't really get your idea here, can you explain it a bit more for me?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a getPageFromLocation helper that would return the page number from location. It's not important though

renderUninstallConfirmationModalFooter,
} from '../client-app-uninstall-confirmation'

const mockState = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And again with the mock state :-)

}
}

export const handleSuccessAlertButtonClick = history => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This history.replace function is used a lot. Feels like we should use a util helper. Also, history is type History :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't build a util helper for history.replace and call it directly in functions like handleSuccessAlertButtonClick because useHistory hook can only called in a function component

import { revisionDetailRequestData } from '@/actions/revision-detail'
import { developerFetchAppDetail } from '@/actions/developer'

const mockState = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And again with mock state - mock state module?

error: null,
}

const appSumarryReducer = (state: ClientAppSummaryState = defaultState, action: Action<any>): ClientAppSummaryState => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small typo, summary has 1 r :-)

import { fetcher } from '@reapit/elements'
import { URLS, generateHeader } from '../constants/api'

export interface FetchAppDetailParams {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You define this interface but don't use it!

Also, needs a test I think for this file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FetchAppDetailParams is used in src/actions/client.ts
export const clientFetchAppDetail = actionCreator<FetchAppDetailParams>(ActionTypes.CLIENT_FETCH_APP_DETAIL)

and in src/actions/developer.ts
export const developerFetchAppDetail = actionCreator<FetchAppDetailParams>(ActionTypes.DEVELOPER_FETCH_APP_DETAIL)

I added a test for this file by the way

@github-actions github-actions bot requested a review from willmcvay May 14, 2020 04:15
Copy link
Contributor

@willmcvay willmcvay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice one 👍

const pageNumber = match.params && !isNaN(match.params.page) ? Number(match.params.page) : 1
let pageNumber = 1

if (location && location.search) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a getPageFromLocation helper that would return the page number from location. It's not important though

@@ -0,0 +1,219 @@
import { ReduxState } from '@/types/core'

const appState: ReduxState = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@vuhuucuong vuhuucuong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Others look good to me👍


export type AppContentProps = {
appDetailData: AppDetailModel & {
apiKey?: string | undefined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need | undefined here
apiKey?: string is enough


export type AppHeaderProps = {
appDetailData: AppDetailModel & {
apiKey?: string | undefined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need |undefined

<div className={styles.appIconContainer}>
<img
className="image"
src={(appIcon && appIcon.uri) || 'https://bulma.io/images/placeholders/48x48.png'}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appIcon?.uri || 'https://...' for short

Comment on lines +55 to +56
appScopes: ScopeModel[] | undefined
revisionScopes: ScopeModel[] | undefined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appScopes?: ScopeModel[]
revisionScopes?: ScopeModel[]

@nphivu414 nphivu414 merged commit 12cc29d into master May 14, 2020
@nphivu414 nphivu414 deleted the feat/1125-standalone-app-page branch May 14, 2020 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
elements Relates to Elements components and utilities marketplace Relates to the Marketplace
Projects
None yet
Development

Successfully merging this pull request may close these issues.

As a developer or client, I should be able to view an app in a standalone page
4 participants