ReadReplicas.utils.ts63 lines · main
| 1 | import { REPLICA_STATUS } from '@/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration.constants' |
| 2 | import { ReplicaInitializationStatus } from '@/data/read-replicas/replicas-status-query' |
| 3 | |
| 4 | export const getIsInTransition = ({ |
| 5 | initStatus, |
| 6 | status, |
| 7 | }: { |
| 8 | initStatus?: string |
| 9 | status?: string |
| 10 | }) => { |
| 11 | return ( |
| 12 | ( |
| 13 | [ |
| 14 | REPLICA_STATUS.UNKNOWN, |
| 15 | REPLICA_STATUS.COMING_UP, |
| 16 | REPLICA_STATUS.GOING_DOWN, |
| 17 | REPLICA_STATUS.RESTORING, |
| 18 | REPLICA_STATUS.RESTARTING, |
| 19 | REPLICA_STATUS.RESIZING, |
| 20 | REPLICA_STATUS.INIT_READ_REPLICA, |
| 21 | ] as string[] |
| 22 | ).includes(status ?? '') || initStatus === ReplicaInitializationStatus.InProgress |
| 23 | ) |
| 24 | } |
| 25 | |
| 26 | export const getStatusLabel = ({ |
| 27 | initStatus, |
| 28 | status, |
| 29 | }: { |
| 30 | initStatus?: string |
| 31 | status?: string |
| 32 | }) => { |
| 33 | if ( |
| 34 | initStatus === ReplicaInitializationStatus.InProgress || |
| 35 | status === REPLICA_STATUS.COMING_UP || |
| 36 | status === REPLICA_STATUS.UNKNOWN || |
| 37 | status === REPLICA_STATUS.INIT_READ_REPLICA |
| 38 | ) { |
| 39 | return 'Coming up' |
| 40 | } |
| 41 | |
| 42 | if ( |
| 43 | initStatus === ReplicaInitializationStatus.Failed || |
| 44 | status === REPLICA_STATUS.INIT_READ_REPLICA_FAILED |
| 45 | ) { |
| 46 | return 'Failed' |
| 47 | } |
| 48 | |
| 49 | switch (status) { |
| 50 | case REPLICA_STATUS.GOING_DOWN: |
| 51 | return 'Going down' |
| 52 | case REPLICA_STATUS.RESTARTING: |
| 53 | return 'Restarting' |
| 54 | case REPLICA_STATUS.RESIZING: |
| 55 | return 'Resizing' |
| 56 | case REPLICA_STATUS.RESTORING: |
| 57 | return 'Restoring' |
| 58 | case REPLICA_STATUS.ACTIVE_HEALTHY: |
| 59 | return 'Healthy' |
| 60 | default: |
| 61 | return 'Unhealthy' |
| 62 | } |
| 63 | } |