-
Notifications
You must be signed in to change notification settings - Fork 86
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: Kevin Cormier <[email protected]>
- Loading branch information
1 parent
213bcff
commit 03a8443
Showing
3 changed files
with
2 additions
and
203 deletions.
There are no files selected for viewing
28 changes: 0 additions & 28 deletions
28
frontend/src/ui-components/AcmProvider/AcmProviderCard/AcmProviderCard.stories.tsx
This file was deleted.
Oops, something went wrong.
59 changes: 0 additions & 59 deletions
59
frontend/src/ui-components/AcmProvider/AcmProviderCard/AcmProviderCard.test.tsx
This file was deleted.
Oops, something went wrong.
118 changes: 2 additions & 116 deletions
118
frontend/src/ui-components/AcmProvider/AcmProviderCard/AcmProviderCard.tsx
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,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" /> | ||
} |