-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d3d55bb
commit e896632
Showing
26 changed files
with
805 additions
and
85 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
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,21 @@ | ||
import React from "react"; | ||
import ErrorState from "@patternfly/react-component-groups/dist/esm/ErrorState"; | ||
import { Bullseye, Spinner } from "@patternfly/react-core"; | ||
|
||
export const LoadingWrapper = (props: { | ||
isFetching: boolean; | ||
fetchError?: Error; | ||
children: React.ReactNode; | ||
}) => { | ||
if (props.isFetching) { | ||
return ( | ||
<Bullseye> | ||
<Spinner /> | ||
</Bullseye> | ||
); | ||
} else if (props.fetchError) { | ||
return <ErrorState errorTitle="Error" />; | ||
} else { | ||
return props.children; | ||
} | ||
}; |
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
30 changes: 30 additions & 0 deletions
30
frontend/client/src/app/components/SeverityProgressBar.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,30 @@ | ||
import React from "react"; | ||
|
||
import { Progress } from "@patternfly/react-core"; | ||
|
||
import { severityFromNumber, severityList } from "@app/api/model-utils"; | ||
|
||
interface SeverityRendererProps { | ||
value: number; | ||
showLabel?: boolean; | ||
} | ||
|
||
export const SeverityProgressBar: React.FC<SeverityRendererProps> = ({ | ||
value, | ||
}) => { | ||
const severityType = severityFromNumber(value); | ||
const severityProps = severityList[severityType]; | ||
|
||
return ( | ||
<> | ||
<Progress | ||
aria-labelledby="severity" | ||
size="sm" | ||
max={10} | ||
value={value} | ||
label={`${value}/10`} | ||
{...severityProps.progressProps} | ||
/> | ||
</> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
frontend/client/src/app/components/SeverityShieldAndText.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,46 @@ | ||
import React from "react"; | ||
|
||
import { Flex, FlexItem } from "@patternfly/react-core"; | ||
import ShieldIcon from "@patternfly/react-icons/dist/esm/icons/shield-alt-icon"; | ||
|
||
import { severityFromNumber, severityList } from "@app/api/model-utils"; | ||
import { Severity } from "@app/api/models"; | ||
|
||
interface SeverityShieldAndTextProps { | ||
value: Severity | number; | ||
showLabel?: boolean; | ||
} | ||
|
||
export const SeverityShieldAndText: React.FC<SeverityShieldAndTextProps> = ({ | ||
value, | ||
showLabel, | ||
}) => { | ||
let severity: Severity; | ||
if (typeof value === "number") { | ||
severity = severityFromNumber(value); | ||
} else { | ||
severity = value; | ||
} | ||
|
||
const severityProps = severityList[severity]; | ||
|
||
return ( | ||
<> | ||
<Flex | ||
spaceItems={{ default: "spaceItemsXs" }} | ||
alignItems={{ default: "alignItemsCenter" }} | ||
flexWrap={{ default: "nowrap" }} | ||
style={{ whiteSpace: "nowrap" }} | ||
> | ||
<FlexItem> | ||
<ShieldIcon color={severityProps.shieldIconColor.value} /> | ||
</FlexItem> | ||
{showLabel && ( | ||
<FlexItem> | ||
{severity.charAt(0).toUpperCase() + severity.slice(1)} | ||
</FlexItem> | ||
)} | ||
</Flex> | ||
</> | ||
); | ||
}; |
22 changes: 22 additions & 0 deletions
22
frontend/client/src/app/components/markdownPFComponents.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,22 @@ | ||
import * as React from "react"; | ||
import { Components } from "react-markdown"; | ||
import { CodeBlock, CodeBlockCode, Text } from "@patternfly/react-core"; | ||
import spacing from "@patternfly/react-styles/css/utilities/Spacing/spacing"; | ||
|
||
export const markdownPFComponents: Components = { | ||
h1: (props) => <Text component="h1" {...props} />, | ||
h2: (props) => <Text component="h2" {...props} />, | ||
h3: (props) => <Text component="h3" {...props} />, | ||
h4: (props) => <Text component="h4" {...props} />, | ||
h5: (props) => <Text component="h5" {...props} />, | ||
h6: (props) => <Text component="h6" {...props} />, | ||
p: (props) => <Text component="p" {...props} />, | ||
a: (props) => <Text component="a" {...props} />, | ||
small: (props) => <Text component="small" {...props} />, | ||
blockquote: (props) => <Text component="blockquote" {...props} />, | ||
pre: (props) => ( | ||
<CodeBlock className={spacing.mbMd}> | ||
<CodeBlockCode {...props} /> | ||
</CodeBlock> | ||
), | ||
}; |
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,29 @@ | ||
import React from "react"; | ||
|
||
import { Text, TextContent } from "@patternfly/react-core"; | ||
import ReactMarkdown from "react-markdown"; | ||
import spacing from "@patternfly/react-styles/css/utilities/Spacing/spacing"; | ||
import { markdownPFComponents } from "./markdownPFComponents"; | ||
|
||
interface NotesMarkdownProps { | ||
isCompact?: boolean; | ||
notes: { | ||
category: string; | ||
text: string; | ||
title: string; | ||
}[]; | ||
} | ||
|
||
export const NotesMarkdown: React.FC<NotesMarkdownProps> = ({ | ||
isCompact, | ||
notes, | ||
}) => { | ||
return notes.map((e, index) => ( | ||
<TextContent key={index} className={spacing.mbMd}> | ||
<Text component={isCompact ? "h4" : "h1"}> | ||
{e.title} ({e.category.replace("_", " ")}) | ||
</Text> | ||
<ReactMarkdown components={markdownPFComponents}>{e.text}</ReactMarkdown> | ||
</TextContent> | ||
)); | ||
}; |
Oops, something went wrong.