-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance Share Health Status Verify/ReApply (#1346)
### Feature or Bugfix <!-- please choose --> - Feature ### Detail - Enhance Share UI for re-apply and verify share health status ### Relates - #1107 ### Security Please answer the questions below briefly where applicable, or write `N/A`. Based on [OWASP 10](https://owasp.org/Top10/en/). - Does this PR introduce or modify any input fields or queries - this includes fetching data from storage outside the application (e.g. a database, an S3 bucket)? - Is the input sanitized? - What precautions are you taking before deserializing the data you consume? - Is injection prevented by parametrizing queries? - Have you ensured no `eval` or similar functions are used? - Does this PR introduce any functionality or component that requires authorization? - How have you ensured it respects the existing AuthN/AuthZ mechanisms? - Are you logging failed auth attempts? - Are you using or adding any cryptographic features? - Do you use a standard proven implementations? - Are the used keys controlled by the customer? Where are they stored? - Are you introducing any new policies/roles/users? - Have you used the least-privilege principle? How? By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
- Loading branch information
1 parent
406cc3b
commit cc927d0
Showing
12 changed files
with
209 additions
and
37 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
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,72 @@ | ||
import VerifiedUserOutlinedIcon from '@mui/icons-material/VerifiedUserOutlined'; | ||
import GppBadOutlinedIcon from '@mui/icons-material/GppBadOutlined'; | ||
import PendingOutlinedIcon from '@mui/icons-material/PendingOutlined'; | ||
import DangerousOutlinedIcon from '@mui/icons-material/DangerousOutlined'; | ||
import * as PropTypes from 'prop-types'; | ||
import { Typography } from '@mui/material'; | ||
import { Label } from './Label'; | ||
|
||
export const ShareHealthStatus = (props) => { | ||
const { status, healthStatus, lastVerificationTime } = props; | ||
|
||
const isShared = ['Revoke_Failed', 'Share_Succeeded'].includes(status); | ||
const isHealthPending = ['PendingReApply', 'PendingVerify', null].includes( | ||
healthStatus | ||
); | ||
const setStatus = () => { | ||
if (!healthStatus) return 'Undefined'; | ||
return healthStatus; | ||
}; | ||
|
||
const setColor = () => { | ||
if (!healthStatus) return 'info'; | ||
if (['Healthy'].includes(healthStatus)) return 'success'; | ||
if (['Unhealthy'].includes(healthStatus)) return 'error'; | ||
if (isHealthPending) return 'warning'; | ||
return 'info'; | ||
}; | ||
|
||
const setIcon = () => { | ||
if (!healthStatus) return <DangerousOutlinedIcon color={setColor()} />; | ||
if (['Healthy'].includes(healthStatus)) | ||
return <VerifiedUserOutlinedIcon color={setColor()} />; | ||
if (['Unhealthy'].includes(healthStatus)) | ||
return <GppBadOutlinedIcon color={setColor()} />; | ||
if (['PendingReApply', 'PendingVerify'].includes(healthStatus)) | ||
return <PendingOutlinedIcon color={setColor()} />; | ||
return <DangerousOutlinedIcon color={setColor()} />; | ||
}; | ||
|
||
if (!isShared) { | ||
return ( | ||
<Typography color="textSecondary" variant="subtitle2"> | ||
{'Item is not Shared'} | ||
</Typography> | ||
); | ||
} | ||
|
||
return ( | ||
<div style={{ display: 'flex', alignItems: 'left' }}> | ||
{setIcon()} | ||
<Label color={setColor()}>{setStatus().toUpperCase()} </Label> | ||
{!isHealthPending && ( | ||
<Typography color="textSecondary" variant="subtitle2" noWrap> | ||
{(lastVerificationTime && | ||
'(' + | ||
lastVerificationTime.substring( | ||
0, | ||
lastVerificationTime.indexOf('.') | ||
) + | ||
')') || | ||
''} | ||
</Typography> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
ShareHealthStatus.propTypes = { | ||
status: PropTypes.string.isRequired, | ||
healthStatus: PropTypes.string, | ||
lastVerificationTime: PropTypes.string | ||
}; |
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
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
60 changes: 60 additions & 0 deletions
60
frontend/src/modules/Shares/components/NavigateShareViewModal.js
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,60 @@ | ||
import { Box, Dialog, Divider, Typography, Button } from '@mui/material'; | ||
import PropTypes from 'prop-types'; | ||
import { Link as RouterLink } from 'react-router-dom'; | ||
|
||
export const NavigateShareViewModal = (props) => { | ||
const { dataset, onApply, onClose, open, ...other } = props; | ||
|
||
return ( | ||
<Dialog maxWidth="md" fullWidth onClose={onClose} open={open} {...other}> | ||
<Box sx={{ p: 3 }}> | ||
<Typography | ||
align="center" | ||
color="textPrimary" | ||
gutterBottom | ||
variant="h4" | ||
> | ||
Dataset: {dataset.label} - Share Object Verification Task(s) Started | ||
</Typography> | ||
<Typography | ||
align="center" | ||
color="textSecondary" | ||
variant="subtitle2" | ||
sx={{ p: 1 }} | ||
> | ||
Navigate to the Share View Page and select the desired share object to | ||
view the progress of each of verification task | ||
</Typography> | ||
<Divider /> | ||
<Button | ||
sx={{ p: 1 }} | ||
color="primary" | ||
type="button" | ||
fullWidth | ||
component={RouterLink} | ||
to={`/console/shares`} | ||
variant="contained" | ||
> | ||
Navigate to Shares View | ||
</Button> | ||
<Button | ||
sx={{ p: 1 }} | ||
onClick={onClose} | ||
fullWidth | ||
color="primary" | ||
variant="outlined" | ||
> | ||
Close | ||
</Button> | ||
</Box> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
NavigateShareViewModal.propTypes = { | ||
shares: PropTypes.array.isRequired, | ||
dataset: PropTypes.object.isRequired, | ||
onApply: PropTypes.func, | ||
onClose: PropTypes.func, | ||
open: PropTypes.bool.isRequired | ||
}; |
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
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