diff --git a/src/components/external-dns-list/index.tsx b/src/components/external-dns-list/index.tsx index 935eb4d74..2f23ef92b 100644 --- a/src/components/external-dns-list/index.tsx +++ b/src/components/external-dns-list/index.tsx @@ -8,30 +8,33 @@ import { import * as PropTypes from 'prop-types'; import { Icon, Table, Typography } from '@equinor/eds-core-react'; -import { ExternalDns, Tls } from '../../store/radix-api'; +import { ExternalDns, Tls, TlsAutomation } from '../../store/radix-api'; import { ExternalDNSStatusBadge } from '../status-badges'; -import { check, chevron_down, chevron_up } from '@equinor/eds-icons'; +import { chevron_down, chevron_up } from '@equinor/eds-icons'; import clsx from 'clsx'; import { TLSCertificateList } from '../tls-certificate-list'; import { dataSorter, sortCompareString } from '../../utils/sort-utils'; import { pluraliser } from '../../utils/string'; import { differenceInDays } from 'date-fns'; import { Alert, AlertProps } from '../alert'; +import { TLSAutomationStatusBadge } from '../status-badges/tls-automation-status-badge'; -const AlertTemplates = { +type TlsStatus = Tls['status']; + +const StatusMessageAlertTemplate = { Pending: { type: 'info' }, Consistent: { type: 'info' }, Invalid: { type: 'danger' }, -} satisfies Record; +} satisfies Record; type StatusMessagesProps = { - status: Tls['status']; + status: TlsStatus; messages: Array; }; function StatusMessages({ status, messages }: StatusMessagesProps) { return ( - +
{messages.map((msg, i) => ( {msg} @@ -41,6 +44,33 @@ function StatusMessages({ status, messages }: StatusMessagesProps) { ); } +type AutomationStatus = TlsAutomation['status'] | 'Unknown'; + +const TlsAutomationMessageAlertTemplate = { + Pending: { type: 'warning' }, + Success: { type: 'info' }, + Failed: { type: 'danger' }, + Unknown: { type: 'warning' }, +} satisfies Record; + +type TlsAutomationMessageProps = { + status: AutomationStatus; + message: string; +}; + +function TlsAutomationStatusMessage({ + status, + message, +}: TlsAutomationMessageProps) { + return ( + +
+ {message} +
+
+ ); +} + const dayPluraliser = pluraliser('day', 'days'); export const ExternalDNSList: FunctionComponent<{ @@ -67,7 +97,7 @@ export const ExternalDNSList: FunctionComponent<{ Alias Expires - Status + Certificate Certificate Automation @@ -83,6 +113,7 @@ export const ExternalDNSList: FunctionComponent<{ ? v.tls.certificates[0].notAfter : null, hasMessages: v.tls.statusMessages?.length > 0, + hasAutomationMessage: v.tls.automation?.message?.length > 0, expanded: !!expandedRows[v.fqdn], })) .map( @@ -91,6 +122,7 @@ export const ExternalDNSList: FunctionComponent<{ hasCertificates, certificateExpiry, hasMessages, + hasAutomationMessage, expanded, }) => ( @@ -100,7 +132,9 @@ export const ExternalDNSList: FunctionComponent<{ })} > - {(hasCertificates || hasMessages) && ( + {(hasCertificates || + hasMessages || + hasAutomationMessage) && ( {externalDns.tls.useAutomation && ( - + )} @@ -154,6 +192,14 @@ export const ExternalDNSList: FunctionComponent<{ className="grid grid--gap-medium" style={{ margin: '16px 0' }} > + {hasAutomationMessage && ( + + )} {hasMessages && ( > + Readonly & { text?: string }> > = { - Pending: { type: 'warning', icon: }, - Consistent: { icon: }, + Pending: { type: 'warning', icon: , text: 'Missing' }, + Consistent: { icon: , text: 'Valid' }, Invalid: { type: 'danger', icon: }, }; @@ -24,11 +24,11 @@ type Props = { status: Status; }; export function ExternalDNSStatusBadge({ status }: Props) { - const { type, icon } = BadgeTemplates[status]; + const { type, icon, text } = BadgeTemplates[status]; return ( - {status} + {text || status} ); } diff --git a/src/components/status-badges/tls-automation-status-badge.tsx b/src/components/status-badges/tls-automation-status-badge.tsx new file mode 100644 index 000000000..cc56a4809 --- /dev/null +++ b/src/components/status-badges/tls-automation-status-badge.tsx @@ -0,0 +1,51 @@ +import { Icon } from '@equinor/eds-core-react'; +import { check, error_outlined, time } from '@equinor/eds-icons'; +import * as PropTypes from 'prop-types'; + +import { + StatusBadgeTemplate, + StatusBadgeTemplateProps, +} from './status-badge-template'; + +import { TlsAutomation } from '../../store/radix-api'; + +type Status = TlsAutomation['status'] | 'Unknown'; + +const BadgeTemplates: Record< + Status, + Readonly & { text?: string }> +> = { + Pending: { + type: 'warning', + icon: , + text: 'Order In Progress', + }, + Success: { icon: , text: 'Order Successful' }, + Failed: { + type: 'danger', + icon: , + text: 'Order Failed', + }, + Unknown: { + type: 'warning', + icon: , + text: 'Order Status Unknown', + }, +}; + +type Props = { + status: Status; +}; +export function TLSAutomationStatusBadge({ status }: Props) { + const { type, icon, text } = BadgeTemplates[status]; + + return ( + + {text || status} + + ); +} + +TLSAutomationStatusBadge.propTypes = { + status: PropTypes.string.isRequired as PropTypes.Validator, +}; diff --git a/src/store/radix-api.ts b/src/store/radix-api.ts index b3ef136a5..3c949956c 100644 --- a/src/store/radix-api.ts +++ b/src/store/radix-api.ts @@ -2134,6 +2134,15 @@ export type StopApplicationApiArg = { /** Works only with custom setup of cluster. Allow impersonation of a comma-seperated list of test groups (Required if Impersonate-User is set) */ 'Impersonate-Group'?: string; }; +export type TlsAutomation = { + /** Message is a human readable description of the reason for the status */ + message?: string; + /** Status of certificate automation request + Pending TLSAutomationPending Certificate automation request pending + Success TLSAutomationSuccess Certificate automation request succeeded + Failed TLSAutomationFailed Certificate automation request failed */ + status: 'Pending' | 'Success' | 'Failed'; +}; export type X509Certificate = { /** DNSNames defines list of Subject Alternate Names in the certificate */ dnsNames?: string[]; @@ -2147,6 +2156,7 @@ export type X509Certificate = { subject: string; }; export type Tls = { + automation?: TlsAutomation; /** Certificates holds the X509 certificate chain The first certificate in the list should be the host certificate and the rest should be intermediate certificates */ certificates?: X509Certificate[];