ReadReplicas.utils.ts 1.6 KB

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