From fc01c2ae4685ee2526f2c2275ad40b9dd053ee04 Mon Sep 17 00:00:00 2001 From: Vu Nguyen Date: Thu, 9 Jul 2020 14:15:04 +0700 Subject: [PATCH] feature: #1917 Remove client app detail files and update dev app detail file names --- .../client-app-button-group.test.tsx.snap | 21 - .../client-app-content.test.tsx.snap | 30 -- .../client-app-detail.test.tsx.snap | 488 ------------------ ...ent-app-install-confirmation.test.tsx.snap | 132 ----- ...t-app-uninstall-confirmation.test.tsx.snap | 160 ------ .../__snapshots__/client-aside.test.tsx.snap | 76 --- ...ient-contact-developer-modal.test.tsx.snap | 191 ------- .../client-web-component-config.test.tsx.snap | 62 --- .../client-app-button-group.test.tsx | 29 -- .../__tests__/client-app-content.test.tsx | 12 - .../__tests__/client-app-detail.test.tsx | 207 -------- .../client-app-install-confirmation.test.tsx | 107 ---- ...client-app-uninstall-confirmation.test.tsx | 131 ----- .../client/__tests__/client-aside.test.tsx | 20 - .../client-contact-developer-modal.test.tsx | 41 -- .../client-web-component-config.test.tsx | 31 -- .../app-detail/client/client-app-content.tsx | 24 - .../client/client-app-detail-button-group.tsx | 44 -- .../app-detail/client/client-app-detail.tsx | 201 -------- .../client-app-install-confirmation.tsx | 172 ------ .../client-app-uninstall-confirmation.tsx | 189 ------- .../pages/app-detail/client/client-aside.tsx | 58 --- .../client/client-contact-developer-modal.tsx | 100 ---- .../client/client-web-component-config.tsx | 49 -- .../pages/app-detail/client/index.ts | 3 - .../__tests__/developer-app-content.test.tsx | 2 +- .../__tests__/developer-app-detail.test.tsx | 2 +- .../developer-app-revision-modal.test.tsx | 2 +- .../__tests__/developer-aside.test.tsx | 2 +- .../__tests__/developer-manage-app.test.tsx | 4 +- ...eloper-app-content.tsx => app-content.tsx} | 0 ...eveloper-app-detail.tsx => app-detail.tsx} | 4 +- ...ision-modal.tsx => app-revision-modal.tsx} | 0 .../{developer-aside.tsx => aside.tsx} | 2 +- .../pages/app-detail/developer/index.ts | 2 +- ...eveloper-manage-app.tsx => manage-app.tsx} | 0 packages/developer-portal/src/core/router.tsx | 17 - 37 files changed, 10 insertions(+), 2605 deletions(-) delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-app-button-group.test.tsx.snap delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-app-content.test.tsx.snap delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-app-detail.test.tsx.snap delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-app-install-confirmation.test.tsx.snap delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-app-uninstall-confirmation.test.tsx.snap delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-aside.test.tsx.snap delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-contact-developer-modal.test.tsx.snap delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-web-component-config.test.tsx.snap delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-app-button-group.test.tsx delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-app-content.test.tsx delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-app-detail.test.tsx delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-app-install-confirmation.test.tsx delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-app-uninstall-confirmation.test.tsx delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-aside.test.tsx delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-contact-developer-modal.test.tsx delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-web-component-config.test.tsx delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/client-app-content.tsx delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/client-app-detail-button-group.tsx delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/client-app-detail.tsx delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/client-app-install-confirmation.tsx delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/client-app-uninstall-confirmation.tsx delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/client-aside.tsx delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/client-contact-developer-modal.tsx delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/client-web-component-config.tsx delete mode 100644 packages/developer-portal/src/components/pages/app-detail/client/index.ts rename packages/developer-portal/src/components/pages/app-detail/developer/{developer-app-content.tsx => app-content.tsx} (100%) rename packages/developer-portal/src/components/pages/app-detail/developer/{developer-app-detail.tsx => app-detail.tsx} (97%) rename packages/developer-portal/src/components/pages/app-detail/developer/{developer-app-revision-modal.tsx => app-revision-modal.tsx} (100%) rename packages/developer-portal/src/components/pages/app-detail/developer/{developer-aside.tsx => aside.tsx} (97%) rename packages/developer-portal/src/components/pages/app-detail/developer/{developer-manage-app.tsx => manage-app.tsx} (100%) diff --git a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-app-button-group.test.tsx.snap b/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-app-button-group.test.tsx.snap deleted file mode 100644 index 48dc51fdc2..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-app-button-group.test.tsx.snap +++ /dev/null @@ -1,21 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ClientAppDetailButtonGroup should match snapshot when both buttons are hidden 1`] = ` - - - -`; - -exports[`ClientAppDetailButtonGroup should match snapshot when both buttons are showing 1`] = ` - - - Uninstall App - - -`; diff --git a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-app-content.test.tsx.snap b/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-app-content.test.tsx.snap deleted file mode 100644 index 288783aeb1..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-app-content.test.tsx.snap +++ /dev/null @@ -1,30 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ClientAppContent ClientAppContent - should match snapshot 1`] = ` - - - - - - - -`; diff --git a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-app-detail.test.tsx.snap b/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-app-detail.test.tsx.snap deleted file mode 100644 index 7a9301a7c8..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-app-detail.test.tsx.snap +++ /dev/null @@ -1,488 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ClientAppDetail renderAppHeaderButtonGroup should match snapshot 1`] = ` -
- -
-`; - -exports[`ClientAppDetail renderAppHeaderButtonGroup should match snapshot 2`] = ` -
- -
-`; - -exports[`ClientAppDetail should match a snapshot 1`] = ` - - - - - -
- -
-
-
-
-
-
- - - - - Confirm - - - Cancel - - - } - title="Confirm undefined uninstallation" - visible={false} - /> - - - - - - Confirm - - - Cancel - - - } - title="Confirm undefined installation" - visible={false} - /> - -
- - - - - -`; - -exports[`ClientAppDetail should render loader when client.appDetail.data is an empty object 1`] = ` - - - - - -
- -
-
-
-
-
-
- - - - - Confirm - - - Cancel - - - } - title="Confirm undefined uninstallation" - visible={false} - /> - - - - - - Confirm - - - Cancel - - - } - title="Confirm undefined installation" - visible={false} - /> - -
- - - - - -`; - -exports[`ClientAppDetail should render loader when isLoadingAppDetail = true 1`] = ` - - - - - -
- -
-
-
-
-
-
- - - - - Confirm - - - Cancel - - - } - title="Confirm undefined uninstallation" - visible={false} - /> - - - - - - Confirm - - - Cancel - - - } - title="Confirm undefined installation" - visible={false} - /> - -
- - - - - -`; diff --git a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-app-install-confirmation.test.tsx.snap b/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-app-install-confirmation.test.tsx.snap deleted file mode 100644 index 7f4515a216..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-app-install-confirmation.test.tsx.snap +++ /dev/null @@ -1,132 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ClientAppInstallConfirmation should match a snapshot 1`] = ` - - - - - - - Confirm - - - Cancel - - - } - title="Confirm Peter's Properties installation" - visible={true} - /> - - - - -`; diff --git a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-app-uninstall-confirmation.test.tsx.snap b/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-app-uninstall-confirmation.test.tsx.snap deleted file mode 100644 index b7310a5fb1..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-app-uninstall-confirmation.test.tsx.snap +++ /dev/null @@ -1,160 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ClientAppUninstallConfirmation renderUninstallConfirmationModalFooter should match snapshot 1`] = ` -
- - Confirm - - - Cancel - -
-`; - -exports[`ClientAppUninstallConfirmation should match a snapshot 1`] = ` - - - - - - - Confirm - - - Cancel - - - } - title="Confirm Peter's Properties uninstallation" - visible={true} - /> - - - - - -`; diff --git a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-aside.test.tsx.snap b/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-aside.test.tsx.snap deleted file mode 100644 index d57896ae40..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-aside.test.tsx.snap +++ /dev/null @@ -1,76 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ClientAside ClientAside - should match snapshot 1`] = ` - - - - - - -`; diff --git a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-contact-developer-modal.test.tsx.snap b/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-contact-developer-modal.test.tsx.snap deleted file mode 100644 index 35d000d8cd..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-contact-developer-modal.test.tsx.snap +++ /dev/null @@ -1,191 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ContactDeveloperSection should match snapshot with gutter 1`] = ` - - - NEED HELP? - - - Close - - } - title="Contact Details" - visible={false} - > - - - - - Company name - - - -

