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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4ec9e74
feat: #1125: Create app details standalone page
nphivu414 May 4, 2020
406b6c0
feat: #1125: Update standalone app detail layout
nphivu414 May 5, 2020
07aae78
feat: #1125: Update app detail features
nphivu414 May 5, 2020
36c3b30
feat: #1125: Update app detail header action buttons
nphivu414 May 6, 2020
3975f4f
feat: #1125: Update client app detail standalone page
nphivu414 May 6, 2020
2c19976
feat: #1125: Remove redundant logs
nphivu414 May 6, 2020
5b0d9cb
feat: #1125: Add client app uninstall confirm dialog
nphivu414 May 7, 2020
9649663
Merge branch 'master' of ssh://github.com/reapit/foundations into fea…
nphivu414 May 7, 2020
ddd314f
feat: #1125: Update client app installation flow
nphivu414 May 7, 2020
868db84
feat: #1125: Update new redux flow for client apps
nphivu414 May 8, 2020
c35dee4
feat: #1125: Update client detaill app install + uninstall behavior f…
nphivu414 May 8, 2020
863268d
feat: #1125: Merge master and fix conflicts
nphivu414 May 8, 2020
f4917e4
feat: #1125: Update client app detail redux action name
nphivu414 May 11, 2020
64c6709
feat: #1125: Update developer app detail behavior flows
nphivu414 May 11, 2020
e35560c
feat: #1125: Update new redux flow for developer apps
nphivu414 May 11, 2020
59d2133
feat: #1125: Remove comments & update modal handler param names
nphivu414 May 11, 2020
d500062
feat: #1125: Merge master into 1125 & fix conflicts
nphivu414 May 11, 2020
49fabe7
feat: #1125: Update tests
nphivu414 May 12, 2020
11bfa62
feat: #1125: Update tests for components using react-redux hooks
nphivu414 May 13, 2020
46da4ce
feat: #1125: Merge master into 1125 and fix conflicts
nphivu414 May 13, 2020
a0f740a
feat: #1125: Remove unused var
nphivu414 May 13, 2020
e2e5db9
feat: #1125: Update snapshot tests
nphivu414 May 13, 2020
9b6b4d7
feat: #1125: Update codes based on reviews
nphivu414 May 13, 2020
f65c93c
feat: #1125: Update codes based on reviews and fix router snapshot tests
nphivu414 May 13, 2020
5e83048
feat: #1125: Update redux mock store + Fix missing type issues
nphivu414 May 14, 2020
acf7726
feat: #1125: Update uninstall app modal rendeing flow
nphivu414 May 14, 2020
eb08903
feat: #1125: Fix lint issues
nphivu414 May 14, 2020
0a61d4c
Merge branch 'master' of ssh://github.com/reapit/foundations into fea…
nphivu414 May 14, 2020
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
2 changes: 1 addition & 1 deletion packages/elements/src/components/DropdownSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const DropdownSelect: React.FC<DropdownSelectProps> = ({
const handleRenderTags = (props: CustomTagProps) => {
const { value, onClose } = props
const option = options.find(option => option.value === value) as SelectOption
return <CustomTag label={option?.value} description={option.description} link={option.link} onClose={onClose} />
return <CustomTag label={option?.value} description={option?.description} link={option?.link} onClose={onClose} />
}

const handleChangeOption = field => value => {
Expand Down
34 changes: 19 additions & 15 deletions packages/marketplace/src/actions/__tests__/client.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
import { clientLoading, clientReceiveData, clientRequestData, clientClearData } from '../client'
import {
clientFetchAppSummary,
clientFetchAppSummarySuccess,
clientFetchAppSummaryFailed,
clientClearAppSummary,
} from '../client'
import ActionTypes from '../../constants/action-types'
import { appsDataStub, featuredAppsDataStub } from '../../sagas/__stubs__/apps'

describe('client actions', () => {
it('should create a clientLoading action', () => {
expect(clientLoading.type).toEqual(ActionTypes.CLIENT_LOADING)
expect(clientLoading(true).data).toEqual(true)
it('should create a clientFetchAppSummary action', () => {
expect(clientFetchAppSummary.type).toEqual(ActionTypes.CLIENT_FETCH_APP_SUMMARY)
expect(clientFetchAppSummary({ page: 1 }).data).toEqual({ page: 1 })
})

it('should create a clientReceiveData action', () => {
expect(clientReceiveData.type).toEqual(ActionTypes.CLIENT_RECEIVE_DATA)
expect(clientReceiveData({ featuredApps: featuredAppsDataStub.data.data, apps: appsDataStub.data }).data).toEqual({
it('should create a clientFetchAppSummarySuccess action', () => {
expect(clientFetchAppSummarySuccess.type).toEqual(ActionTypes.CLIENT_FETCH_APP_SUMMARY_SUCCESS)
expect(
clientFetchAppSummarySuccess({ featuredApps: featuredAppsDataStub.data.data, apps: appsDataStub.data }).data,
).toEqual({
featuredApps: featuredAppsDataStub.data.data,
apps: appsDataStub.data,
})
})

it('should create a clientRequestData action', () => {
expect(clientRequestData.type).toEqual(ActionTypes.CLIENT_REQUEST_DATA)
expect(clientRequestData({ page: 1 }).data).toEqual({ page: 1 })
it('should create a clientFetchAppSummaryFailed action', () => {
expect(clientFetchAppSummaryFailed.type).toEqual(ActionTypes.CLIENT_FETCH_APP_SUMMARY_FAILED)
expect(clientFetchAppSummaryFailed('error').data).toEqual('error')
})

it('should create a clientClearData action', () => {
expect(clientClearData.type).toEqual(ActionTypes.CLIENT_CLEAR_DATA)
expect(clientClearData(null).data).toEqual(null)
expect(clientClearAppSummary.type).toEqual(ActionTypes.CLIENT_CLEAR_APP_SUMMARY)
expect(clientClearAppSummary(null).data).toEqual(null)
})
})
3 changes: 2 additions & 1 deletion packages/marketplace/src/actions/app-installations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ export interface InstallationParams {
pageNumber?: number
}

export type InstallParams = CreateInstallationModel
export type InstallParams = CreateInstallationModel & { callback?: () => void }

export type UninstallParams = {
installationId: string
callback?: () => void
} & TerminateInstallationModel

export const appInstallationsRequestData = actionCreator<InstallationParams>(ActionTypes.APP_INSTALLATIONS_REQUEST_DATA)
Expand Down
24 changes: 16 additions & 8 deletions packages/marketplace/src/actions/client.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { actionCreator } from '../utils/actions'
import ActionTypes from '../constants/action-types'
import { ClientItem, ClientParams } from '../reducers/client'
import { actionCreator } from '@/utils/actions'
import ActionTypes from '@/constants/action-types'
import { ClientAppSummary, ClientAppSummaryParams } from '@/reducers/client/app-summary'
import { AppDetailData } from '@/reducers/client/app-detail'
import { FetchAppDetailParams } from '@/services/apps'

export const clientRequestData = actionCreator<ClientParams>(ActionTypes.CLIENT_REQUEST_DATA)
export const clientRequestDataFailure = actionCreator<void>(ActionTypes.CLIENT_REQUEST_FAILURE)
export const clientLoading = actionCreator<boolean>(ActionTypes.CLIENT_LOADING)
export const clientReceiveData = actionCreator<ClientItem | undefined>(ActionTypes.CLIENT_RECEIVE_DATA)
export const clientClearData = actionCreator<null>(ActionTypes.CLIENT_CLEAR_DATA)
export const clientFetchAppSummary = actionCreator<ClientAppSummaryParams>(ActionTypes.CLIENT_FETCH_APP_SUMMARY)
export const clientFetchAppSummarySuccess = actionCreator<ClientAppSummary | undefined>(
ActionTypes.CLIENT_FETCH_APP_SUMMARY_SUCCESS,
)
export const clientFetchAppSummaryFailed = actionCreator<string>(ActionTypes.CLIENT_FETCH_APP_SUMMARY_FAILED)
export const clientClearAppSummary = actionCreator<null>(ActionTypes.CLIENT_CLEAR_APP_SUMMARY)

// Client App Detail
export const clientFetchAppDetail = actionCreator<FetchAppDetailParams>(ActionTypes.CLIENT_FETCH_APP_DETAIL)
export const clientFetchAppDetailSuccess = actionCreator<AppDetailData>(ActionTypes.CLIENT_FETCH_APP_DETAIL_SUCCESS)
export const clientFetchAppDetailFailed = actionCreator<string>(ActionTypes.CLIENT_FETCH_APP_DETAIL_FAILED)
9 changes: 9 additions & 0 deletions packages/marketplace/src/actions/developer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { actionCreator } from '../utils/actions'
import ActionTypes from '../constants/action-types'
import {
AppDetailData,
DeveloperItem,
DeveloperRequestParams,
Billing,
Expand All @@ -11,9 +12,17 @@ import {
import { CreateDeveloperModel, DeveloperModel } from '@reapit/foundations-ts-definitions'
import { FormState } from '@/types/core'
import { FetchBillingParams } from '@/sagas/api'
import { FetchAppDetailParams } from '@/services/apps'
import { FetchMonthlyBillingParams } from '@/services/billings'
import { WebhookPingTestParams } from '@/services/subscriptions'

// Developer App Detail
export const developerFetchAppDetail = actionCreator<FetchAppDetailParams>(ActionTypes.DEVELOPER_FETCH_APP_DETAIL)
export const developerFetchAppDetailSuccess = actionCreator<AppDetailData>(
ActionTypes.DEVELOPER_FETCH_APP_DETAIL_SUCCESS,
)
export const developerFetchAppDetailFailed = actionCreator<string>(ActionTypes.DEVELOPER_FETCH_APP_DETAIL_FAILED)

export const developerRequestData = actionCreator<DeveloperRequestParams>(ActionTypes.DEVELOPER_REQUEST_DATA)
export const developerRequestDataFailure = actionCreator<void>(ActionTypes.DEVELOPER_REQUEST_DATA_FAILURE)
export const developerLoading = actionCreator<boolean>(ActionTypes.DEVELOPER_LOADING)
Expand Down
1 change: 1 addition & 0 deletions packages/marketplace/src/actions/revision-detail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { FormState } from '@/types/core'
export interface RevisionDetailRequestParams {
appId: string
appRevisionId: string
callback?: () => void
}

export interface RevisionReceiveDataParams extends RevisionDetailItem {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ exports[`DeveloperHome should match a snapshot 1`] = `
pagination={
Object {
"onChange": [Function],
"pageNumber": 2,
"pageNumber": 1,
"pageSize": 2,
"totalCount": 6,
}
Expand Down Expand Up @@ -139,7 +139,7 @@ exports[`DeveloperHome should match a snapshot 3`] = `
pagination={
Object {
"onChange": [Function],
"pageNumber": 2,
"pageNumber": 1,
"pageSize": 2,
"totalCount": 6,
}
Expand Down
43 changes: 26 additions & 17 deletions packages/marketplace/src/components/pages/__tests__/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Provider } from 'react-redux'
import { shallow, mount } from 'enzyme'
import { appsDataStub, featuredAppsDataStub } from '@/sagas/__stubs__/apps'
import { ReduxState } from '@/types/core'
import { ClientItem } from '@/reducers/client'
import { ClientAppSummary } from '@/reducers/client/app-summary'
import {
Client,
ClientProps,
Expand Down Expand Up @@ -34,12 +34,12 @@ const routerProps = {
} as RouteComponentProps<any, StaticContext, any>

const props = (loading: boolean): ClientProps => ({
clientState: {
loading: loading,
clientData: {
appSummaryState: {
isAppSummaryLoading: loading,
data: {
featuredApps: featuredAppsDataStub.data,
apps: appsDataStub,
} as ClientItem,
} as ClientAppSummary,
},
appDetail: {
appDetailData: appDetailDataStub,
Expand Down Expand Up @@ -81,12 +81,12 @@ describe('Client', () => {
} as RouteComponentProps<any, StaticContext, any>

const props: ClientProps = {
clientState: {
loading: false,
clientData: {
appSummaryState: {
isAppSummaryLoading: false,
data: {
featuredApps: [] as AppSummaryModel[],
apps: appsDataStub,
} as ClientItem,
} as ClientAppSummary,
},
appDetail: {
appDetailData: appDetailDataStub,
Expand All @@ -111,12 +111,12 @@ describe('Client', () => {

it('should match a snapshot when featured apps is undefined', () => {
const props: ClientProps = {
clientState: {
loading: false,
clientData: {
appSummaryState: {
isAppSummaryLoading: false,
data: {
featuredApps: undefined,
apps: appsDataStub,
} as ClientItem,
} as ClientAppSummary,
},
appDetail: {
appDetailData: appDetailDataStub,
Expand All @@ -143,9 +143,18 @@ describe('Client', () => {
it('should return correctly', () => {
const mockState = {
client: {
clientData: {
featuredApps: featuredAppsDataStub.data,
apps: appsDataStub,
appSummary: {
data: {
apps: appsDataStub.data,
featuredApps: featuredAppsDataStub.data,
},
isAppSummaryLoading: false,
error: 'error',
},
appDetail: {
data: appDetailDataStub.data,
isAppDetailLoading: false,
error: '',
},
},
appDetail: {
Expand All @@ -165,7 +174,7 @@ describe('Client', () => {
},
} as ReduxState
const output = {
clientState: mockState.client,
appSummaryState: mockState.client.appSummary,
appDetail: mockState.appDetail,
clientId: 'ABC',
installationsFormState: 'PENDING',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ describe('DeveloperHome', () => {
webhookPingTestStatus: null,
loading: false,
isVisible: false,
developerAppDetail: {
data: null,
isAppDetailLoading: false,
},
developerData: {
...appsDataStub,
scopes: appPermissionStub,
Expand Down Expand Up @@ -76,6 +80,10 @@ describe('DeveloperHome', () => {
},
loading: false,
isVisible: true,
developerAppDetail: {
data: null,
isAppDetailLoading: false,
},
developerData: {
...appsDataStub,
scopes: appPermissionStub,
Expand Down Expand Up @@ -125,10 +133,10 @@ describe('DeveloperHome', () => {
it('should call push correctly', () => {
const mockHistory = {
push: jest.fn(),
}
} as any
const fn = handleOnChange(mockHistory)
fn(1)
expect(mockHistory.push).toBeCalledWith(`${routes.DEVELOPER_MY_APPS}/${1}`)
expect(mockHistory.push).toBeCalledWith(`${routes.DEVELOPER_MY_APPS}?page=1`)
})
})

Expand Down
Loading