forked from konveyor/tackle2-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🌱 1236 - changes to StatusIcon (now IconedStatus) (konveyor#1250)
closes konveyor#1236 --------- Signed-off-by: gitdallas <[email protected]>
- Loading branch information
Showing
13 changed files
with
170 additions
and
200 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
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
106 changes: 106 additions & 0 deletions
106
client/src/app/shared/components/iconed-status/iconed-status.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,106 @@ | ||
import React from "react"; | ||
import { Flex, FlexItem, Icon } from "@patternfly/react-core"; | ||
import { useTranslation } from "react-i18next"; | ||
import CheckCircleIcon from "@patternfly/react-icons/dist/esm/icons/check-circle-icon"; | ||
import TimesCircleIcon from "@patternfly/react-icons/dist/esm/icons/times-circle-icon"; | ||
import InProgressIcon from "@patternfly/react-icons/dist/esm/icons/in-progress-icon"; | ||
import ExclamationCircleIcon from "@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon"; | ||
import UnknownIcon from "@patternfly/react-icons/dist/esm/icons/unknown-icon"; | ||
|
||
export type IconedStatusPreset = | ||
| "Canceled" | ||
| "Completed" | ||
| "Error" | ||
| "Failed" | ||
| "InProgress" | ||
| "NotStarted" | ||
| "Ok" | ||
| "Scheduled" | ||
| "Unknown"; | ||
|
||
export type IconedStatusStatusType = | ||
| "custom" | ||
| "info" | ||
| "success" | ||
| "warning" | ||
| "danger"; | ||
|
||
type IconedStatusPresetType = { | ||
[key in IconedStatusPreset]: Omit<IIconedStatusProps, "preset">; | ||
}; | ||
|
||
export interface IIconedStatusProps { | ||
preset?: IconedStatusPreset; | ||
status?: IconedStatusStatusType; | ||
icon?: React.ReactNode; | ||
className?: string; | ||
label?: React.ReactNode | string; | ||
} | ||
|
||
export const IconedStatus: React.FC<IIconedStatusProps> = ({ | ||
preset, | ||
status, | ||
icon, | ||
className = "", | ||
label, | ||
}: IIconedStatusProps) => { | ||
const { t } = useTranslation(); | ||
const presets: IconedStatusPresetType = { | ||
Canceled: { | ||
icon: <TimesCircleIcon />, | ||
status: "info", | ||
label: t("terms.canceled"), | ||
}, | ||
Completed: { | ||
icon: <CheckCircleIcon />, | ||
status: "success", | ||
label: t("terms.completed"), | ||
}, | ||
Error: { | ||
icon: <ExclamationCircleIcon />, | ||
status: "danger", | ||
label: t("terms.error"), | ||
}, | ||
Failed: { | ||
icon: <ExclamationCircleIcon />, | ||
status: "danger", | ||
label: t("terms.failed"), | ||
}, | ||
InProgress: { | ||
icon: <InProgressIcon />, | ||
status: "info", | ||
label: t("terms.inProgress"), | ||
}, | ||
NotStarted: { | ||
icon: <TimesCircleIcon />, | ||
label: t("terms.notStarted"), | ||
}, | ||
Ok: { | ||
icon: <CheckCircleIcon />, | ||
status: "success", | ||
}, | ||
Scheduled: { | ||
icon: <InProgressIcon />, | ||
status: "info", | ||
label: t("terms.scheduled"), | ||
}, | ||
Unknown: { | ||
icon: <UnknownIcon />, | ||
}, | ||
}; | ||
const presetProps = preset && presets[preset]; | ||
|
||
return ( | ||
<Flex | ||
flexWrap={{ default: "nowrap" }} | ||
spaceItems={{ default: "spaceItemsSm" }} | ||
> | ||
<FlexItem> | ||
<Icon status={status || presetProps?.status} className={className}> | ||
{icon || presetProps?.icon || <UnknownIcon />} | ||
</Icon> | ||
</FlexItem> | ||
<FlexItem>{label || presetProps?.label}</FlexItem> | ||
</Flex> | ||
); | ||
}; |
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 @@ | ||
export * from "./iconed-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
4 changes: 2 additions & 2 deletions
4
...ts/status-icon/tests/status-icon.test.tsx → .../iconed-status/tests/status-icon.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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { render } from "@app/test-config/test-utils"; | ||
import React from "react"; | ||
import { StatusIcon } from "../status-icon"; | ||
import { IconedStatus } from "../iconed-status"; | ||
|
||
describe("StatusIcon", () => { | ||
it("Renders without crashing", () => { | ||
const wrapper = render(<StatusIcon status="NotStarted" />); | ||
const wrapper = render(<IconedStatus preset="NotStarted" />); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
}); |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.