|
1 |
| -import * as React from 'react'; |
2 | 1 | import { K8sResourceKind } from '@openshift-console/dynamic-plugin-sdk';
|
3 | 2 |
|
4 |
| -import Status from '@openshift-console/dynamic-plugin-sdk/lib/app/components/status/Status'; |
5 |
| -//import { useTranslation } from "react-i18next"; |
| 3 | +export const CamelIntegrationStatuses = ['Succeeded', 'Failed', 'Unknown'] as const; |
6 | 4 |
|
7 |
| -const CamelIntegrationStatus = ({ camelInt }: { camelInt: K8sResourceKind }) => { |
8 |
| - // Use translated values for Succeded and Failed |
9 |
| - //const { t } = useTranslation('plugin__camel-openshift-console-plugin'); |
| 5 | +export type CamelIntegrationStatuses = typeof CamelIntegrationStatuses[number]; |
10 | 6 |
|
| 7 | +export const CamelIntegrationStatusValue = ( |
| 8 | + camelInt: K8sResourceKind, |
| 9 | +): CamelIntegrationStatuses => { |
11 | 10 | if (camelInt.kind == 'Deployment' || camelInt.kind == 'DeploymentConfig') {
|
12 |
| - return ( |
13 |
| - <Status |
14 |
| - title={`${camelInt.status.availableReplicas} of ${camelInt.status.replicas} pods`} |
15 |
| - status={ |
16 |
| - camelInt.status.availableReplicas === camelInt.status.replicas ? 'Succeeded' : 'Failed' |
17 |
| - } |
18 |
| - /> |
19 |
| - ); |
20 |
| - } else if (camelInt.kind == 'CronJob') { |
21 |
| - return ( |
22 |
| - <Status |
23 |
| - title={`${camelInt.status.lastSuccessfulTime}`} |
24 |
| - status={camelInt.status.lastSuccessfulTime ? 'Succeeded' : 'Failed'} |
25 |
| - /> |
26 |
| - ); |
| 11 | + return camelInt.status.availableReplicas === camelInt.status.replicas ? 'Succeeded' : 'Failed'; |
27 | 12 | }
|
| 13 | + |
| 14 | + if (camelInt.kind == 'CronJob') { |
| 15 | + return camelInt.status.lastSuccessfulTime ? 'Succeeded' : 'Failed'; |
| 16 | + } |
| 17 | + |
| 18 | + return 'Unknown'; |
28 | 19 | };
|
29 | 20 |
|
30 |
| -export default CamelIntegrationStatus; |
| 21 | +export const CamelIntegrationStatusTitle = (camelInt: K8sResourceKind): string => { |
| 22 | + if (camelInt.kind == 'Deployment' || camelInt.kind == 'DeploymentConfig') { |
| 23 | + return camelInt.status.availableReplicas + ' of ' + camelInt.status.replicas + ' pods'; |
| 24 | + } |
| 25 | + |
| 26 | + if (camelInt.kind == 'CronJob') { |
| 27 | + return camelInt.status.lastSuccessfulTime; |
| 28 | + } |
| 29 | + |
| 30 | + return 'Unknown'; |
| 31 | +}; |
0 commit comments