diff --git a/packages/marketplace/src/components/pages/app-detail/developer/__tests__/__snapshots__/developer-app-content.test.tsx.snap b/packages/marketplace/src/components/pages/app-detail/developer/__tests__/__snapshots__/developer-app-content.test.tsx.snap
index 066003d81f..404e7d0654 100644
--- a/packages/marketplace/src/components/pages/app-detail/developer/__tests__/__snapshots__/developer-app-content.test.tsx.snap
+++ b/packages/marketplace/src/components/pages/app-detail/developer/__tests__/__snapshots__/developer-app-content.test.tsx.snap
@@ -563,7 +563,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -633,7 +633,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -698,7 +698,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"subRows": Array [],
"toggleRowExpanded": [Function],
"values": Object {
- "Date Installed": "03/12/2019",
+ "Date Installed": "03 Dec 2019",
"Uninstall": undefined,
"client": "DXX",
},
@@ -914,7 +914,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -1016,7 +1016,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -1081,7 +1081,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"subRows": Array [],
"toggleRowExpanded": [Function],
"values": Object {
- "Date Installed": "03/12/2019",
+ "Date Installed": "03 Dec 2019",
"Uninstall": undefined,
"client": "DXX",
},
@@ -1241,7 +1241,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -1343,7 +1343,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -1408,7 +1408,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"subRows": Array [],
"toggleRowExpanded": [Function],
"values": Object {
- "Date Installed": "03/12/2019",
+ "Date Installed": "03 Dec 2019",
"Uninstall": undefined,
"client": "DXX",
},
@@ -1765,7 +1765,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -1867,7 +1867,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -1932,7 +1932,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"subRows": Array [],
"toggleRowExpanded": [Function],
"values": Object {
- "Date Installed": "03/12/2019",
+ "Date Installed": "03 Dec 2019",
"Uninstall": undefined,
"client": "DXX",
},
@@ -2007,7 +2007,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -2109,7 +2109,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -2174,7 +2174,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"subRows": Array [],
"toggleRowExpanded": [Function],
"values": Object {
- "Date Installed": "03/12/2019",
+ "Date Installed": "03 Dec 2019",
"Uninstall": undefined,
"client": "DXX",
},
@@ -2248,7 +2248,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -2350,7 +2350,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -2415,7 +2415,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"subRows": Array [],
"toggleRowExpanded": [Function],
"values": Object {
- "Date Installed": "03/12/2019",
+ "Date Installed": "03 Dec 2019",
"Uninstall": undefined,
"client": "DXX",
},
@@ -2490,7 +2490,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -2592,7 +2592,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -2657,7 +2657,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"subRows": Array [],
"toggleRowExpanded": [Function],
"values": Object {
- "Date Installed": "03/12/2019",
+ "Date Installed": "03 Dec 2019",
"Uninstall": undefined,
"client": "DXX",
},
@@ -3061,12 +3061,12 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"subRows": Array [],
"toggleRowExpanded": [Function],
"values": Object {
- "Date Installed": "03/12/2019",
+ "Date Installed": "03 Dec 2019",
"Uninstall": undefined,
"client": "DXX",
},
},
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
}
}
column={
@@ -3277,7 +3277,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -3379,7 +3379,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -3444,7 +3444,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"subRows": Array [],
"toggleRowExpanded": [Function],
"values": Object {
- "Date Installed": "03/12/2019",
+ "Date Installed": "03 Dec 2019",
"Uninstall": undefined,
"client": "DXX",
},
@@ -3604,7 +3604,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -3706,7 +3706,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -3771,7 +3771,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"subRows": Array [],
"toggleRowExpanded": [Function],
"values": Object {
- "Date Installed": "03/12/2019",
+ "Date Installed": "03 Dec 2019",
"Uninstall": undefined,
"client": "DXX",
},
@@ -4128,7 +4128,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -4230,7 +4230,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -4295,7 +4295,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"subRows": Array [],
"toggleRowExpanded": [Function],
"values": Object {
- "Date Installed": "03/12/2019",
+ "Date Installed": "03 Dec 2019",
"Uninstall": undefined,
"client": "DXX",
},
@@ -4370,7 +4370,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -4472,7 +4472,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -4537,7 +4537,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"subRows": Array [],
"toggleRowExpanded": [Function],
"values": Object {
- "Date Installed": "03/12/2019",
+ "Date Installed": "03 Dec 2019",
"Uninstall": undefined,
"client": "DXX",
},
@@ -4611,7 +4611,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -4713,7 +4713,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -4778,7 +4778,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"subRows": Array [],
"toggleRowExpanded": [Function],
"values": Object {
- "Date Installed": "03/12/2019",
+ "Date Installed": "03 Dec 2019",
"Uninstall": undefined,
"client": "DXX",
},
@@ -4853,7 +4853,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -4955,7 +4955,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"getCellProps": [Function],
"render": [Function],
"row": [Circular],
- "value": "03/12/2019",
+ "value": "03 Dec 2019",
},
Object {
"column": Object {
@@ -5020,7 +5020,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
"subRows": Array [],
"toggleRowExpanded": [Function],
"values": Object {
- "Date Installed": "03/12/2019",
+ "Date Installed": "03 Dec 2019",
"Uninstall": undefined,
"client": "DXX",
},
@@ -5043,7 +5043,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
totalColumnsMinWidth={0}
totalColumnsWidth={450}
useControlledState={[Function]}
- value="03/12/2019"
+ value="03 Dec 2019"
visibleColumns={
Array [
Object {
@@ -5130,7 +5130,7 @@ exports[`AppContent AppContent - should match snapshoot 1`] = `
]
}
>
- 03/12/2019
+ 03 Dec 2019
{
expect(spyOpenUrl).toBeCalledWith('developer/apps/appId/preview', '_blank')
})
})
+
+ describe('generateInstallationTableColumns', () => {
+ it('should run correctly', () => {
+ const result = generateInstallationTableColumns(jest.fn())()
+ expect(result).toHaveLength(3)
+ })
+ })
})
diff --git a/packages/marketplace/src/components/pages/app-detail/developer/developer-app-content.tsx b/packages/marketplace/src/components/pages/app-detail/developer/developer-app-content.tsx
index d53e67801e..662a368e3d 100644
--- a/packages/marketplace/src/components/pages/app-detail/developer/developer-app-content.tsx
+++ b/packages/marketplace/src/components/pages/app-detail/developer/developer-app-content.tsx
@@ -1,16 +1,16 @@
import * as React from 'react'
+import dayjs from 'dayjs'
import { Dispatch } from 'redux'
import { GET_ALL_PAGE_SIZE } from '@/constants/paginator'
import { appInstallationsRequestData } from '@/actions/app-installations'
import { selectDeveloperId } from '@/selector'
-import { FlexContainerBasic } from '@reapit/elements'
+import { FlexContainerBasic, Button, DATE_TIME_FORMAT } from '@reapit/elements'
import ConfirmUninstall from '@/components/ui/app-installations/confirm-uninstall'
import { PagedResultInstallationModel_, InstallationModel } from '@reapit/foundations-ts-definitions'
import { handleUninstall, handleAfterClose } from '@/components/ui/app-installations/app-installations-modal'
import { useSelector, useDispatch } from 'react-redux'
import { selectInstallationAppData } from '@/selector/installations'
import { Modal } from '@reapit/elements'
-import { generateColumns } from '@/components/ui/app-installations/installations'
import { AppDetailDataNotNull } from '@/reducers/client/app-detail'
import { DeveloperAppDetailState } from '@/reducers/developer'
import {
@@ -25,6 +25,8 @@ export type AppContentProps = {
appDetailState: DeveloperAppDetailState
}
+export type CustomUninstallCell = React.FC<{ onClick: () => void }>
+
interface HandleUninstallSuccessParams {
handleAfterClose: any
setUninstallApp: React.Dispatch>
@@ -61,6 +63,38 @@ export const CustomUninstallCell: React.FC<{ onClick: () => void }> = ({ onClick
Uninstall
)
+export const generateInstallationTableColumns = (
+ onUninstall: (app: InstallationModel) => () => void,
+ CustomUninstallCell?: CustomUninstallCell,
+) => () => {
+ const UninstallCell = ({ row }) => {
+ if (CustomUninstallCell) {
+ return
+ }
+
+ return (
+
+ )
+ }
+
+ return [
+ {
+ Header: 'Client',
+ accessor: 'client',
+ },
+ {
+ Header: 'Date Installed',
+ accessor: d => dayjs(d.created).format(DATE_TIME_FORMAT.DATE_FORMAT),
+ },
+ {
+ Header: 'Uninstall',
+ Cell: UninstallCell,
+ },
+ ]
+}
+
const AppContent: React.FC = ({ appDetailState }) => {
const appDetailData = appDetailState.data as AppDetailDataNotNull
const { summary = '', authFlow = '', externalId = '', id = '', name = '', scopes = [] } = appDetailData
@@ -70,7 +104,10 @@ const AppContent: React.FC = ({ appDetailState }) => {
const developerId = useSelector(selectDeveloperId) || ''
const [uninstallApp, setUninstallApp] = React.useState()
- const columns = generateColumns(handleUninstall(setUninstallApp), CustomUninstallCell)()
+ const installationTableColumns = generateInstallationTableColumns(
+ handleUninstall(setUninstallApp),
+ CustomUninstallCell,
+ )()
const isVisibleUninstallModal = Boolean(uninstallApp)
return (
@@ -96,7 +133,7 @@ const AppContent: React.FC = ({ appDetailState }) => {
-
+
)
}
diff --git a/packages/marketplace/src/components/pages/app-detail/developer/developer-app-detail.tsx b/packages/marketplace/src/components/pages/app-detail/developer/developer-app-detail.tsx
index 0ea251c3d5..274c08b3a3 100644
--- a/packages/marketplace/src/components/pages/app-detail/developer/developer-app-detail.tsx
+++ b/packages/marketplace/src/components/pages/app-detail/developer/developer-app-detail.tsx
@@ -12,13 +12,11 @@ import { selectInstallAppLoading } from '@/selector/installations'
import { Loader, FlexContainerResponsive, FlexContainerBasic, Grid, GridItem } from '@reapit/elements'
import AppHeader from '@/components/pages/app-detail/common/ui-app-header'
import styles from '@/styles/blocks/standalone-app-detail.scss?mod'
-import AppInstallations from '@/components/ui/app-installations/app-installations-modal'
import routes from '@/constants/routes'
import { getDesktopIntegrationTypes } from '@/utils/get-desktop-integration-types'
import useReactResponsive from '@/components/hooks/use-react-responsive'
import { BackToAppsSection } from '../common/ui-sections'
import AppContent from './developer-app-content'
-import AppRevisionModal from './developer-app-revision-modal'
export type DeveloperAppDetailProps = {}
@@ -46,8 +44,6 @@ export const onBackToAppsButtonClick = (history: History) => () => {
const DeveloperAppDetail: React.FC = () => {
const history = useHistory()
- const [isInstallationsModalOpen, setIsInstallationsModalOpen] = React.useState(false)
- const [isAppRevisionComparisonModalOpen, setIsAppRevisionComparisonModalOpen] = React.useState(false)
const { isMobile } = useReactResponsive()
const appDetailState = useSelector(selectAppDetailState)
@@ -57,7 +53,6 @@ const DeveloperAppDetail: React.FC = () => {
const desktopIntegrationTypes = useSelector(selectIntegrationTypes) as DesktopIntegrationTypeModel[]
const installationsData = useSelector(selectInstallationAppData) as PagedResultInstallationModel_
const unfetch = !appDetailState?.data || !installationsData?.data
- const { id = '', name = '' } = appDetailData
const userDesktopIntegrationTypes = getDesktopIntegrationTypes(
appDetailData.desktopIntegrationTypeIds || [],
desktopIntegrationTypes,
@@ -80,23 +75,6 @@ const DeveloperAppDetail: React.FC = () => {
{!isMobile && }
- {isInstallationsModalOpen && (
-
- )}
- {isAppRevisionComparisonModalOpen && (
-
- )}
)
diff --git a/packages/marketplace/src/components/ui/app-installations/__tests__/__snapshots__/app-installations-modal.tsx.snap b/packages/marketplace/src/components/ui/app-installations/__tests__/__snapshots__/app-installations-modal.tsx.snap
index 6bf3673015..7c2efa8d17 100644
--- a/packages/marketplace/src/components/ui/app-installations/__tests__/__snapshots__/app-installations-modal.tsx.snap
+++ b/packages/marketplace/src/components/ui/app-installations/__tests__/__snapshots__/app-installations-modal.tsx.snap
@@ -5,11 +5,5 @@ exports[`AppInstallationsModal should match a snapshot 1`] = `
afterClose={[MockFunction]}
renderChildren={true}
visible={true}
->
-
-
+/>
`;
diff --git a/packages/marketplace/src/components/ui/app-installations/__tests__/__snapshots__/installations.tsx.snap b/packages/marketplace/src/components/ui/app-installations/__tests__/__snapshots__/installations.tsx.snap
deleted file mode 100644
index 694fdd1b71..0000000000
--- a/packages/marketplace/src/components/ui/app-installations/__tests__/__snapshots__/installations.tsx.snap
+++ /dev/null
@@ -1,84 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Installations should match a snapshot when LOADING false 1`] = `
-
-
-
-
-
-
-
-
-
-
- }
- />
-
-`;
-
-exports[`Installations should match a snapshot when LOADING true 1`] = `
-
-
-
-
-
- }
- />
-
-`;
diff --git a/packages/marketplace/src/components/ui/app-installations/__tests__/installations.tsx b/packages/marketplace/src/components/ui/app-installations/__tests__/installations.tsx
deleted file mode 100644
index db6dac9bf8..0000000000
--- a/packages/marketplace/src/components/ui/app-installations/__tests__/installations.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-import * as React from 'react'
-import { shallow } from 'enzyme'
-import { Installations, InstallationsProps, mapDispatchToProps, mapStateToProps } from '../installations'
-import { installationsStub } from '@/sagas/__stubs__/installations'
-import { ReduxState } from '@/types/core'
-
-const props: InstallationsProps = {
- appId: '1',
- loading: false,
- installationsData: installationsStub,
- onUninstall: jest.fn(),
- fetchInstallationsApp: jest.fn(),
- afterClose: jest.fn(),
-}
-
-describe('Installations', () => {
- it('should match a snapshot when LOADING false', () => {
- expect(shallow()).toMatchSnapshot()
- })
-
- it('should match a snapshot when LOADING true', () => {
- const newProps = { ...props, loading: true }
- expect(shallow()).toMatchSnapshot()
- })
-
- describe('mapStateToProps', () => {
- it('should run correctly', () => {
- const mockState = {
- installations: {
- installationsAppData: installationsStub,
- loading: false,
- formState: 'PENDING',
- },
- } as ReduxState
- const expected = {
- installationsData: installationsStub,
- loading: false,
- }
- const result = mapStateToProps(mockState)
- expect(result).toEqual(expected)
- })
- })
-
- describe('mapDispatchToProps', () => {
- const dispatch = jest.fn()
- const fn = mapDispatchToProps(dispatch)
- it('fetchInstallationsApp', () => {
- fn.fetchInstallationsApp({ appId: ['1'] })()
- expect(dispatch).toBeCalled()
- })
- })
-})
diff --git a/packages/marketplace/src/components/ui/app-installations/app-installations-modal.tsx b/packages/marketplace/src/components/ui/app-installations/app-installations-modal.tsx
index 173d70ee4f..38c5a99aee 100644
--- a/packages/marketplace/src/components/ui/app-installations/app-installations-modal.tsx
+++ b/packages/marketplace/src/components/ui/app-installations/app-installations-modal.tsx
@@ -1,7 +1,6 @@
import * as React from 'react'
import { ModalProps, Modal } from '@reapit/elements'
import { InstallationModel } from '@reapit/foundations-ts-definitions'
-import Installations from './installations'
import ConfirmUninstall from './confirm-uninstall'
interface AppInstallationsModalInnerProps {
@@ -30,7 +29,6 @@ export const handleUninstall = (setUninstallApp: (app: InstallationModel) => voi
}
export const AppInstallationsModal: React.FC = ({
- appId,
appName,
visible,
afterClose,
@@ -41,19 +39,13 @@ export const AppInstallationsModal: React.FC = ({
return (
<>
- {uninstallApp ? (
+ {uninstallApp && (
- ) : (
-
)}
>
diff --git a/packages/marketplace/src/components/ui/app-installations/installations.tsx b/packages/marketplace/src/components/ui/app-installations/installations.tsx
deleted file mode 100644
index 079b2d04eb..0000000000
--- a/packages/marketplace/src/components/ui/app-installations/installations.tsx
+++ /dev/null
@@ -1,118 +0,0 @@
-import * as React from 'react'
-import dayjs from 'dayjs'
-import { connect } from 'react-redux'
-import { InstallationModel, PagedResultInstallationModel_ } from '@reapit/foundations-ts-definitions'
-import { Button, Table, ModalHeader, ModalBody, Pagination, Alert, Loader } from '@reapit/elements'
-import { InstallationParams, appInstallationsRequestData } from '@/actions/app-installations'
-import { ReduxState } from '@/types/core'
-
-export interface InstallationsInnerProps {
- appId: string
- onUninstall: (app: InstallationModel) => () => void
- afterClose?: () => void
-}
-
-export interface InstallationsMappedProps {
- installationsData: PagedResultInstallationModel_ | null
- loading: boolean
-}
-export interface InstallationsMappedActions {
- fetchInstallationsApp: (params: InstallationParams) => () => void
-}
-
-export const mapStateToProps = (state: ReduxState): InstallationsMappedProps => ({
- installationsData: state.installations.installationsAppData,
- loading: state.installations.loading,
-})
-
-export const mapDispatchToProps = (dispatch: any): InstallationsMappedActions => ({
- fetchInstallationsApp: (params: InstallationParams) => () => {
- dispatch(appInstallationsRequestData(params))
- },
-})
-
-export type InstallationsProps = InstallationsInnerProps & InstallationsMappedProps & InstallationsMappedActions
-
-export type CustomUninstallCell = React.FC<{
- onClick: () => void
-}>
-
-export const generateColumns = (
- onUninstall: (app: InstallationModel) => () => void,
- CustomUninstallCell?: CustomUninstallCell,
-) => () => {
- const UninstallCell = ({ row }) => {
- if (CustomUninstallCell) {
- return
- }
-
- return (
-
- )
- }
-
- return [
- {
- Header: 'Client',
- accessor: 'client',
- },
- {
- Header: 'Date Installed',
- accessor: d => dayjs(d.created).format('DD/MM/YYYY'),
- },
- {
- Header: 'Uninstall',
- Cell: UninstallCell,
- },
- ]
-}
-
-export const Installations: React.FC = ({
- appId,
- loading,
- installationsData,
- onUninstall,
- afterClose,
- fetchInstallationsApp,
-}) => {
- const [pageNumber, setPageNumber] = React.useState(1)
- const { data = [], pageSize, totalCount } = installationsData || {}
- const columns = React.useMemo(generateColumns(onUninstall), [installationsData])
-
- React.useEffect(fetchInstallationsApp({ appId: [appId], isInstalled: true, pageNumber, pageSize }), [appId])
-
- return (
- <>
- void} />
-
- {loading ? (
-
- ) : (
- <>
- {data.length > 0 ? (
- <>
-
-
- >
- ) : (
-
- )}
- >
- )}
- >
- }
- />
- >
- )
-}
-
-export default connect(mapStateToProps, mapDispatchToProps)(Installations)
|