-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PSP-9900 : PIMS service availability notifications #4674
Open
eddherrera
wants to merge
4
commits into
bcgov:dev
Choose a base branch
from
eddherrera:psp-9900
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
@import './colors.scss'; | ||
|
||
$healthcheck-height: 4.5rem; | ||
$header-height: 7.2rem; | ||
$mapfilter-height: 6rem; | ||
$footer-height: 4.4rem; |
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
53 changes: 53 additions & 0 deletions
53
source/frontend/src/components/layout/Healthcheck/HealthcheckView.test.tsx
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,53 @@ | ||
import HealthcheckView, { IHealthCheckIssue, IHealthCheckViewProps } from './HealthcheckView'; | ||
import { act, render, RenderOptions, userEvent, screen } from '@/utils/test-utils'; | ||
|
||
const mockHealthcheckIssues: IHealthCheckIssue[] = [ | ||
{ | ||
key: 'PimsApi', | ||
msg: 'The PIMS server is currently unavailable, PIMS will not be useable until this is resolved.', | ||
}, | ||
]; | ||
|
||
describe('Healthcheck View component', () => { | ||
const setup = async ( | ||
renderOptions: RenderOptions & { props?: Partial<IHealthCheckViewProps> } = {}, | ||
) => { | ||
const utils = render( | ||
<HealthcheckView | ||
{...renderOptions.props} | ||
systemChecks={renderOptions.props?.systemChecks ?? mockHealthcheckIssues} | ||
/>, | ||
{ | ||
...renderOptions, | ||
}, | ||
); | ||
|
||
return { | ||
...utils, | ||
}; | ||
}; | ||
|
||
afterEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
it('renders as expected', async () => { | ||
const { asFragment } = await setup({}); | ||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
|
||
it(`renders 'See the full list here' link`, async () => { | ||
const { getByTestId } = await setup({ | ||
props: { | ||
systemChecks: [ | ||
{ | ||
key: 'Mayan', | ||
msg: 'The PIMS Document server is experiencing service degradation, you will be unable to view, download or upload documents until resolved.', | ||
}, | ||
...mockHealthcheckIssues, | ||
], | ||
}, | ||
}); | ||
expect(getByTestId('healthcheck-full-list-lnk')).toBeVisible(); | ||
}); | ||
}); |
130 changes: 130 additions & 0 deletions
130
source/frontend/src/components/layout/Healthcheck/HealthcheckView.tsx
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,130 @@ | ||
import { FaBan } from 'react-icons/fa'; | ||
import styled from 'styled-components'; | ||
|
||
import { LinkButton } from '@/components/common/buttons/LinkButton'; | ||
import { ModalSize } from '@/components/common/GenericModal'; | ||
import { useModalContext } from '@/hooks/useModalContext'; | ||
|
||
export interface IHealthCheckIssue { | ||
key: string; | ||
msg: string; | ||
} | ||
|
||
export interface IHealthCheckViewProps { | ||
systemChecks: IHealthCheckIssue[]; | ||
} | ||
|
||
const HealthcheckView: React.FunctionComponent<IHealthCheckViewProps> = ({ systemChecks }) => { | ||
const { setModalContent, setDisplayModal } = useModalContext(); | ||
|
||
return ( | ||
systemChecks.length && ( | ||
<StyledWrapperDiv> | ||
<StyledIconDiv> | ||
<FaBan size={24} /> | ||
</StyledIconDiv> | ||
<StyledContainer> | ||
<label> | ||
<span>{systemChecks[0].key}: </span> | ||
{systemChecks[0].msg} | ||
</label> | ||
{systemChecks.length > 1 && ( | ||
<LinkButton | ||
data-testid="healthcheck-full-list-lnk" | ||
onClick={() => { | ||
setModalContent({ | ||
variant: 'error', | ||
title: 'Error', | ||
modalSize: ModalSize.LARGE, | ||
message: ( | ||
<StyledList> | ||
{systemChecks.map(x => { | ||
return ( | ||
<label key={x.key}> | ||
<span>{x.key}: </span> | ||
{x.msg} | ||
</label> | ||
); | ||
})} | ||
</StyledList> | ||
), | ||
okButtonText: 'Close', | ||
handleOk: async () => { | ||
setDisplayModal(false); | ||
}, | ||
}); | ||
setDisplayModal(true); | ||
}} | ||
> | ||
See the full list here... | ||
</LinkButton> | ||
)} | ||
</StyledContainer> | ||
</StyledWrapperDiv> | ||
) | ||
); | ||
}; | ||
|
||
const StyledWrapperDiv = styled.div` | ||
display: flex; | ||
height: 100%; | ||
background-color: ${props => props.theme.css.dangerBackgroundColor}; | ||
`; | ||
|
||
const StyledIconDiv = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: auto; | ||
min-width: 6rem; | ||
height: 100%; | ||
background-color: ${props => props.theme.bcTokens.typographyColorDanger}; | ||
|
||
svg { | ||
color: ${props => props.theme.css.pimsWhite}; | ||
} | ||
`; | ||
|
||
const StyledContainer = styled.div` | ||
display: flex; | ||
align-items: center; | ||
flex-direction: row; | ||
flex-grow: 1; | ||
justify-content: flex-start; | ||
padding-left: 6rem; | ||
background-color: ${props => props.theme.css.dangerBackgroundColor}; | ||
|
||
label { | ||
display: list-item; | ||
margin-bottom: 0; | ||
|
||
span { | ||
text-transform: uppercase; | ||
font-weight: bolder; | ||
} | ||
} | ||
|
||
button { | ||
margin-left: 6rem; | ||
} | ||
`; | ||
|
||
const StyledList = styled.div` | ||
padding: 1rem 2rem; | ||
|
||
label { | ||
display: list-item; | ||
margin-bottom: 0; | ||
|
||
span { | ||
text-transform: uppercase; | ||
font-weight: bolder; | ||
} | ||
} | ||
|
||
button { | ||
margin-left: 6rem; | ||
} | ||
`; | ||
|
||
export default HealthcheckView; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this appears to throw an NPE, as this is initialized with null until the promise returns.