Skip to content

Add StatusIndicator to AMI state inside custom images #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion frontend/src/components/Status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
ComputeFleetStatus,
} from '../types/clusters'
import {InstanceState, Instance, EC2Instance} from '../types/instances'
import {ImageBuildStatus} from '../types/images'
import {Ec2AmiState, ImageBuildStatus} from '../types/images'
import {StackEvent} from '../types/stackevents'
import {JobStateCode} from '../types/jobs'
import capitalize from 'lodash/capitalize'
Expand Down Expand Up @@ -185,11 +185,30 @@ function CustomImageStatusIndicator({
)
}

function AMIStatusIndicator({state}: {state: Ec2AmiState}) {
const statusMap: Record<Ec2AmiState, StatusIndicatorProps.Type> = {
AVAILABLE: 'success',
DEREGISTERED: 'error',
ERROR: 'error',
FAILED: 'error',
INVALID: 'error',
PENDING: 'in-progress',
TRANSIENT: 'in-progress',
}

return (
<StatusIndicator type={statusMap[state]}>
{formatStatus(state)}
</StatusIndicator>
)
}

export {
ClusterStatusIndicator,
ComputeFleetStatusIndicator,
InstanceStatusIndicator,
JobStatusIndicator,
StackEventStatusIndicator,
CustomImageStatusIndicator,
AMIStatusIndicator,
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ import EmptyState from '../../../components/EmptyState'
import {truncate} from 'lodash'
import {ReadonlyConfigView} from '../../../components/ConfigView'
import {extendCollectionsOptions} from '../../../shared/extendCollectionsOptions'
import {CustomImageStatusIndicator} from '../../../components/Status'
import {
AMIStatusIndicator,
CustomImageStatusIndicator,
} from '../../../components/Status'

const customImagesPath = ['app', 'customImages']

Expand Down Expand Up @@ -98,7 +101,9 @@ function CustomImageProperties() {
<ValueWithLabel
label={t('customImages.imageDetails.properties.state')}
>
{image.ec2AmiInfo && image.ec2AmiInfo.state}
{image.ec2AmiInfo && (
<AMIStatusIndicator state={image.ec2AmiInfo.state} />
)}
{!image.ec2AmiInfo && loadingText}
</ValueWithLabel>
</SpaceBetween>
Expand Down