-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Bipul Adhikari <[email protected]>
- Loading branch information
Showing
9 changed files
with
171 additions
and
60 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...ard/status-card/storage-system-popup.scss → ...oard/status-card/status-card-popover.scss
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.odf-storageSystemPopup__item--margin { | ||
.odf-status-card__popup--margin { | ||
// Overriding PF default margin for FlexItem | ||
margin-bottom: 0 !important; | ||
} |
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
60 changes: 60 additions & 0 deletions
60
packages/odf/components/odf-dashboard/status-card/utils.ts
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,60 @@ | ||
import { StorageConsumerKind, StorageConsumerState } from '@odf/shared'; | ||
import { HealthState } from '@openshift-console/dynamic-plugin-sdk'; | ||
import { TFunction } from 'i18next'; | ||
|
||
export const getClientHealthState = ( | ||
client: StorageConsumerKind | ||
): HealthState => { | ||
const state = client.status.state; | ||
let health = HealthState.UNKNOWN; | ||
switch (state) { | ||
case StorageConsumerState.Ready: | ||
health = HealthState.OK; | ||
break; | ||
case StorageConsumerState.Configuring: | ||
case StorageConsumerState.Deleting: | ||
health = HealthState.LOADING; | ||
break; | ||
case StorageConsumerState.Disabled: | ||
case StorageConsumerState.Failed: | ||
health = HealthState.ERROR; | ||
break; | ||
default: | ||
health = HealthState.UNKNOWN; | ||
} | ||
return health; | ||
}; | ||
|
||
export const getAggregateClientHealthState = ( | ||
clients: StorageConsumerKind[] | ||
) => { | ||
const totalConnectedClients = clients.filter( | ||
(client) => client.status.state === StorageConsumerState.Ready | ||
).length; | ||
const total = clients.length; | ||
if (total === totalConnectedClients) { | ||
return HealthState.OK; | ||
} | ||
if (totalConnectedClients === 0 && total > 0) { | ||
return HealthState.ERROR; | ||
} | ||
if (total === 0) { | ||
return HealthState.NOT_AVAILABLE; | ||
} | ||
return HealthState.NOT_AVAILABLE; | ||
}; | ||
|
||
export const getClientText = (clients: StorageConsumerKind[], t: TFunction) => { | ||
const connectedClients = clients.filter( | ||
(client) => client.status.state === StorageConsumerState.Ready | ||
); | ||
const total = clients.length; | ||
if (total === 0) { | ||
return t('0 connected clients'); | ||
} else { | ||
return t('{{connected}} / {{total}} clients connected', { | ||
connected: connectedClients.length, | ||
total, | ||
}); | ||
} | ||
}; |
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
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
Oops, something went wrong.