diff --git a/packages/developer-portal/src/components/ui/__tests__/menu.tsx b/packages/developer-portal/src/components/ui/__tests__/menu.tsx index 3fbca5abbe..6ddca0915e 100644 --- a/packages/developer-portal/src/components/ui/__tests__/menu.tsx +++ b/packages/developer-portal/src/components/ui/__tests__/menu.tsx @@ -41,8 +41,7 @@ describe('Menu', () => { search: '', state: {}, } - const logout = jest.fn() - const result = generateMenuConfig(logout, location, false) + const result = generateMenuConfig(location) expect(result).toBeDefined() }) }) diff --git a/packages/developer-portal/src/components/ui/menu.tsx b/packages/developer-portal/src/components/ui/menu.tsx index bccc28310c..214f0639fb 100644 --- a/packages/developer-portal/src/components/ui/menu.tsx +++ b/packages/developer-portal/src/components/ui/menu.tsx @@ -1,122 +1,82 @@ import * as React from 'react' -import { useDispatch, useSelector } from 'react-redux' import { useLocation } from 'react-router' import { Menu as Sidebar, MenuConfig, ReapitLogo } from '@reapit/elements' -import { authLogout } from '@/actions/auth' import Routes from '../../constants/routes' import { Location } from 'history' -import { FaSignOutAlt, FaCloud, FaReadme, FaCog, FaChartBar, FaBolt, FaDesktop } from 'react-icons/fa' +import { FaCloud, FaReadme, FaCog, FaChartBar, FaBolt, FaDesktop } from 'react-icons/fa' import { MdHelp } from 'react-icons/md' import { GoDatabase } from 'react-icons/go' -import { selectIsAdmin, selectLoginType } from '@/selector/auth' import { ActionCreator } from '@/types/core' import { LoginType } from '@reapit/cognito-auth' import { Dispatch } from 'redux' -import { selectDeveloperEditionId } from '@/selector/client' -export const generateMenuConfig = ( - logoutCallback: () => void, - location: Location, - isAdmin: boolean, -): { [key: string]: MenuConfig } => { +export const generateMenuConfig = (location: Location): MenuConfig => { return { - ADMIN: { - defaultActiveKey: 'APPROVALS', - location, - menu: [ - { - key: 'LOGO', - icon: , - type: 'LOGO', - }, - - { - title: 'Logout', - key: 'LOGOUT', - callback: logoutCallback, - icon: , - type: 'SECONDARY', - }, - ], - }, - DEVELOPER: { - defaultActiveKey: 'MANAGE_APPS', - location, - menu: [ - { - key: 'LOGO', - icon: , - type: 'LOGO', - }, - { - title: 'Apps', - key: 'MANAGE_APPS', - url: Routes.APPS, - type: 'PRIMARY', - icon: , - }, - { - title: 'Analytics', - key: 'DEVELOPER_ANALYTICS', - url: Routes.ANALYTICS, - type: 'PRIMARY', - icon: , - }, - { - title: 'API', - key: 'SWAGGER', - url: Routes.SWAGGER, - type: 'PRIMARY', - icon: , - }, - { - title: 'Webhooks', - key: 'WEBHOOKS', - url: Routes.WEBHOOKS, - type: 'PRIMARY', - icon: , - }, - { - title: 'Docs', - key: 'API_DOCS', - url: Routes.API_DOCS, - type: 'PRIMARY', - icon: , - }, - { - title: 'Desktop', - key: 'DESKTOP', - url: Routes.DESKTOP, - type: 'PRIMARY', - icon: , - }, - { - title: 'Help', - key: 'HELP', - url: Routes.HELP, - type: 'PRIMARY', - icon: , - }, - { - title: 'Settings', - key: 'SETTINGS', - url: Routes.SETTINGS, - icon: , - type: 'SECONDARY', - }, - ], - }, - CLIENT: { - defaultActiveKey: 'BROWSE_APPS', - location, - menu: [ - { - key: 'LOGO', - icon: , - type: 'LOGO', - }, - ], - }, + defaultActiveKey: 'MANAGE_APPS', + location, + menu: [ + { + key: 'LOGO', + icon: , + type: 'LOGO', + }, + { + title: 'Apps', + key: 'MANAGE_APPS', + url: Routes.APPS, + type: 'PRIMARY', + icon: , + }, + { + title: 'Analytics', + key: 'DEVELOPER_ANALYTICS', + url: Routes.ANALYTICS, + type: 'PRIMARY', + icon: , + }, + { + title: 'API', + key: 'SWAGGER', + url: Routes.SWAGGER, + type: 'PRIMARY', + icon: , + }, + { + title: 'Webhooks', + key: 'WEBHOOKS', + url: Routes.WEBHOOKS, + type: 'PRIMARY', + icon: , + }, + { + title: 'Docs', + key: 'API_DOCS', + url: Routes.API_DOCS, + type: 'PRIMARY', + icon: , + }, + { + title: 'Desktop', + key: 'DESKTOP', + url: Routes.DESKTOP, + type: 'PRIMARY', + icon: , + }, + { + title: 'Help', + key: 'HELP', + url: Routes.HELP, + type: 'PRIMARY', + icon: , + }, + { + title: 'Settings', + key: 'SETTINGS', + url: Routes.SETTINGS, + icon: , + type: 'SECONDARY', + }, + ], } } @@ -136,14 +96,8 @@ export const logout = ({ dispatch, authLogout }: { dispatch: Dispatch; authLogou export const Menu: React.FunctionComponent = () => { const location = useLocation() - const dispatch = useDispatch() - const isDesktopAdmin = useSelector(selectIsAdmin) - const isDeveloperEdition = Boolean(useSelector(selectDeveloperEditionId)) - const loginType = useSelector(selectLoginType) - const isAdmin = isDesktopAdmin || isDeveloperEdition - - const menuConfigs = generateMenuConfig(logout({ dispatch, authLogout }), location, isAdmin) - return + const menuConfigs = generateMenuConfig(location) + return } export default Menu diff --git a/packages/developer-portal/src/core/__tests__/private-route-wrapper.tsx b/packages/developer-portal/src/core/__tests__/private-route-wrapper.tsx index f5be4e10c1..c031114932 100644 --- a/packages/developer-portal/src/core/__tests__/private-route-wrapper.tsx +++ b/packages/developer-portal/src/core/__tests__/private-route-wrapper.tsx @@ -5,7 +5,7 @@ import { shallow, mount } from 'enzyme' import configureStore from 'redux-mock-store' import appState from '@/reducers/__stubs__/app-state' import { PrivateRouteWrapper, handleSetTermsAcceptFromCookie } from '../private-route-wrapper' -import { selectLoginSession, selectRefreshSession, selectLoginType } from '@/selector/auth' +import { selectLoginSession, selectRefreshSession } from '@/selector/auth' import { getTokenFromQueryString, redirectToOAuth, RefreshParams } from '@reapit/cognito-auth' import { getCookieString, COOKIE_DEVELOPER_FIRST_TIME_LOGIN_COMPLETE } from '@/utils/cookie' import { authSetRefreshSession, setInitDeveloperTermsAcceptedStateFromCookie } from '@/actions/auth' diff --git a/packages/developer-portal/src/sagas/__tests__/app-delete.ts b/packages/developer-portal/src/sagas/__tests__/app-delete.ts index 38a0fa254f..81ac2e5ddb 100644 --- a/packages/developer-portal/src/sagas/__tests__/app-delete.ts +++ b/packages/developer-portal/src/sagas/__tests__/app-delete.ts @@ -6,7 +6,7 @@ import { put, takeLatest, call } from '@redux-saga/core/effects' import { appDeleteRequestSuccess, appDeleteRequestLoading, appDeleteRequestFailure } from '@/actions/app-delete' import { Action } from '@/types/core' import { cloneableGenerator } from '@redux-saga/testing-utils' -import { deleteAppById, fetchAppsList } from '@/services/apps' +import { deleteAppById } from '@/services/apps' jest.mock('@/services/apps') jest.mock('@reapit/elements') diff --git a/packages/developer-portal/src/sagas/__tests__/revision-detail.ts b/packages/developer-portal/src/sagas/__tests__/revision-detail.ts index cf5326ca8b..f5cac2709f 100644 --- a/packages/developer-portal/src/sagas/__tests__/revision-detail.ts +++ b/packages/developer-portal/src/sagas/__tests__/revision-detail.ts @@ -98,11 +98,11 @@ describe('revision-detail thunks', () => { describe('revision decline submmit', () => { const gen = cloneableGenerator(declineRevision as any)(declineSubmitParams) const { appId, appRevisionId, ...body } = declineSubmitParams.data + expect(gen.next('SUBMITTING').value).toEqual(put(declineRevisionSetFormState('SUBMITTING'))) expect(gen.next().value).toEqual(call(rejectAppRevisionById, { id: appId, revisionId: appRevisionId, ...body })) test('api call success', () => { const clone = gen.clone() - expect(clone.next({}).value).toBeCalled() expect(clone.next('SUCCESS').value).toEqual(put(declineRevisionSetFormState('SUCCESS'))) expect(clone.next().done).toBe(true) }) diff --git a/packages/developer-portal/src/utils/__tests__/actions.ts b/packages/developer-portal/src/utils/__tests__/actions.ts index 2476e81a7e..72fac5861a 100644 --- a/packages/developer-portal/src/utils/__tests__/actions.ts +++ b/packages/developer-portal/src/utils/__tests__/actions.ts @@ -1,6 +1,6 @@ import { actionCreator, isType } from '../actions' import ActionTypes from '../../constants/action-types' -import { developerRequestData, developerReceiveData } from '../../actions/developer' +import { developerRequestData } from '../../actions/developer' import { Action } from '../../types/core' import { DeveloperRequestParams } from '@/reducers/developer'