From d778d5843c92411bb7cef990ad935ee94c191824 Mon Sep 17 00:00:00 2001 From: Ted Adams Date: Tue, 1 Nov 2022 10:33:09 -0700 Subject: [PATCH] Fix header wrapping in safari. Add tooltip to type/severity row icons --- apollo/ui/src/components/Overview.tsx | 5 +- apollo/ui/src/components/Root.tsx | 4 + apollo/ui/src/components/ShowErrata.tsx | 2 +- apollo/ui/src/enumToText.tsx | 226 ++++++++++++------------ 4 files changed, 118 insertions(+), 119 deletions(-) diff --git a/apollo/ui/src/components/Overview.tsx b/apollo/ui/src/components/Overview.tsx index 3cd58b09..3e589769 100644 --- a/apollo/ui/src/components/Overview.tsx +++ b/apollo/ui/src/components/Overview.tsx @@ -34,7 +34,6 @@ import { AddIcon, ArrowLeftIcon, ArrowRightIcon, - ChevronDownIcon, MinusIcon, SearchIcon, } from '@chakra-ui/icons'; @@ -69,7 +68,6 @@ import { import { severityToBadge, severityToText, - typeToBadge, typeToText, } from 'apollo/ui/src/enumToText'; import { @@ -77,7 +75,6 @@ import { ListAdvisoriesFiltersTypeEnum, } from 'bazel-bin/apollo/proto/v1/client_typescript'; import { - AdvisorySeverity, V1Advisory, V1AdvisoryType, } from 'bazel-bin/apollo/proto/v1/client_typescript/models'; @@ -432,7 +429,7 @@ export const Overview = () => { textAlign="center" pr={0} > - {severityToBadge(a.severity)} + {severityToBadge(a.severity, a.type)} { alignItems="stretch" > { Product Errata @@ -80,6 +83,7 @@ export const Root = () => { { spacing="6" mb={2} > - {severityToBadge(errata.severity, 40)} + {severityToBadge(errata.severity, errata.type, 40)} diff --git a/apollo/ui/src/enumToText.tsx b/apollo/ui/src/enumToText.tsx index b06ac7ad..8fcb848f 100644 --- a/apollo/ui/src/enumToText.tsx +++ b/apollo/ui/src/enumToText.tsx @@ -30,7 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -import { Box, Tag, TagProps } from '@chakra-ui/react'; +import { Box, Tag, TagProps, Tooltip } from '@chakra-ui/react'; import { AdvisorySeverity, V1AdvisoryType, @@ -53,106 +53,119 @@ export const severityToText = (severity?: AdvisorySeverity): string => { }; export const severityToBadge = ( - severity?: AdvisorySeverity, + severity: AdvisorySeverity | undefined, + type: V1AdvisoryType | undefined, size: number = 20 ): React.ReactNode => { - return { - [AdvisorySeverity.Critical]: ( - - - - - - - ), - [AdvisorySeverity.Important]: ( - - - - - - - ), - [AdvisorySeverity.Moderate]: ( - - - - - ), - [AdvisorySeverity.Low]: ( - - - - - - - ), - [AdvisorySeverity.Unknown]: ( - - - - - - - - ), - }[severity || AdvisorySeverity.Unknown]; + return ( + + { + { + [AdvisorySeverity.Critical]: ( + + + + + + + ), + [AdvisorySeverity.Important]: ( + + + + + + + ), + [AdvisorySeverity.Moderate]: ( + + + + + ), + [AdvisorySeverity.Low]: ( + + + + + + + ), + [AdvisorySeverity.Unknown]: ( + + + + + + + + ), + }[severity || AdvisorySeverity.Unknown] + } + + ); }; export const typeToText = (type?: V1AdvisoryType): string => { @@ -167,18 +180,3 @@ export const typeToText = (type?: V1AdvisoryType): string => { return 'Unknown'; } }; - -export const typeToBadge = ( - type?: V1AdvisoryType, - size: TagProps['size'] = 'sm' -): React.ReactNode => { - return ( - - {typeToText(type)} - - ); -};