Skip to content

Commit

Permalink
WIP Remove AcmProviderCard
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Cormier <[email protected]>
  • Loading branch information
KevinFCormier committed Nov 13, 2024
1 parent 213bcff commit 03a8443
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 203 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,121 +1,7 @@
/* Copyright Contributors to the Open Cluster Management project */

import { css } from '@emotion/css'
import {
Card,
CardFooter,
CardHeader,
Gallery,
GalleryItem,
Icon,
Stack,
StackItem,
Text,
TextVariants,
Title,
} from '@patternfly/react-core'
import { ExclamationCircleIcon } from '@patternfly/react-icons'
import { Provider, ProviderIconMap, ProviderShortTextMap } from '../'
import { Trans, useTranslation } from '../../../lib/acm-i18next'
import { AddCluster } from '../../../routes/Infrastructure/Clusters/ManagedClusters/components/AddCluster'
import { AcmEmptyState } from '../../AcmEmptyState'
import { AcmIcon } from '../../AcmIcons/AcmIcons'

const icon = css({
'& svg, & img': {
width: '56px',
height: '56px',
},
})
const providerTitle = css({
marginTop: '4px',
fontSize: 'var(--pf-v5-c-title--m-3xl--FontSize)',
lineHeight: 'var(--pf-v5-c-title--m-3xl--LineHeight)',
})
const dangerIcon = css({
width: '16px',
height: '16px',
marginLeft: '8px',
verticalAlign: 'unset !important',
})
const clusterCount = css({
fontSize: '28px',
})
const clusterText = css({
fontSize: '14px',
fontWeight: 600,
})

type ProviderCardProps = {
provider: Provider
clusterCount: number | undefined
onClick: (provider: string) => void
danger?: boolean
isSelected?: boolean
}

export function AcmOverviewProviders(props: { providers: ProviderCardProps[] }) {
const { t } = useTranslation()
if (props.providers.length === 0) {
return (
<AcmEmptyState
title={t('managed.emptyStateHeader')}
message={<Trans i18nKey="managed.emptyStateMsg" components={{ bold: <strong /> }} />}
action={<AddCluster type="button" />}
/>
)
}
return (
<Gallery hasGutter>
{props.providers.map((provider) => (
<GalleryItem key={provider.provider}>
<AcmProviderCard {...provider} />
</GalleryItem>
))}
</Gallery>
)
}

export function AcmProviderCard(props: ProviderCardProps) {
const { t } = useTranslation()
return (
<Card
onClick={() => props.onClick(props.provider)}
onKeyDown={(event: React.KeyboardEvent) => [13, 32].includes(event.keyCode) && props.onClick(props.provider)}
isSelectable
isSelected={props.isSelected}
id={`${props.provider}-provider-card`}
>
<Stack>
<StackItem>
<CardHeader>
<>
<div className={icon}>
<AcmIcon icon={ProviderIconMap[props.provider]} />
</div>
<Title headingLevel="h2" size="3xl" className={providerTitle} style={{ fontWeight: 300 }}>
{ProviderShortTextMap[props.provider]}
{props.danger && (
<Icon status="danger">
<ExclamationCircleIcon className={dangerIcon} />
</Icon>
)}
</Title>
</>
</CardHeader>
</StackItem>
<StackItem isFilled></StackItem>
<StackItem>
<CardFooter>
<Text component={TextVariants.p} className={clusterCount}>
{props.clusterCount}
</Text>
<Text component={TextVariants.p} className={clusterText}>
{props.clusterCount === 1 ? t('Cluster') : t('Clusters')}
</Text>
</CardFooter>
</StackItem>
</Stack>
</Card>
)
export function AcmOverviewProviders() {
return <AddCluster type="button" />
}

0 comments on commit 03a8443

Please sign in to comment.