-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NCL-8899 Add announcement redirect to old UI when React UI is set as …
…primary UI
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Alert, AlertActionCloseButton, AlertVariant } from '@patternfly/react-core'; | ||
import { ApplicationsIcon, ArrowIcon } from '@patternfly/react-icons'; | ||
|
||
import { useStorage } from 'hooks/useStorage'; | ||
|
||
const URL_TRIGGER = 'secondary'; | ||
const LOCAL_STORAGE_KEY = 'old-ui-announcement-closed'; | ||
|
||
export const OldUIAnnouncement = () => { | ||
const { storageValue: isClosed, storeToStorage: setIsClosed } = useStorage<boolean>({ | ||
storageKey: LOCAL_STORAGE_KEY, | ||
initialValue: false, | ||
}); | ||
|
||
const oldUIUrl = process.env.REACT_APP_PNC_OLD_UI_WEB; | ||
|
||
//Display announcement when oldUIUrl is configured and current host name does not contain keyword | ||
const shouldDisplay = !!oldUIUrl && !window.location.hostname.toLowerCase().includes(URL_TRIGGER); | ||
|
||
if (!shouldDisplay || isClosed) { | ||
return null; | ||
} | ||
|
||
const closeAnnouncement = () => { | ||
setIsClosed(true); | ||
}; | ||
|
||
return ( | ||
<Alert | ||
id="old-ui-announcement-bar" | ||
variant={AlertVariant.custom} | ||
actionClose={<AlertActionCloseButton onClose={closeAnnouncement} />} | ||
aria-label="Old UI Announcement" | ||
customIcon={<ApplicationsIcon />} | ||
title={ | ||
<> | ||
Welcome to the new PNC Web UI. The{' '} | ||
<a href={oldUIUrl} target="_blank" rel="noopener noreferrer"> | ||
Old UI Version <ArrowIcon /> | ||
</a>{' '} | ||
is temporarily available, but it will soon be decommissioned. | ||
</> | ||
} | ||
isInline | ||
/> | ||
); | ||
}; |