- Reapit Ltd -

-
-
- - - - Telephone Number - - - -

- 0777 777 777 -

-
-
- - - - Support Email - - - -

- - reapit@reapit.com - -

-
-
- - - - Home Page - - - -

- - https://reapit.com - -

-
-
-
-
-
-`; - -exports[`ContactDeveloperSection should match snapshot without gutter 1`] = ` - - - NEED HELP? - - - Close - - } - title="Contact Details" - visible={false} - > - - - - - Company name - - - -

- Reapit Ltd -

-
-
- - - - Telephone Number - - - -

- 0777 777 777 -

-
-
- - - - Support Email - - - -

- - reapit@reapit.com - -

-
-
- - - - Home Page - - - -

- - https://reapit.com - -

-
-
-
-
-
-`; diff --git a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-web-component-config.test.tsx.snap b/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-web-component-config.test.tsx.snap deleted file mode 100644 index 5240a1c2cc..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/__snapshots__/client-web-component-config.test.tsx.snap +++ /dev/null @@ -1,62 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`WebComponentConfig Should match snapshot 1`] = ` - - - - - - - -`; diff --git a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-app-button-group.test.tsx b/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-app-button-group.test.tsx deleted file mode 100644 index a918c96541..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-app-button-group.test.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import React from 'react' -import { ClientAppDetailButtonGroup } from '../client-app-detail-button-group' -import { shallow } from 'enzyme' - -describe('ClientAppDetailButtonGroup', () => { - it('should match snapshot when both buttons are showing', () => { - const wrapper = shallow( - , - ) - expect(wrapper).toMatchSnapshot() - }) - - it('should match snapshot when both buttons are hidden', () => { - const wrapper = shallow( - , - ) - expect(wrapper).toMatchSnapshot() - }) -}) diff --git a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-app-content.test.tsx b/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-app-content.test.tsx deleted file mode 100644 index 4c58c8bd05..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-app-content.test.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import React from 'react' -import ClientAppContent from '../client-app-content' -import { appDetailDataStub } from '@/sagas/__stubs__/app-detail' -import { shallow } from 'enzyme' -import { AppDetailDataNotNull } from '@/reducers/client/app-detail' - -describe('ClientAppContent', () => { - it('ClientAppContent - should match snapshot', () => { - const wrapper = shallow() - expect(wrapper).toMatchSnapshot() - }) -}) diff --git a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-app-detail.test.tsx b/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-app-detail.test.tsx deleted file mode 100644 index 3d6b47f0e4..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-app-detail.test.tsx +++ /dev/null @@ -1,207 +0,0 @@ -import * as React from 'react' -import * as ReactRedux from 'react-redux' -import TestRenderer from 'react-test-renderer' -import { MemoryRouter } from 'react-router' -import { mount, shallow } from 'enzyme' -import configureStore from 'redux-mock-store' -import { getMockRouterProps } from '@/utils/mock-helper' -import ClientAppDetail, { - handleCloseInstallConfirmationModal, - handleInstallAppButtonClick, - renderAppHeaderButtonGroup, - handleCloseUnInstallConfirmationModal, - handleUnInstallAppButtonClick, - onBackToAppsButtonClick, - handleApplyAppDetailsFromLocalStorage, -} from '../client-app-detail' -import { Button } from '@reapit/elements' -import Routes from '@/constants/routes' -import appState from '@/reducers/__stubs__/app-state' -import { developerApplyAppDetails } from '@/actions/developer' -import { AppDetailData } from '@/reducers/client/app-detail' - -describe('ClientAppDetail', () => { - const { history } = getMockRouterProps({}) - let store - beforeEach(() => { - /* mocking store */ - const mockStore = configureStore() - store = mockStore({ - ...appState, - client: { - appDetail: { - data: {}, - loading: false, - }, - }, - }) - }) - - it('should render loader when isLoadingAppDetail = true', () => { - const mockStore = configureStore() - const customStore = mockStore({ - ...appState, - client: { - appDetail: { - isAppDetailLoading: true, - data: {}, - }, - }, - }) - - const wrapper = mount( - - - - - , - ) - - expect(wrapper).toMatchSnapshot() - const loader = wrapper.find('[data-test="client-app-detail-loader"]') - expect(loader.length).toBe(1) - }) - - it('should render loader when client.appDetail.data is an empty object', () => { - const mockStore = configureStore() - const customStore = mockStore({ - ...appState, - client: { - appDetail: { - data: {}, - loading: false, - }, - }, - }) - - const wrapper = mount( - - - - - , - ) - - expect(wrapper).toMatchSnapshot() - const loader = wrapper.find('[data-test="client-app-detail-loader"]') - expect(loader.length).toBe(1) - }) - - it('should match a snapshot', () => { - expect( - mount( - - - - - , - ), - ).toMatchSnapshot() - }) - - describe('renderAppHeaderButtonGroup', () => { - const mockAppId = 'test' - const mockInstalledOn = '2020-2-20' - - it('should match snapshot', () => { - const wrapperWithIsInstallBtnHiddenTrue = shallow( -
{renderAppHeaderButtonGroup(mockAppId, mockInstalledOn, jest.fn(), jest.fn(), true, 'CLIENT')}
, - ) - expect(wrapperWithIsInstallBtnHiddenTrue).toMatchSnapshot() - const wrapperWithIsInstallBtnHiddenFalse = shallow( -
{renderAppHeaderButtonGroup(mockAppId, mockInstalledOn, jest.fn(), jest.fn(), false, 'CLIENT')}
, - ) - expect(wrapperWithIsInstallBtnHiddenFalse).toMatchSnapshot() - }) - - it('should render header button group when appId is existed', () => { - const testRenderer = TestRenderer.create( -
{renderAppHeaderButtonGroup(mockAppId, mockInstalledOn, jest.fn(), jest.fn(), false, 'CLIENT')}
, - ) - const testInstance = testRenderer.root - expect(testInstance.children.length).toBe(1) - }) - - it('should render install app button if installedOn is empty', () => { - const testRenderer = TestRenderer.create( -
{renderAppHeaderButtonGroup(mockAppId, '', jest.fn(), jest.fn(), false, 'CLIENT')}
, - ) - const testInstance = testRenderer.root - expect(testInstance.findByType(Button).props.children).toBe('Install App') - }) - - it('should render uninstall app button if installedOn is existed', () => { - const testRenderer = TestRenderer.create( -
{renderAppHeaderButtonGroup(mockAppId, 'exist', jest.fn(), jest.fn(), false, 'CLIENT')}
, - ) - const testInstance = testRenderer.root - expect(testInstance.findByType(Button).props.children).toBe('Uninstall App') - }) - - it('should not render header button group when appId is empty', () => { - const testRenderer = TestRenderer.create( -
{renderAppHeaderButtonGroup('', mockInstalledOn, jest.fn(), jest.fn(), false, 'CLIENT')}
, - ) - const testInstance = testRenderer.getInstance - expect(testInstance).toHaveLength(0) - }) - }) - - describe('handleCloseInstallConfirmationModal', () => { - it('should run correctly', () => { - const mockFunction = jest.fn() - const fn = handleCloseInstallConfirmationModal(mockFunction) - fn() - expect(mockFunction).toBeCalledWith(false) - }) - }) - - describe('handleInstallAppButtonClick', () => { - it('should run correctly', () => { - const mockFunction = jest.fn() - const fn = handleInstallAppButtonClick(mockFunction) - fn() - expect(mockFunction).toBeCalledWith(true) - }) - }) - - describe('handleCloseUnInstallConfirmationModal', () => { - it('should run correctly', () => { - const mockFunction = jest.fn() - const fn = handleCloseUnInstallConfirmationModal(mockFunction) - fn() - expect(mockFunction).toBeCalledWith(false) - }) - }) - - describe('handleUnInstallAppButtonClick', () => { - it('should run correctly', () => { - const mockFunction = jest.fn() - const fn = handleUnInstallAppButtonClick(mockFunction) - fn() - expect(mockFunction).toBeCalledWith(true) - }) - }) - - describe('onBackToAppsButtonClick', () => { - it('should run correctly', () => { - const fn = onBackToAppsButtonClick(history) - fn() - expect(history.push).toBeCalledWith(Routes.CLIENT) - }) - }) - - describe('handleApplyAppDetailsFromLocalStorage', () => { - it('should run correctly', () => { - const dispatch = jest.fn() - const appId = 'appId' - const value = { id: 'appId' } as AppDetailData - const stringValue = JSON.stringify(value) - const spyLocalStorageGetItem = jest.spyOn(window.localStorage, 'getItem').mockImplementation(() => stringValue) - const fn = handleApplyAppDetailsFromLocalStorage(dispatch, 'DEVELOPER', appId) - fn() - expect(spyLocalStorageGetItem).toBeCalledWith('developer-preview-app') - expect(dispatch).toBeCalledWith(developerApplyAppDetails(value)) - }) - }) -}) diff --git a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-app-install-confirmation.test.tsx b/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-app-install-confirmation.test.tsx deleted file mode 100644 index 59ef36f468..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-app-install-confirmation.test.tsx +++ /dev/null @@ -1,107 +0,0 @@ -import * as React from 'react' -import * as ReactRedux from 'react-redux' -import { mount } from 'enzyme' -import configureStore from 'redux-mock-store' -import { appDetailDataStub } from '@/sagas/__stubs__/app-detail' -import { MemoryRouter } from 'react-router' -import ClientAppInstallConfirmation, { - ClientAppInstallConfirmationProps, - handleInstallButtonClick, - handleInstallAppSuccessCallback, - handleSuccessAlertButtonClick, - handleSuccessAlertMessageAfterClose, -} from '../client-app-install-confirmation' -import { appInstallationsRequestInstall } from '@/actions/app-installations' -import { clientFetchAppDetail } from '@/actions/client' -import routes from '@/constants/routes' -import Routes from '@/constants/routes' -import appState from '@/reducers/__stubs__/app-state' - -const mockProps: ClientAppInstallConfirmationProps = { - appDetailData: appDetailDataStub.data, - visible: true, - closeInstallConfirmationModal: jest.fn(), -} - -describe('ClientAppInstallConfirmation', () => { - let store - let spyDispatch - const appId = mockProps.appDetailData?.id || '' - const clientId = appState.auth.loginSession?.loginIdentity.clientId || '' - - beforeEach(() => { - /* mocking store */ - const mockStore = configureStore() - store = mockStore(appState) - /* mocking useDispatch on our mock store */ - spyDispatch = jest.spyOn(ReactRedux, 'useDispatch').mockImplementation(() => store.dispatch) - }) - - it('should match a snapshot', () => { - expect( - mount( - - - - - , - ), - ).toMatchSnapshot() - }) - - describe('handleInstallButtonClick', () => { - it('should run correctly', () => { - const mockFunction = jest.fn() - const fn = handleInstallButtonClick( - appId, - clientId, - spyDispatch, - mockFunction, - mockProps.closeInstallConfirmationModal, - false, - ) - fn() - expect(spyDispatch).toBeCalledWith( - appInstallationsRequestInstall({ - appId, - callback: expect.any(Function), - }), - ) - }) - }) - - describe('handleSuccessAlertMessageAfterClose', () => { - it('should run correctly', () => { - const mockFunction = jest.fn() - const fn = handleSuccessAlertMessageAfterClose(appId, clientId, mockFunction, spyDispatch) - fn() - expect(mockFunction).toBeCalledWith(false) - expect(spyDispatch).toBeCalledWith( - clientFetchAppDetail({ - id: appId, - clientId, - }), - ) - }) - }) - - describe('handleInstallAppSuccessCallback', () => { - it('should run correctly', () => { - const mockFunction = jest.fn() - const fn = handleInstallAppSuccessCallback(mockFunction, mockProps.closeInstallConfirmationModal, false) - fn() - - expect(mockProps.closeInstallConfirmationModal).toBeCalled() - expect(mockFunction).toBeCalledWith(true) - }) - }) - - describe('handleSuccessAlertButtonClick', () => { - const history = { - replace: jest.fn(), - } as any - const fn = handleSuccessAlertButtonClick(history) - fn() - expect(history.replace).toBeCalledWith(routes.CLIENT) - }) -}) diff --git a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-app-uninstall-confirmation.test.tsx b/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-app-uninstall-confirmation.test.tsx deleted file mode 100644 index 07dbad8d3d..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-app-uninstall-confirmation.test.tsx +++ /dev/null @@ -1,131 +0,0 @@ -import * as React from 'react' -import * as ReactRedux from 'react-redux' -import { mount, shallow } from 'enzyme' -import configureStore from 'redux-mock-store' -import { MemoryRouter } from 'react-router' -import { appDetailDataStub } from '@/sagas/__stubs__/app-detail' -import { appInstallationsRequestUninstall } from '@/actions/app-installations' -import { clientFetchAppDetail } from '@/actions/client' -import routes from '@/constants/routes' -import ClientAppUninstallConfirmation, { - ClientAppUninstallConfirmationProps, - onUninstallButtonClick, - handleUninstallAppSuccessCallback, - handleSuccessAlertButtonClick, - handleSuccessAlertMessageAfterClose, - renderUninstallConfirmationModalFooter, -} from '../client-app-uninstall-confirmation' -import Routes from '@/constants/routes' -import appState from '@/reducers/__stubs__/app-state' - -const mockProps: ClientAppUninstallConfirmationProps = { - appDetailData: appDetailDataStub.data, - visible: true, - closeUninstallConfirmationModal: jest.fn(), -} - -describe('ClientAppUninstallConfirmation', () => { - let store - let spyDispatch - const appId = mockProps.appDetailData?.id || '' - const installationId = mockProps.appDetailData?.installationId || '' - const clientId = appState.auth.loginSession?.loginIdentity.clientId || '' - - beforeEach(() => { - /* mocking store */ - const mockStore = configureStore() - store = mockStore(appState) - /* mocking useDispatch on our mock store */ - spyDispatch = jest.spyOn(ReactRedux, 'useDispatch').mockImplementation(() => store.dispatch) - }) - - it('should match a snapshot', () => { - expect( - mount( - - - - - , - ), - ).toMatchSnapshot() - }) - - describe('onUninstallButtonClick', () => { - it('should run correctly', () => { - const mockFunction = jest.fn() - const fn = onUninstallButtonClick( - appId, - clientId, - installationId, - spyDispatch, - mockFunction, - mockProps.closeUninstallConfirmationModal, - false, - ) - fn() - expect(spyDispatch).toBeCalledWith( - appInstallationsRequestUninstall({ - appId, - installationId, - terminatedReason: 'User uninstall', - callback: expect.any(Function), - }), - ) - }) - }) - - describe('handleUninstallAppSuccessCallback', () => { - it('should run correctly', () => { - const mockFunction = jest.fn() - const fn = handleUninstallAppSuccessCallback(mockFunction, mockProps.closeUninstallConfirmationModal, false) - fn() - expect(mockProps.closeUninstallConfirmationModal).toBeCalled() - expect(mockFunction).toBeCalledWith(true) - }) - }) - - describe('handleSuccessAlertButtonClick', () => { - const history = { - replace: jest.fn(), - } as any - const fn = handleSuccessAlertButtonClick(history) - fn() - expect(history.replace).toBeCalledWith(routes.CLIENT) - }) - - describe('handleSuccessAlertMessageAfterClose', () => { - it('should match snapshot', () => { - const mockFunction = jest.fn() - const fn = handleSuccessAlertMessageAfterClose(appId, clientId, mockFunction, spyDispatch) - fn() - expect(spyDispatch).toBeCalledWith( - clientFetchAppDetail({ - id: appId, - clientId, - }), - ) - expect(mockFunction).toBeCalledWith(false) - }) - }) - - describe('renderUninstallConfirmationModalFooter', () => { - it('should match snapshot', () => { - const wrapper = shallow( -
- {renderUninstallConfirmationModalFooter( - false, - appId, - clientId, - installationId, - spyDispatch, - jest.fn(), - jest.fn(), - false, - )} -
, - ) - expect(wrapper).toMatchSnapshot() - }) - }) -}) diff --git a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-aside.test.tsx b/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-aside.test.tsx deleted file mode 100644 index f888ff017d..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-aside.test.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import React from 'react' -import { ClientAside } from '../client-aside' -import { shallow } from 'enzyme' -import { integrationTypesStub } from '@/sagas/__stubs__/integration-types' -import { appDetailDataStub } from '@/sagas/__stubs__/app-detail' -import { AppDetailDataNotNull } from '@/reducers/client/app-detail' -import { DesktopIntegrationTypeModel } from '@/actions/app-integration-types' - -describe('ClientAside', () => { - test('ClientAside - should match snapshot', () => { - expect( - shallow( - , - ), - ).toMatchSnapshot() - }) -}) diff --git a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-contact-developer-modal.test.tsx b/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-contact-developer-modal.test.tsx deleted file mode 100644 index 08cae4c123..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-contact-developer-modal.test.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import React from 'react' -import { - ContactDeveloperSection, - ContactDeveloperSectionType, - openContactModal, - closeContactModal, -} from '../client-contact-developer-modal' -import { shallow } from 'enzyme' - -const props: ContactDeveloperSectionType = { - contact: { - developer: 'Reapit Ltd', - telephone: '0777 777 777', - supportEmail: 'reapit@reapit.com', - homePage: 'https://reapit.com', - }, -} - -describe('ContactDeveloperSection', () => { - test('should match snapshot without gutter', () => { - expect(shallow()).toMatchSnapshot() - }) - - test('should match snapshot with gutter', () => { - expect(shallow()).toMatchSnapshot() - }) - - test('handle openContactModal', () => { - const setVisible = jest.fn() - openContactModal(setVisible)() - expect(setVisible).toBeCalled() - expect(setVisible).toBeCalledWith(true) - }) - - test('handle closeContactModal', () => { - const setVisible = jest.fn() - closeContactModal(setVisible)() - expect(setVisible).toBeCalled() - expect(setVisible).toBeCalledWith(false) - }) -}) diff --git a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-web-component-config.test.tsx b/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-web-component-config.test.tsx deleted file mode 100644 index 2046a70710..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/__tests__/client-web-component-config.test.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import * as React from 'react' -import { Provider } from 'react-redux' -import appState from '@/reducers/__stubs__/app-state' -import configureStore from 'redux-mock-store' -import { mount } from 'enzyme' -import { WebComponentConfig } from '../client-web-component-config' -import Routes from '@/constants/routes' -import { MemoryRouter } from 'react-router' - -describe('WebComponentConfig', () => { - const extendStore = { - ...appState, - client: { - webComponent: { isShowModal: true }, - }, - } - const mockStore = configureStore() - const store = mockStore(extendStore) - - it('Should match snapshot', () => { - expect( - mount( - - - - - , - ), - ).toMatchSnapshot() - }) -}) diff --git a/packages/developer-portal/src/components/pages/app-detail/client/client-app-content.tsx b/packages/developer-portal/src/components/pages/app-detail/client/client-app-content.tsx deleted file mode 100644 index d08b121208..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/client-app-content.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import * as React from 'react' -import { Section } from '@reapit/elements' -import { AppDetailDataNotNull } from '@/reducers/client/app-detail' -import { SummarySection, AdditionalImagesSection, PermissionsSection, DescriptionSection } from '../common/ui-sections' - -export type AppContentProps = { - appDetailData: AppDetailDataNotNull -} - -const AppContent: React.FC = ({ appDetailData }) => { - const { summary = '', description = '', scopes = [], media = [] } = appDetailData - - return ( -
- - - - - -
- ) -} - -export default AppContent diff --git a/packages/developer-portal/src/components/pages/app-detail/client/client-app-detail-button-group.tsx b/packages/developer-portal/src/components/pages/app-detail/client/client-app-detail-button-group.tsx deleted file mode 100644 index b3065b9494..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/client-app-detail-button-group.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import * as React from 'react' -import { Button } from '@reapit/elements' - -interface ClientAppDetailButtonGroupProps { - installedOn: string - onInstallConfirmationModal: () => void - onUninstallConfirmationModal: () => void - isInstallBtnHidden: boolean -} - -export const ClientAppDetailButtonGroup: React.FC = ({ - installedOn, - onInstallConfirmationModal, - onUninstallConfirmationModal, - isInstallBtnHidden, -}) => { - return ( - <> - {installedOn ? ( - - ) : ( - isInstallBtnHidden || ( - - ) - )} - - ) -} diff --git a/packages/developer-portal/src/components/pages/app-detail/client/client-app-detail.tsx b/packages/developer-portal/src/components/pages/app-detail/client/client-app-detail.tsx deleted file mode 100644 index 4c11159d13..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/client-app-detail.tsx +++ /dev/null @@ -1,201 +0,0 @@ -import * as React from 'react' -import { History } from 'history' -import { useHistory } from 'react-router' -import ClientAppUninstallConfirmation from '@/components/pages/app-detail/client/client-app-uninstall-confirmation' -import { DesktopIntegrationTypeModel } from '@/actions/app-integration-types' -import { AppDetailDataNotNull } from '@/reducers/client/app-detail' -import { selectIntegrationTypes } from '@/selector/integration-types' -import { useSelector, useDispatch } from 'react-redux' -import { selectAppDetailData, selectAppDetailLoading, selectAppDetailError } from '@/selector/client-app-detail' -import { selectLoginType, selectIsAdmin } from '@/selector/auth' -import { canGoBack } from '@/utils/router-helper' -import AppContent from './client-app-content' -import { Loader, Alert, GridItem, Grid, Section } from '@reapit/elements' -import styles from '@/styles/blocks/standalone-app-detail.scss?mod' -import ClientAppInstallConfirmation from '@/components/pages/app-detail/client/client-app-install-confirmation' -import { ClientAside } from './client-aside' -import { clientFetchAppDetail, clientFetchAppDetailFailed } from '@/actions/client' -import { developerApplyAppDetails } from '@/actions/developer' -import { useParams } from 'react-router' -import { Dispatch } from 'redux' -import { getDesktopIntegrationTypes } from '@/utils/get-desktop-integration-types' -import Routes from '@/constants/routes' -import { LoginType } from '@reapit/cognito-auth' -import useReactResponsive from '@/components/hooks/use-react-responsive' -import AppHeader from '../common/ui-app-header' -import { BackToAppsSection } from '../common/ui-sections' -import { ClientAppDetailButtonGroup } from './client-app-detail-button-group' -import { selectDeveloperEditionId } from '@/selector/client' - -export type ClientAppDetailProps = {} - -export const handleCloseInstallConfirmationModal = ( - setIsVisibleInstallConfirmation: (isVisible: boolean) => void, -) => () => { - setIsVisibleInstallConfirmation(false) -} - -export const handleInstallAppButtonClick = (setIsVisibleInstallConfirmation: (isVisible: boolean) => void) => () => { - setIsVisibleInstallConfirmation(true) -} - -export const handleCloseUnInstallConfirmationModal = ( - setIsVisibleUnInstallConfirmation: (isVisible: boolean) => void, -) => () => { - setIsVisibleUnInstallConfirmation(false) -} - -export const handleUnInstallAppButtonClick = ( - setIsVisibleUnInstallConfirmation: (isVisible: boolean) => void, -) => () => { - setIsVisibleUnInstallConfirmation(true) -} - -export const onBackToAppsButtonClick = (history: History) => () => { - if (canGoBack(history)) { - history.goBack() - } - history.push(Routes.CLIENT) -} - -export const handleApplyAppDetailsFromLocalStorage = ( - dispatch: Dispatch, - loginType: LoginType, - appId?: string, -) => () => { - if (loginType !== 'DEVELOPER' || !appId) return - - if (appId === 'submit-app') { - try { - const appDataString = localStorage.getItem('developer-preview-app') - if (!appDataString) throw 'No preview data' - const appData = JSON.parse(appDataString) - if (appData.id) throw 'No preview data' - dispatch(developerApplyAppDetails(appData)) - } catch (err) { - dispatch(clientFetchAppDetailFailed(err)) - } - return - } - - try { - const appDataString = localStorage.getItem('developer-preview-app') - if (!appDataString) throw 'No preview data' - const appData = JSON.parse(appDataString) - if (appData.id !== appId) throw 'Preview data not match appId' - - dispatch(developerApplyAppDetails(appData)) - } catch (err) { - dispatch(clientFetchAppDetail({ id: appId })) - } -} - -export const renderAppHeaderButtonGroup = ( - id: string, - installedOn: string, - onInstallConfirmationModal: () => void, - onUninstallConfirmationModal: () => void, - isInstallBtnHidden: boolean, - loginType: LoginType, -) => { - return id && loginType !== 'DEVELOPER' ? ( - - ) : null -} - -const ClientAppDetail: React.FC = () => { - const dispatch = useDispatch() - const history = useHistory() - const { appId } = useParams() - - const [isVisibleInstallConfirmation, setIsVisibleInstallConfirmation] = React.useState(false) - const [isVisibleUninstallConfirmation, setIsVisibleUninstallConfirmation] = React.useState(false) - const closeInstallConfirmationModal = React.useCallback( - handleCloseInstallConfirmationModal(setIsVisibleInstallConfirmation), - [], - ) - - const onInstallConfirmationModal = React.useCallback(handleInstallAppButtonClick(setIsVisibleInstallConfirmation), []) - const onUninstsallConfirmationModal = React.useCallback( - handleUnInstallAppButtonClick(setIsVisibleUninstallConfirmation), - [], - ) - const closeUninstallConfirmationModal = React.useCallback( - handleCloseInstallConfirmationModal(setIsVisibleUninstallConfirmation), - [], - ) - - const desktopIntegrationTypes = useSelector(selectIntegrationTypes) as DesktopIntegrationTypeModel[] - const appDetailData = useSelector(selectAppDetailData) as AppDetailDataNotNull - const userDesktopIntegrationTypes = getDesktopIntegrationTypes( - appDetailData.desktopIntegrationTypeIds || [], - desktopIntegrationTypes, - ) - const { isMobile } = useReactResponsive() - - const isLoadingAppDetail = useSelector(selectAppDetailLoading) - const loginType = useSelector(selectLoginType) - const isDesktopAdmin = useSelector(selectIsAdmin) - const isDeveloperEdition = Boolean(useSelector(selectDeveloperEditionId)) - const error = useSelector(selectAppDetailError) - - const isAdmin = isDesktopAdmin || isDeveloperEdition - const isInstallBtnHidden = loginType === 'CLIENT' && !isAdmin - // selector selectAppDetailData return {} if not data - const unfetched = Object.keys(appDetailData).length === 0 - const { id = '', installedOn = '' } = appDetailData - - React.useEffect(handleApplyAppDetailsFromLocalStorage(dispatch, loginType, appId), [dispatch]) - if (error) return - - return ( - - {isLoadingAppDetail || unfetched ? ( - - ) : ( - <> - - - - -
- - - {!isMobile && loginType !== 'DEVELOPER' && ( - - )} -
-
- - )} - - - -
- ) -} - -export default ClientAppDetail diff --git a/packages/developer-portal/src/components/pages/app-detail/client/client-app-install-confirmation.tsx b/packages/developer-portal/src/components/pages/app-detail/client/client-app-install-confirmation.tsx deleted file mode 100644 index 32156c1b8f..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/client-app-install-confirmation.tsx +++ /dev/null @@ -1,172 +0,0 @@ -import * as React from 'react' -import { useHistory } from 'react-router' -import { History } from 'history' -import { useDispatch, useSelector } from 'react-redux' -import { AppDetailModel } from '@reapit/foundations-ts-definitions' -import appPermissionContentStyles from '@/styles/pages/app-permission-content.scss?mod' -import { Button, Modal, GridFourCol, GridFourColItem, Content } from '@reapit/elements' -import { appInstallationsRequestInstall } from '@/actions/app-installations' -import { clientFetchAppDetail } from '@/actions/client' -import { Dispatch } from 'redux' -import CallToAction from '../../../ui/call-to-action' -import { selectClientId } from '@/selector/client' -import routes from '@/constants/routes' -import { selectInstallationFormState } from '@/selector/installations' -import { selectIsDesktopMode } from '@/selector/auth' -import { DESKTOP_REFRESH_URL } from '@/constants/desktop-urls' -import { canGoBack } from '@/utils/router-helper' - -export type ClientAppInstallConfirmationProps = { - appDetailData?: AppDetailModel - visible: boolean - closeInstallConfirmationModal: () => void -} - -export const handleInstallAppSuccessCallback = ( - setIsSuccessAlertVisible: (isVisible: boolean) => void, - closeInstallConfirmationModal: () => void, - isDesktopMode: boolean, -) => { - return () => { - if (isDesktopMode) { - window.location.href = DESKTOP_REFRESH_URL - } - closeInstallConfirmationModal() - setIsSuccessAlertVisible(true) - } -} - -export const handleInstallButtonClick = ( - appId: string, - clientId: string, - dispatch: Dispatch, - setIsSuccessAlertVisible: (isVisible: boolean) => void, - closeInstallConfirmationModal: () => void, - isDesktopMode: boolean, -) => () => { - dispatch( - appInstallationsRequestInstall({ - appId, - callback: handleInstallAppSuccessCallback(setIsSuccessAlertVisible, closeInstallConfirmationModal, isDesktopMode), - }), - ) -} - -export const handleSuccessAlertButtonClick = (history: History) => () => { - if (canGoBack(history)) { - history.goBack() - } - history.replace(routes.CLIENT) -} - -export const handleSuccessAlertMessageAfterClose = ( - appId: string, - clientId: string, - setIsSuccessAlertVisible: (isVisible: boolean) => void, - dispatch: Dispatch, -) => { - return () => { - dispatch( - clientFetchAppDetail({ - id: appId, - clientId, - }), - ) - setIsSuccessAlertVisible(false) - } -} - -const ClientAppInstallConfirmation: React.FC = ({ - appDetailData, - visible, - closeInstallConfirmationModal, -}) => { - const history = useHistory() - const [isSuccessAlertVisible, setIsSuccessAlertVisible] = React.useState(false) - const clientId = useSelector(selectClientId) - const installationFormState = useSelector(selectInstallationFormState) - const isDesktopMode = useSelector(selectIsDesktopMode) - const isSubmitting = installationFormState === 'SUBMITTING' - - const { name, id = '', scopes = [] } = appDetailData || {} - - const dispatch = useDispatch() - const onSuccessAlertButtonClick = React.useCallback(handleSuccessAlertButtonClick(history), [history]) - - return ( - <> - - - - - } - > - <> - {scopes.length ? ( - -

This action will install the app for ALL platform users.

-

{name} requires the permissions below. By installing you are granting permission to your data.

- - {scopes.map(scope => ( - {scope?.description ?? ''} - ))} - -
- ) : ( -

This action will install the app for ALL platform users.

- )} - -
- {isSuccessAlertVisible && ( - ( - - {name} has been successfully installed - - )} - /> - )} - - ) -} - -export default ClientAppInstallConfirmation diff --git a/packages/developer-portal/src/components/pages/app-detail/client/client-app-uninstall-confirmation.tsx b/packages/developer-portal/src/components/pages/app-detail/client/client-app-uninstall-confirmation.tsx deleted file mode 100644 index aed68b8ede..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/client-app-uninstall-confirmation.tsx +++ /dev/null @@ -1,189 +0,0 @@ -import * as React from 'react' -import { useHistory } from 'react-router' -import { History } from 'history' -import { Dispatch } from 'redux' -import { useDispatch, useSelector } from 'react-redux' -import { AppDetailModel } from '@reapit/foundations-ts-definitions' -import appPermissionContentStyles from '@/styles/pages/app-permission-content.scss?mod' -import { Button, Modal } from '@reapit/elements' -import { clientFetchAppDetail } from '@/actions/client' -import { appInstallationsRequestUninstall } from '@/actions/app-installations' -import CallToAction from '../../../ui/call-to-action' -import { selectClientId } from '@/selector/client' -import { selectInstallationFormState } from '@/selector/installations' -import routes from '@/constants/routes' -import { selectIsDesktopMode } from '@/selector/auth' -import { DESKTOP_REFRESH_URL } from '@/constants/desktop-urls' -import { canGoBack } from '@/utils/router-helper' - -export type ClientAppUninstallConfirmationProps = { - appDetailData?: AppDetailModel - visible: boolean - closeUninstallConfirmationModal: () => void -} - -export const handleUninstallAppSuccessCallback = ( - setIsSuccessAlertVisible: (isVisible: boolean) => void, - closeUninstallConfirmationModal: () => void, - isDesktopMode: boolean, -) => { - return () => { - if (isDesktopMode) { - window.location.href = DESKTOP_REFRESH_URL - } - setIsSuccessAlertVisible(true) - closeUninstallConfirmationModal() - } -} - -export const onUninstallButtonClick = ( - appId: string, - clientId: string, - installationId: string, - dispatch: Dispatch, - setIsSuccessAlertVisible: (isVisible: boolean) => void, - closeUninstallConfirmationModal: () => void, - isDesktopMode: boolean, -) => { - return () => { - dispatch( - appInstallationsRequestUninstall({ - appId, - installationId, - terminatedReason: 'User uninstall', - callback: handleUninstallAppSuccessCallback( - setIsSuccessAlertVisible, - closeUninstallConfirmationModal, - isDesktopMode, - ), - }), - ) - } -} - -export const handleSuccessAlertButtonClick = (history: History) => { - return () => { - if (canGoBack(history)) { - history.goBack() - } - history.replace(routes.CLIENT) - } -} - -export const handleSuccessAlertMessageAfterClose = ( - appId: string, - clientId: string, - setIsSuccessAlertVisible: (isVisible: boolean) => void, - dispatch: Dispatch, -) => { - return () => { - dispatch( - clientFetchAppDetail({ - id: appId, - clientId, - }), - ) - - setIsSuccessAlertVisible(false) - } -} - -export const renderUninstallConfirmationModalFooter = ( - isSubmitting: boolean, - id: string, - clientId: string, - installationId: string, - dispatch: Dispatch, - setIsSuccessAlertVisible: (isVisible: boolean) => void, - closeUninstallConfirmationModal: () => void, - isDesktopMode: boolean, -) => { - return ( - <> - - - - ) -} - -const ClientAppUninstallConfirmation: React.FC = ({ - appDetailData, - visible, - closeUninstallConfirmationModal, -}) => { - const [isSuccessAlertVisible, setIsSuccessAlertVisible] = React.useState(false) - const history = useHistory() - const clientId = useSelector(selectClientId) - const installationFormState = useSelector(selectInstallationFormState) - const isDesktopMode = useSelector(selectIsDesktopMode) - const isSubmitting = installationFormState === 'SUBMITTING' - const { name, id = '', installationId = '' } = appDetailData || {} - const dispatch = useDispatch() - const onSuccessAlertButtonClick = React.useCallback(handleSuccessAlertButtonClick(history), [history]) - - return ( - <> - - <>Are you sure you wish to uninstall {name}? This action will uninstall the app for ALL platform users - - ( - - {name} has been successfully uninstalled - - )} - /> - - ) -} - -export default ClientAppUninstallConfirmation diff --git a/packages/developer-portal/src/components/pages/app-detail/client/client-aside.tsx b/packages/developer-portal/src/components/pages/app-detail/client/client-aside.tsx deleted file mode 100644 index aa2fc9295a..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/client-aside.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import React from 'react' -import { DesktopIntegrationTypeModel } from '@reapit/foundations-ts-definitions' -import { AppDetailDataNotNull } from '@/reducers/client/app-detail' -import { FlexContainerBasic } from '@reapit/elements' -import { ContactDeveloperSection } from './client-contact-developer-modal' -import useReactResponsive from '@/components/hooks/use-react-responsive' -import { History } from 'history' -import routes from '@/constants/routes' -// Commenting out for now until we have the API -import { - DeveloperSection /*, DeveloperAboutSection */, - CategorySection, - DesktopIntegrationSection, - DirectApiSection, - BackToAppsSection, -} from '../common/ui-sections' -import { useHistory } from 'react-router' -import { WebComponentConfig } from './client-web-component-config' - -interface AsideProps { - appDetailData: AppDetailDataNotNull - desktopIntegrationTypes: DesktopIntegrationTypeModel[] -} - -export const onBackToAppsButtonClick = (history: History) => { - return () => { - history.push(routes.APPS) - } -} - -export const ClientAside: React.FC = ({ desktopIntegrationTypes, appDetailData }) => { - const { category, developer, telephone, supportEmail, homePage, isDirectApi, isWebComponent } = appDetailData - const { isMobile } = useReactResponsive() - const history = useHistory() - - return ( - - {developer && } - {/** Placeholder for now until we have the API - - */} - - - - - {isWebComponent && } - - {isMobile && } - - ) -} diff --git a/packages/developer-portal/src/components/pages/app-detail/client/client-contact-developer-modal.tsx b/packages/developer-portal/src/components/pages/app-detail/client/client-contact-developer-modal.tsx deleted file mode 100644 index 263effa35b..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/client-contact-developer-modal.tsx +++ /dev/null @@ -1,100 +0,0 @@ -import React from 'react' -import { Button, Grid, GridItem, SubTitleH6, Modal, Content } from '@reapit/elements' -import linkStyles from '@/styles/elements/link.scss?mod' - -export type ContactDeveloperSectionType = { - contact: { - developer?: string - telephone?: string - supportEmail?: string - homePage?: string - } - hasGutter?: boolean -} - -export const openContactModal = (setVisible: React.Dispatch>) => () => { - setVisible(true) -} - -export const closeContactModal = (setVisible: React.Dispatch>) => () => { - setVisible(false) -} - -export const ContactDeveloperSection = ({ - contact: { developer, telephone, supportEmail, homePage }, -}: ContactDeveloperSectionType) => { - const [visible, setVisible] = React.useState(false) - - return ( - <> - - - - Close - - } - > - - - - Company name - - -

{developer}

-
-
- - - Telephone Number - - -

{telephone}

-
-
- - - Support Email - - -

- - {supportEmail} - -

-
-
- - - Home Page - - -

- - {homePage} - -

-
-
-
-
- - ) -} diff --git a/packages/developer-portal/src/components/pages/app-detail/client/client-web-component-config.tsx b/packages/developer-portal/src/components/pages/app-detail/client/client-web-component-config.tsx deleted file mode 100644 index 29b47ab3b7..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/client-web-component-config.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import React, { useEffect, useState } from 'react' -import { Button } from '@reapit/elements' -import { useDispatch, useSelector } from 'react-redux' -import { selectWebComponentData } from '@/selector/client' -import { clientFetchWebComponentConfig } from '@/actions/client' -import { Dispatch } from 'redux' -import WebComponentModal from '@/components/ui/web-component-config-modal' -import { AppDetailSection } from '../common/ui-helpers' -import { selectClientId } from '@/selector/auth' -import { useParams } from 'react-router-dom' - -export const toggleWebComponentModal = (setIsOpenConfigModal, isOpen) => () => { - setIsOpenConfigModal(isOpen) -} - -export const handleFetchWebComponentConfig = ( - dispatch: Dispatch, - customerId?: string, - applicationId?: string, -) => () => { - customerId && applicationId && dispatch(clientFetchWebComponentConfig({ customerId, applicationId })) -} - -export const WebComponentConfig: React.FC = () => { - const dispatch = useDispatch() - const [isOpenConfigModal, setIsOpenConfigModal] = useState(false) - - const clientId = useSelector(selectClientId) || '' - const webComponentData = useSelector(selectWebComponentData) - const { appid: applicationId } = useParams() - - const handleToggleWebComponentModal = toggleWebComponentModal(setIsOpenConfigModal, true) - const handleCloseWebComponentModal = toggleWebComponentModal(setIsOpenConfigModal, false) - - useEffect(handleFetchWebComponentConfig(dispatch, clientId, applicationId), []) - - if (!webComponentData) return null - - return ( - - - {isOpenConfigModal && ( - - )} - - ) -} diff --git a/packages/developer-portal/src/components/pages/app-detail/client/index.ts b/packages/developer-portal/src/components/pages/app-detail/client/index.ts deleted file mode 100644 index 6f420e3e73..0000000000 --- a/packages/developer-portal/src/components/pages/app-detail/client/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import ClientAppDetail from './client-app-detail' - -export default ClientAppDetail diff --git a/packages/developer-portal/src/components/pages/app-detail/developer/__tests__/developer-app-content.test.tsx b/packages/developer-portal/src/components/pages/app-detail/developer/__tests__/developer-app-content.test.tsx index 948927148d..838c60027e 100644 --- a/packages/developer-portal/src/components/pages/app-detail/developer/__tests__/developer-app-content.test.tsx +++ b/packages/developer-portal/src/components/pages/app-detail/developer/__tests__/developer-app-content.test.tsx @@ -8,7 +8,7 @@ import AppContent, { handleUninstallSuccess, handleOpenAppPreview, generateInstallationTableColumns, -} from '../developer-app-content' +} from '../app-content' import { Provider } from 'react-redux' import { ReduxState } from '@/types/core' import configureStore from 'redux-mock-store' diff --git a/packages/developer-portal/src/components/pages/app-detail/developer/__tests__/developer-app-detail.test.tsx b/packages/developer-portal/src/components/pages/app-detail/developer/__tests__/developer-app-detail.test.tsx index e224084f50..69c512b481 100644 --- a/packages/developer-portal/src/components/pages/app-detail/developer/__tests__/developer-app-detail.test.tsx +++ b/packages/developer-portal/src/components/pages/app-detail/developer/__tests__/developer-app-detail.test.tsx @@ -11,7 +11,7 @@ import DeveloperAppDetail, { closeAppRevisionComparisonModal, closeDeleteAppModal, onBackToAppsButtonClick, -} from '../developer-app-detail' +} from '../app-detail' import routes from '@/constants/routes' import Routes from '@/constants/routes' import appState from '@/reducers/__stubs__/app-state' diff --git a/packages/developer-portal/src/components/pages/app-detail/developer/__tests__/developer-app-revision-modal.test.tsx b/packages/developer-portal/src/components/pages/app-detail/developer/__tests__/developer-app-revision-modal.test.tsx index 6b927c764f..8367c5ae80 100644 --- a/packages/developer-portal/src/components/pages/app-detail/developer/__tests__/developer-app-revision-modal.test.tsx +++ b/packages/developer-portal/src/components/pages/app-detail/developer/__tests__/developer-app-revision-modal.test.tsx @@ -9,7 +9,7 @@ import AppRevisionModal, { handleUseEffectToFetchAppRevisions, handleUseEffectToFetchAppRevisionDetail, handleCancelPendingRevisionsSuccessCallback, -} from '../developer-app-revision-modal' +} from '../app-revision-modal' import { revisionsRequestData } from '@/actions/revisions' import { revisionDetailRequestData } from '@/actions/revision-detail' import { developerFetchAppDetail } from '@/actions/developer' diff --git a/packages/developer-portal/src/components/pages/app-detail/developer/__tests__/developer-aside.test.tsx b/packages/developer-portal/src/components/pages/app-detail/developer/__tests__/developer-aside.test.tsx index 1f694d62eb..51ae31dcd1 100644 --- a/packages/developer-portal/src/components/pages/app-detail/developer/__tests__/developer-aside.test.tsx +++ b/packages/developer-portal/src/components/pages/app-detail/developer/__tests__/developer-aside.test.tsx @@ -1,6 +1,6 @@ import React from 'react' import { DeveloperAppDetailState } from '@/reducers/developer' -import { DeveloperAside, onBackToAppsButtonClick } from '../developer-aside' +import { DeveloperAside, onBackToAppsButtonClick } from '../aside' import { shallow } from 'enzyme' import { integrationTypesStub } from '@/sagas/__stubs__/integration-types' import { appDetailDataStub } from '@/sagas/__stubs__/app-detail' diff --git a/packages/developer-portal/src/components/pages/app-detail/developer/__tests__/developer-manage-app.test.tsx b/packages/developer-portal/src/components/pages/app-detail/developer/__tests__/developer-manage-app.test.tsx index 7e55275b19..8e3635d39a 100644 --- a/packages/developer-portal/src/components/pages/app-detail/developer/__tests__/developer-manage-app.test.tsx +++ b/packages/developer-portal/src/components/pages/app-detail/developer/__tests__/developer-manage-app.test.tsx @@ -7,7 +7,7 @@ import { MemoryRouter } from 'react-router' import { getMockRouterProps } from '@/utils/mock-helper' import configureStore from 'redux-mock-store' import Routes from '@/constants/routes' -import DeveloperManageApp from '../developer-manage-app' +import DeveloperManageApp from '../manage-app' import { appDetailDataStub } from '@/sagas/__stubs__/app-detail' import { DeveloperAppDetailState } from '@/reducers/developer' import { @@ -17,7 +17,7 @@ import { onPendingRevisionButtonClick, onEditDetailButtonClick, onDeleteAppButtonClick, -} from '../developer-manage-app' +} from '../manage-app' const mockState = { ...appState, diff --git a/packages/developer-portal/src/components/pages/app-detail/developer/developer-app-content.tsx b/packages/developer-portal/src/components/pages/app-detail/developer/app-content.tsx similarity index 100% rename from packages/developer-portal/src/components/pages/app-detail/developer/developer-app-content.tsx rename to packages/developer-portal/src/components/pages/app-detail/developer/app-content.tsx diff --git a/packages/developer-portal/src/components/pages/app-detail/developer/developer-app-detail.tsx b/packages/developer-portal/src/components/pages/app-detail/developer/app-detail.tsx similarity index 97% rename from packages/developer-portal/src/components/pages/app-detail/developer/developer-app-detail.tsx rename to packages/developer-portal/src/components/pages/app-detail/developer/app-detail.tsx index d8472650f6..6a77e044a0 100644 --- a/packages/developer-portal/src/components/pages/app-detail/developer/developer-app-detail.tsx +++ b/packages/developer-portal/src/components/pages/app-detail/developer/app-detail.tsx @@ -4,7 +4,7 @@ import { selectIntegrationTypes } from '@/selector/integration-types' import { DesktopIntegrationTypeModel } from '@/actions/app-integration-types' import { selectInstallationAppData } from '@/selector/installations' import { PagedResultInstallationModel_ } from '@reapit/foundations-ts-definitions' -import { DeveloperAside } from './developer-aside' +import { DeveloperAside } from './aside' import { useSelector } from 'react-redux' import { History } from 'history' import { selectAppDetailState, selectAppDetailData, selectAppDetailLoading } from '@/selector/developer-app-detail' @@ -16,7 +16,7 @@ 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 AppContent from './app-content' export type DeveloperAppDetailProps = {} diff --git a/packages/developer-portal/src/components/pages/app-detail/developer/developer-app-revision-modal.tsx b/packages/developer-portal/src/components/pages/app-detail/developer/app-revision-modal.tsx similarity index 100% rename from packages/developer-portal/src/components/pages/app-detail/developer/developer-app-revision-modal.tsx rename to packages/developer-portal/src/components/pages/app-detail/developer/app-revision-modal.tsx diff --git a/packages/developer-portal/src/components/pages/app-detail/developer/developer-aside.tsx b/packages/developer-portal/src/components/pages/app-detail/developer/aside.tsx similarity index 97% rename from packages/developer-portal/src/components/pages/app-detail/developer/developer-aside.tsx rename to packages/developer-portal/src/components/pages/app-detail/developer/aside.tsx index 4bfd009cfe..30505309fc 100644 --- a/packages/developer-portal/src/components/pages/app-detail/developer/developer-aside.tsx +++ b/packages/developer-portal/src/components/pages/app-detail/developer/aside.tsx @@ -7,7 +7,7 @@ import { DesktopIntegrationTypeModel } from '@reapit/foundations-ts-definitions' import { DeveloperAppDetailState } from '@/reducers/developer' import { AppDetailModel } from '@reapit/foundations-ts-definitions' import useReactResponsive from '@/components/hooks/use-react-responsive' -import DeveloperManageApp from './developer-manage-app' +import DeveloperManageApp from './manage-app' import { CategorySection, DesktopIntegrationSection, diff --git a/packages/developer-portal/src/components/pages/app-detail/developer/index.ts b/packages/developer-portal/src/components/pages/app-detail/developer/index.ts index 2db0658cf6..5897395e5f 100644 --- a/packages/developer-portal/src/components/pages/app-detail/developer/index.ts +++ b/packages/developer-portal/src/components/pages/app-detail/developer/index.ts @@ -1,3 +1,3 @@ -import DeveloperAppDetail from './developer-app-detail' +import DeveloperAppDetail from './app-detail' export default DeveloperAppDetail diff --git a/packages/developer-portal/src/components/pages/app-detail/developer/developer-manage-app.tsx b/packages/developer-portal/src/components/pages/app-detail/developer/manage-app.tsx similarity index 100% rename from packages/developer-portal/src/components/pages/app-detail/developer/developer-manage-app.tsx rename to packages/developer-portal/src/components/pages/app-detail/developer/manage-app.tsx diff --git a/packages/developer-portal/src/core/router.tsx b/packages/developer-portal/src/core/router.tsx index 652afd8b8a..67c624ebef 100644 --- a/packages/developer-portal/src/core/router.tsx +++ b/packages/developer-portal/src/core/router.tsx @@ -12,7 +12,6 @@ export const history = createBrowserHistory() const Authentication = React.lazy(() => catchChunkError(() => import('../components/pages/authentication'))) const Login = React.lazy(() => catchChunkError(() => import('../components/pages/login'))) const Client = React.lazy(() => catchChunkError(() => import('../components/pages/client'))) -const ClientAppDetail = React.lazy(() => catchChunkError(() => import('../components/pages/app-detail/client'))) const ClientWelcomePage = React.lazy(() => catchChunkError(() => import('../components/pages/client-welcome'))) const InstalledApps = React.lazy(() => catchChunkError(() => import('../components/pages/installed-apps'))) const ClientSetting = React.lazy(() => catchChunkError(() => import('../components/pages/settings/client-setting'))) @@ -92,20 +91,6 @@ const Router = () => { - - @@ -173,8 +158,6 @@ const Router = () => { fetcher component={DeveloperHelpPage} /> - -