Files
grafana/public/app/features/auth-config/components/ProviderCard.tsx
Misi 74d7cd2cad Auth: Add name to be configurable from the UI (#82144)
* Add name to be configurable from the UI

* Update public/app/features/auth-config/ProviderConfigPage.tsx

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>

* Align test

---------

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
2024-02-08 13:33:47 +01:00

36 lines
1.0 KiB
TypeScript

import React from 'react';
import { isIconName } from '@grafana/data';
import { Badge, Card, Icon } from '@grafana/ui';
import { UIMap } from '../constants';
import { getProviderUrl } from '../utils/url';
type Props = {
providerId: string;
enabled: boolean;
configPath?: string;
authType?: string;
onClick?: () => void;
};
export function ProviderCard({ providerId, enabled, configPath, authType, onClick }: Props) {
//@ts-expect-error
const url = getProviderUrl({ configPath, id: providerId });
const [iconName, displayName] = UIMap[providerId] || ['lock', providerId.toUpperCase()];
return (
<Card href={url} onClick={onClick}>
<Card.Heading>{displayName}</Card.Heading>
<Card.Meta>{authType}</Card.Meta>
{isIconName(iconName) && (
<Card.Figure>
<Icon name={iconName} size={'xxxl'} />
</Card.Figure>
)}
<Card.Actions>
<Badge text={enabled ? 'Enabled' : 'Not enabled'} color={enabled ? 'green' : 'blue'} />
</Card.Actions>
</Card>
);
}