-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* show tls automation status * handle unknown statuses
- Loading branch information
1 parent
2b62c71
commit 3146891
Showing
4 changed files
with
121 additions
and
14 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
51 changes: 51 additions & 0 deletions
51
src/components/status-badges/tls-automation-status-badge.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,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<Pick<StatusBadgeTemplateProps, 'icon' | 'type'> & { text?: string }> | ||
> = { | ||
Pending: { | ||
type: 'warning', | ||
icon: <Icon data={time} />, | ||
text: 'Order In Progress', | ||
}, | ||
Success: { icon: <Icon data={check} />, text: 'Order Successful' }, | ||
Failed: { | ||
type: 'danger', | ||
icon: <Icon data={error_outlined} />, | ||
text: 'Order Failed', | ||
}, | ||
Unknown: { | ||
type: 'warning', | ||
icon: <Icon data={time} />, | ||
text: 'Order Status Unknown', | ||
}, | ||
}; | ||
|
||
type Props = { | ||
status: Status; | ||
}; | ||
export function TLSAutomationStatusBadge({ status }: Props) { | ||
const { type, icon, text } = BadgeTemplates[status]; | ||
|
||
return ( | ||
<StatusBadgeTemplate type={type} icon={icon}> | ||
{text || status} | ||
</StatusBadgeTemplate> | ||
); | ||
} | ||
|
||
TLSAutomationStatusBadge.propTypes = { | ||
status: PropTypes.string.isRequired as PropTypes.Validator<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