From 26fab0fd17e3d267af2d852e54b2986313d5bb94 Mon Sep 17 00:00:00 2001 From: Joel Davies Date: Mon, 2 Dec 2024 16:03:22 +0000 Subject: [PATCH] Address review comments #1379 --- src/App.test.tsx | 1 + src/adminPage/adminPage.component.tsx | 5 +---- src/mainAppBar/mobileOverflowMenu.component.tsx | 3 +-- src/mainAppBar/pageLinks.component.tsx | 3 +-- src/state/reducers/createReducer.tsx | 2 +- vite.config.ts | 2 -- 6 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/App.test.tsx b/src/App.test.tsx index 0b4849c2..03d73d6e 100644 --- a/src/App.test.tsx +++ b/src/App.test.tsx @@ -35,6 +35,7 @@ vi.mock('axios', async () => { if (path === '/settings.json') { return Promise.resolve({ data: { + // Set provider to icat as that supports maintenance states needed for App.test.tsx 'auth-provider': 'icat', 'ui-strings': '/res/default.json', plugins: [], diff --git a/src/adminPage/adminPage.component.tsx b/src/adminPage/adminPage.component.tsx index f8e58da1..1436f047 100644 --- a/src/adminPage/adminPage.component.tsx +++ b/src/adminPage/adminPage.component.tsx @@ -59,10 +59,7 @@ const AdminPage = (props: AdminPageProps): ReactElement => { location.pathname.startsWith(adminRoutes[key]) ) ?? (props.adminPageDefaultTab && - Object.prototype.hasOwnProperty.call( - adminRoutes, - props.adminPageDefaultTab - ) + Object.hasOwn(adminRoutes, props.adminPageDefaultTab) ? props.adminPageDefaultTab : 'maintenance') ); diff --git a/src/mainAppBar/mobileOverflowMenu.component.tsx b/src/mainAppBar/mobileOverflowMenu.component.tsx index 5a8cbb4c..7a36e980 100644 --- a/src/mainAppBar/mobileOverflowMenu.component.tsx +++ b/src/mainAppBar/mobileOverflowMenu.component.tsx @@ -49,8 +49,7 @@ function MobileOverflowMenu({ function navigateToAdminPage(): void { const targetRoute = - adminPageDefaultTab && - Object.prototype.hasOwnProperty.call(adminRoutes, adminPageDefaultTab) + adminPageDefaultTab && Object.hasOwn(adminRoutes, adminPageDefaultTab) ? adminRoutes[adminPageDefaultTab] : adminRoutes['maintenance']; diff --git a/src/mainAppBar/pageLinks.component.tsx b/src/mainAppBar/pageLinks.component.tsx index 01615cf3..c96a420f 100644 --- a/src/mainAppBar/pageLinks.component.tsx +++ b/src/mainAppBar/pageLinks.component.tsx @@ -35,8 +35,7 @@ function PageLinks(): JSX.Element { function navigateToAdminPage(): void { const targetRoute = - adminPageDefaultTab && - Object.prototype.hasOwnProperty.call(adminRoutes, adminPageDefaultTab) + adminPageDefaultTab && Object.hasOwn(adminRoutes, adminPageDefaultTab) ? adminRoutes[adminPageDefaultTab] : adminRoutes['maintenance']; diff --git a/src/state/reducers/createReducer.tsx b/src/state/reducers/createReducer.tsx index de183464..924d327d 100644 --- a/src/state/reducers/createReducer.tsx +++ b/src/state/reducers/createReducer.tsx @@ -7,7 +7,7 @@ interface Action { function createReducer(initialState: any, handlers: Record): any { return function reducer(state: any = initialState, action: Action) { - if (action && Object.prototype.hasOwnProperty.call(handlers, action.type)) { + if (action && Object.hasOwn(handlers, action.type)) { return handlers[action.type](state, action.payload); } return state; diff --git a/vite.config.ts b/vite.config.ts index fc9f9dc2..e30b9469 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -44,8 +44,6 @@ export default defineConfig(({ mode }) => { plugins: plugins, server: { port: 3000, - // Don't open by default as Dockerfile wont run as it can't find a display - open: false, }, preview: { port: 5001,