-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(topology): remove usage of pf react icons (#1803)
- Loading branch information
Showing
51 changed files
with
609 additions
and
597 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,236 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
StatusClassKey, | ||
StatusError, | ||
StatusOK, | ||
StatusPending, | ||
StatusRunning, | ||
StatusWarning, | ||
} from '@backstage/core-components'; | ||
|
||
import { makeStyles } from '@material-ui/core'; | ||
import OffIcon from '@mui/icons-material/DoNotDisturbOnOutlined'; | ||
import UnknownIcon from '@mui/icons-material/HelpOutline'; | ||
import AngleDoubleRightIcon from '@mui/icons-material/KeyboardDoubleArrowRight'; | ||
import BanIcon from '@mui/icons-material/NotInterestedOutlined'; | ||
import PauseIcon from '@mui/icons-material/PauseCircleOutlineOutlined'; | ||
|
||
import { StatusIconAndText } from './StatusIconAndText'; | ||
|
||
const useStyles = makeStyles({ | ||
iconStyles: { | ||
height: '0.8em', | ||
width: '0.8em', | ||
top: '0.125em', | ||
position: 'relative', | ||
flexShrink: 0, | ||
marginRight: '8px', | ||
}, | ||
}); | ||
|
||
const DASH = '-'; | ||
|
||
const useStatusStyles = makeStyles(theme => ({ | ||
success: { | ||
'& svg': { | ||
fill: theme.palette.status.ok, | ||
}, | ||
}, | ||
running: { | ||
'& svg': { | ||
fill: theme.palette.status.running, | ||
}, | ||
}, | ||
pending: { | ||
'& svg': { | ||
fill: theme.palette.status.pending, | ||
}, | ||
}, | ||
warning: { | ||
'& svg': { | ||
fill: theme.palette.status.warning, | ||
}, | ||
}, | ||
error: { | ||
'& svg': { | ||
fill: theme.palette.status.error, | ||
}, | ||
}, | ||
})); | ||
|
||
const StatusIcon = ({ statusKey }: { statusKey: StatusClassKey }) => { | ||
const statusStyles = useStatusStyles(); | ||
|
||
switch (statusKey) { | ||
case 'ok': | ||
return ( | ||
<g className={statusStyles.success}> | ||
<StatusOK />{' '} | ||
</g> | ||
); | ||
case 'pending': | ||
return ( | ||
<g className={statusStyles.pending}> | ||
<StatusPending />{' '} | ||
</g> | ||
); | ||
case 'running': | ||
return ( | ||
<g className={statusStyles.running}> | ||
<StatusRunning />{' '} | ||
</g> | ||
); | ||
case 'warning': | ||
return ( | ||
<g className={statusStyles.warning}> | ||
<StatusWarning />{' '} | ||
</g> | ||
); | ||
case 'error': | ||
return ( | ||
<g className={statusStyles.error}> | ||
<StatusError />{' '} | ||
</g> | ||
); | ||
default: | ||
return null; | ||
} | ||
}; | ||
|
||
/** | ||
* Component for displaying a status message | ||
* @param {string} status - type of status to be displayed | ||
* @param {boolean} [iconOnly] - (optional) if true, only displays icon | ||
* @param {string} [className] - (optional) additional class name for the component | ||
* @example | ||
* ```tsx | ||
* <Status status='Warning' /> | ||
* ``` | ||
*/ | ||
export const Status = ({ | ||
status, | ||
iconOnly, | ||
className, | ||
displayStatusText, | ||
}: { | ||
status: string | null; | ||
displayStatusText?: string; | ||
iconOnly?: boolean; | ||
className?: string; | ||
}): React.ReactElement => { | ||
const classes = useStyles(); | ||
const statusProps = { | ||
title: displayStatusText || status || '', | ||
iconOnly, | ||
className, | ||
}; | ||
|
||
switch (status) { | ||
case 'New': | ||
case 'Idle': | ||
case 'Pending': | ||
case 'PipelineNotStarted': | ||
return ( | ||
<StatusIconAndText | ||
{...statusProps} | ||
icon={<StatusIcon statusKey="pending" />} | ||
/> | ||
); | ||
|
||
case 'In Progress': | ||
case 'Progress': | ||
case 'Installing': | ||
case 'InstallReady': | ||
case 'Replacing': | ||
case 'Running': | ||
case 'Updating': | ||
case 'Upgrading': | ||
case 'PendingInstall': | ||
return ( | ||
<StatusIconAndText | ||
{...statusProps} | ||
icon={<StatusIcon statusKey="running" />} | ||
/> | ||
); | ||
|
||
case 'Cancelled': | ||
case 'Deleting': | ||
case 'Expired': | ||
case 'Not Ready': | ||
case 'Cancelling': | ||
case 'Terminating': | ||
case 'Superseded': | ||
case 'Uninstalling': | ||
return ( | ||
<StatusIconAndText | ||
{...statusProps} | ||
icon={<BanIcon className={classes.iconStyles} />} | ||
/> | ||
); | ||
|
||
case 'Warning': | ||
case 'RequiresApproval': | ||
return ( | ||
<StatusIconAndText | ||
{...statusProps} | ||
icon={<StatusIcon statusKey="warning" />} | ||
/> | ||
); | ||
|
||
case 'ImagePullBackOff': | ||
case 'Error': | ||
case 'Failed': | ||
case 'CrashLoopBackOff': | ||
case 'ErrImagePull': | ||
return ( | ||
<StatusIconAndText | ||
{...statusProps} | ||
icon={<StatusIcon statusKey="error" />} | ||
/> | ||
); | ||
|
||
case 'Completed': | ||
case 'Succeeded': | ||
return ( | ||
<StatusIconAndText | ||
{...statusProps} | ||
icon={<StatusIcon statusKey="ok" />} | ||
/> | ||
); | ||
|
||
case 'Skipped': | ||
return ( | ||
<StatusIconAndText | ||
{...statusProps} | ||
icon={<AngleDoubleRightIcon className={classes.iconStyles} />} | ||
/> | ||
); | ||
case 'Paused': | ||
return ( | ||
<StatusIconAndText | ||
{...statusProps} | ||
icon={<PauseIcon className={classes.iconStyles} />} | ||
/> | ||
); | ||
case 'Stopped': | ||
return ( | ||
<StatusIconAndText | ||
{...statusProps} | ||
icon={<OffIcon className={classes.iconStyles} />} | ||
/> | ||
); | ||
|
||
case 'Unknown': | ||
return ( | ||
<StatusIconAndText | ||
{...statusProps} | ||
icon={<UnknownIcon className={classes.iconStyles} />} | ||
/> | ||
); | ||
|
||
default: | ||
return <>{status || DASH}</>; | ||
} | ||
}; |
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 |
---|---|---|
|
@@ -12,3 +12,4 @@ export { | |
DrawerContext, | ||
useDrawer, | ||
} from './common/DrawerContext'; | ||
export { Status } from './common/Status'; |
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,25 @@ | ||
import * as React from 'react'; | ||
|
||
import { global_palette_red_200 as criticalColor } from '@patternfly/react-tokens/dist/js/global_palette_red_200'; | ||
|
||
const CriticalRiskIcon = ({ | ||
className, | ||
title, | ||
}: { | ||
className: string; | ||
title?: string; | ||
}): React.ReactElement => { | ||
return ( | ||
<svg | ||
viewBox="0 0 925 1024" | ||
fill={criticalColor.value} | ||
xmlns="http://www.w3.org/2000/svg" | ||
className={className} | ||
> | ||
{title && <title>{title}</title>} | ||
<path d="M897.86597,252.24865 L491.105712,7.96742801 C473.40731,-2.65897781 451.300057,-2.65597516 433.611654,7.97743687 L27.1213875,252.245648 C10.3059556,262.353595 0.0163032058,280.549701 0.0163032058,300.182078 L0.0163032058,967.971163 C-1.04266102,1010.81008 49.7156241,1038.89994 85.4314175,1015.41816 C85.4304175,1015.42016 432.807682,798.630273 432.807682,798.630273 C450.891071,787.348287 473.816296,787.342282 491.906685,798.624268 L839.584939,1015.4612 C875.297732,1039.03406 926.031018,1010.73602 924.984054,968.003192 C924.985054,968.005193 924.985054,300.192087 924.985054,300.192087 C924.985054,280.552703 914.688401,262.353595 897.86597,252.24865" /> | ||
</svg> | ||
); | ||
}; | ||
|
||
export default CriticalRiskIcon; |
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,25 @@ | ||
import * as React from 'react'; | ||
|
||
import { global_palette_gold_400 as mediumColor } from '@patternfly/react-tokens/dist/js/global_palette_gold_400'; | ||
|
||
const EqualsIcon = ({ | ||
className, | ||
title, | ||
}: { | ||
className: string; | ||
title?: string; | ||
}): React.ReactElement => { | ||
return ( | ||
<svg | ||
viewBox="0 -960 960 960" | ||
fill={mediumColor.value} | ||
xmlns="http://www.w3.org/2000/svg" | ||
className={className} | ||
> | ||
{title && <title>{title}</title>} | ||
<path d="M160-280v-120h640v120H160Zm0-280v-120h640v120H160Z" /> | ||
</svg> | ||
); | ||
}; | ||
|
||
export default EqualsIcon; |
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
Oops, something went wrong.