2024-02-08 06:33:47 -06:00
|
|
|
import { isIconName } from '@grafana/data';
|
2023-11-29 11:09:36 -06:00
|
|
|
import { Badge, Card, Icon } from '@grafana/ui';
|
2023-04-13 09:07:43 -05:00
|
|
|
|
2024-02-08 06:33:47 -06:00
|
|
|
import { UIMap } from '../constants';
|
2023-12-21 07:26:42 -06:00
|
|
|
import { getProviderUrl } from '../utils/url';
|
2023-04-13 09:07:43 -05:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
providerId: string;
|
|
|
|
enabled: boolean;
|
|
|
|
configPath?: string;
|
|
|
|
authType?: string;
|
2023-06-29 09:42:52 -05:00
|
|
|
onClick?: () => void;
|
2023-04-13 09:07:43 -05:00
|
|
|
};
|
|
|
|
|
2023-11-29 11:09:36 -06:00
|
|
|
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()];
|
2023-04-13 09:07:43 -05:00
|
|
|
return (
|
2023-11-29 11:09:36 -06:00
|
|
|
<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>
|
2023-04-13 09:07:43 -05:00
|
|
|
</Card>
|
|
|
|
);
|
|
|
|
}
|