diff --git a/public/app/features/provisioning/Repository/RepositoryCard.tsx b/public/app/features/provisioning/Repository/RepositoryCard.tsx index e56f8655eb9..488a5afbc66 100644 --- a/public/app/features/provisioning/Repository/RepositoryCard.tsx +++ b/public/app/features/provisioning/Repository/RepositoryCard.tsx @@ -1,9 +1,10 @@ import { ReactNode } from 'react'; import { Trans } from '@grafana/i18n'; -import { IconName, Stack, Text, TextLink, Icon, Card, LinkButton } from '@grafana/ui'; +import { Stack, Text, TextLink, Icon, Card, LinkButton } from '@grafana/ui'; import { Repository, ResourceCount } from 'app/api/clients/provisioning/v0alpha1'; +import { RepoIcon } from '../Shared/RepoIcon'; import { StatusBadge } from '../Shared/StatusBadge'; import { PROVISIONING_URL } from '../constants'; @@ -53,14 +54,10 @@ export function RepositoryCard({ repository }: Props) { return meta; }; - const getRepositoryIcon = (): IconName => { - return spec?.type === 'github' ? 'github' : 'database'; - }; - return ( - + diff --git a/public/app/features/provisioning/Shared/RepoIcon.tsx b/public/app/features/provisioning/Shared/RepoIcon.tsx new file mode 100644 index 00000000000..7840bbccf12 --- /dev/null +++ b/public/app/features/provisioning/Shared/RepoIcon.tsx @@ -0,0 +1,34 @@ +import { css } from '@emotion/css'; + +import { Icon, useStyles2 } from '@grafana/ui'; +import { getSvgSize } from '@grafana/ui/internal'; + +import { RepoType } from '../Wizard/types'; +import { getRepositoryTypeConfig } from '../utils/repositoryTypes'; + +export function RepoIcon({ type }: { type: RepoType | undefined }) { + const styles = useStyles2(getStyles); + const config = type ? getRepositoryTypeConfig(type) : undefined; + + if (!config) { + return ; + } + return ( + <> + {config.logo ? ( + {config.label} + ) : ( + + )} + + ); +} + +function getStyles() { + return { + logo: css({ + width: getSvgSize('xxl'), + height: getSvgSize('xxl'), + }), + }; +} diff --git a/public/app/features/provisioning/Shared/RepositoryTypeCards.tsx b/public/app/features/provisioning/Shared/RepositoryTypeCards.tsx index 7eab2d894a3..0fefc098673 100644 --- a/public/app/features/provisioning/Shared/RepositoryTypeCards.tsx +++ b/public/app/features/provisioning/Shared/RepositoryTypeCards.tsx @@ -1,12 +1,14 @@ import { css } from '@emotion/css'; import { Trans } from '@grafana/i18n'; -import { Card, Icon, Stack, Text, useStyles2 } from '@grafana/ui'; +import { Card, Stack, Text, useStyles2 } from '@grafana/ui'; import { useGetFrontendSettingsQuery } from 'app/api/clients/provisioning/v0alpha1/endpoints.gen'; import { CONNECT_URL, DEFAULT_REPOSITORY_TYPES } from '../constants'; import { getOrderedRepositoryConfigs } from '../utils/repositoryTypes'; +import { RepoIcon } from './RepoIcon'; + export function RepositoryTypeCards() { const styles = useStyles2(getStyles); const { data: frontendSettings } = useGetFrontendSettingsQuery(); @@ -26,11 +28,7 @@ export function RepositoryTypeCards() { {gitProviders.map((config) => ( - {config.logo ? ( - {config.label} - ) : ( - - )} + ( - {config.logo ? ( - {config.label} - ) : ( - - )} + {config.type === 'local' ? ( Configure file provisioning ) : ( @@ -84,9 +78,5 @@ function getStyles() { card: css({ width: 220, }), - logo: css({ - width: 36, - height: 36, - }), }; }