Skip to content

Commit

Permalink
Fix side window refresh when already opened
Browse files Browse the repository at this point in the history
  • Loading branch information
ivangabriele committed Sep 18, 2024
1 parent 99f9a9f commit db9156a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
10 changes: 4 additions & 6 deletions frontend/src/features/SideWindow/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function Menu({ selectedMenu }: MenuProps) {
data-cy="side-window-menu-mission-list"
Icon={Icon.MissionAction}
iconSize={26}
onClick={() => dispatch(openSideWindowPath({ menu: SideWindowMenuKey.MISSION_LIST }, false, true))}
onClick={() => dispatch(openSideWindowPath({ menu: SideWindowMenuKey.MISSION_LIST }))}
role="menuitem"
selected={selectedMenu === SideWindowMenuKey.MISSION_LIST}
title={SideWindowMenuLabel.MISSION_LIST}
Expand All @@ -29,9 +29,7 @@ export function Menu({ selectedMenu }: MenuProps) {
data-cy="side-window-menu-alerts"
Icon={Icon.Alert}
iconSize={26}
onClick={() =>
dispatch(openSideWindowPath({ menu: SideWindowMenuKey.ALERT_LIST_AND_REPORTING_LIST }, false, true))
}
onClick={() => dispatch(openSideWindowPath({ menu: SideWindowMenuKey.ALERT_LIST_AND_REPORTING_LIST }))}
role="menuitem"
selected={selectedMenu === SideWindowMenuKey.ALERT_LIST_AND_REPORTING_LIST}
title={SideWindowMenuLabel.ALERT_LIST_AND_REPORTING_LIST}
Expand All @@ -41,7 +39,7 @@ export function Menu({ selectedMenu }: MenuProps) {
aria-label={SideWindowMenuKey.PRIOR_NOTIFICATION_LIST}
Icon={Icon.Fishery}
iconSize={26}
onClick={() => dispatch(openSideWindowPath({ menu: SideWindowMenuKey.PRIOR_NOTIFICATION_LIST }, false, true))}
onClick={() => dispatch(openSideWindowPath({ menu: SideWindowMenuKey.PRIOR_NOTIFICATION_LIST }))}
role="menuitem"
selected={selectedMenu === SideWindowMenuKey.PRIOR_NOTIFICATION_LIST}
title={SideWindowMenuLabel.PRIOR_NOTIFICATION_LIST}
Expand All @@ -51,7 +49,7 @@ export function Menu({ selectedMenu }: MenuProps) {
data-cy="side-window-menu-beacon-malfunctions"
Icon={Icon.Vms}
iconSize={26}
onClick={() => dispatch(openSideWindowPath({ menu: SideWindowMenuKey.BEACON_MALFUNCTION_BOARD }, false, true))}
onClick={() => dispatch(openSideWindowPath({ menu: SideWindowMenuKey.BEACON_MALFUNCTION_BOARD }))}
role="menuitem"
selected={selectedMenu === SideWindowMenuKey.BEACON_MALFUNCTION_BOARD}
title={SideWindowMenuLabel.BEACON_MALFUNCTION_BOARD}
Expand Down
14 changes: 5 additions & 9 deletions frontend/src/features/SideWindow/useCases/openSideWindowPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ import type { MainAppThunk } from '../../../store'
import type { SideWindow } from '../SideWindow.types'

export const openSideWindowPath =
(
path: SideWindow.Path,
withoutConfirmation: boolean = false,
isSameWindow: boolean = false
): MainAppThunk<Promise<boolean>> =>
async (dispatch, getState) => {
(path: SideWindow.Path, withoutConfirmation: boolean = false): MainAppThunk<boolean> =>
(dispatch, getState) => {
const { missionForm, sideWindow } = getState()

if (
Expand All @@ -21,14 +17,14 @@ export const openSideWindowPath =
sideWindow.status !== SideWindowStatus.CLOSED &&
missionForm.isDraftDirty
) {
await dispatch(askForSideWindowDraftCancellationConfirmation(path))
dispatch(askForSideWindowDraftCancellationConfirmation(path))

return false
}

await dispatch(sideWindowActions.openOrFocusAndGoTo(getFullPathFromPath(path)))
dispatch(sideWindowActions.openOrFocusAndGoTo(getFullPathFromPath(path)))

if (!isSameWindow) {
if (sideWindow.status === SideWindowStatus.CLOSED && !window.location.href.includes('side_window')) {
window.open('/side_window', 'MonitorFish', `height=1200,width=${window.innerWidth}`)
}

Expand Down

0 comments on commit db9156a

Please sign in to comment.