Provisioning: Hide other providers if empty (#110652)
This commit is contained in:
@@ -4,7 +4,7 @@ import { Trans } from '@grafana/i18n';
|
||||
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 { CONNECT_URL } from '../constants';
|
||||
import { getOrderedRepositoryConfigs } from '../utils/repositoryTypes';
|
||||
|
||||
import { RepoIcon } from './RepoIcon';
|
||||
@@ -13,7 +13,7 @@ export function RepositoryTypeCards() {
|
||||
const styles = useStyles2(getStyles);
|
||||
const { data: frontendSettings } = useGetFrontendSettingsQuery();
|
||||
|
||||
const availableTypes = frontendSettings?.availableRepositoryTypes || DEFAULT_REPOSITORY_TYPES;
|
||||
const availableTypes = frontendSettings?.availableRepositoryTypes ?? [];
|
||||
const { gitProviders, otherProviders } = getOrderedRepositoryConfigs(availableTypes);
|
||||
|
||||
return (
|
||||
@@ -42,33 +42,37 @@ export function RepositoryTypeCards() {
|
||||
</Stack>
|
||||
)}
|
||||
|
||||
<Stack direction="column">
|
||||
<Text variant="bodySmall" color="secondary">
|
||||
<Trans i18nKey="provisioning.repository-type-cards.provider-not-listed">
|
||||
If your provider is not listed:
|
||||
</Trans>
|
||||
</Text>
|
||||
{otherProviders.length > 0 && (
|
||||
<Stack direction="column">
|
||||
<Text variant="bodySmall" color="secondary">
|
||||
<Trans i18nKey="provisioning.repository-type-cards.provider-not-listed">
|
||||
If your provider is not listed:
|
||||
</Trans>
|
||||
</Text>
|
||||
|
||||
<Stack direction="row" gap={1} wrap>
|
||||
{otherProviders.map((config) => (
|
||||
<Card key={config.type} href={`${CONNECT_URL}/${config.type}`} className={styles.card} noMargin>
|
||||
<Stack gap={2} alignItems="center">
|
||||
<RepoIcon type={config.type} />
|
||||
{config.type === 'local' ? (
|
||||
<Trans i18nKey="provisioning.repository-type-cards.configure-file">Configure file provisioning</Trans>
|
||||
) : (
|
||||
<Trans
|
||||
i18nKey="provisioning.repository-type-cards.configure-with-provider"
|
||||
values={{ provider: config.label }}
|
||||
>
|
||||
Configure with {'{{ provider }}'}
|
||||
</Trans>
|
||||
)}
|
||||
</Stack>
|
||||
</Card>
|
||||
))}
|
||||
<Stack direction="row" gap={1} wrap>
|
||||
{otherProviders.map((config) => (
|
||||
<Card key={config.type} href={`${CONNECT_URL}/${config.type}`} className={styles.card} noMargin>
|
||||
<Stack gap={2} alignItems="center">
|
||||
<RepoIcon type={config.type} />
|
||||
{config.type === 'local' ? (
|
||||
<Trans i18nKey="provisioning.repository-type-cards.configure-file">
|
||||
Configure file provisioning
|
||||
</Trans>
|
||||
) : (
|
||||
<Trans
|
||||
i18nKey="provisioning.repository-type-cards.configure-with-provider"
|
||||
values={{ provider: config.label }}
|
||||
>
|
||||
Configure with {'{{ provider }}'}
|
||||
</Trans>
|
||||
)}
|
||||
</Stack>
|
||||
</Card>
|
||||
))}
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Stack>
|
||||
)}
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user