DataSourcesList.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Libraries
  2. import { css } from '@emotion/css';
  3. import React, { FC } from 'react';
  4. // Types
  5. import { DataSourceSettings, LayoutMode } from '@grafana/data';
  6. import { Card, Tag, useStyles } from '@grafana/ui';
  7. export interface Props {
  8. dataSources: DataSourceSettings[];
  9. layoutMode: LayoutMode;
  10. }
  11. export const DataSourcesList: FC<Props> = ({ dataSources, layoutMode }) => {
  12. const styles = useStyles(getStyles);
  13. return (
  14. <ul className={styles.list}>
  15. {dataSources.map((dataSource) => {
  16. return (
  17. <li key={dataSource.id}>
  18. <Card href={`datasources/edit/${dataSource.uid}`}>
  19. <Card.Heading>{dataSource.name}</Card.Heading>
  20. <Card.Figure>
  21. <img src={dataSource.typeLogoUrl} alt="" height="40px" width="40px" className={styles.logo} />
  22. </Card.Figure>
  23. <Card.Meta>
  24. {[
  25. dataSource.typeName,
  26. dataSource.url,
  27. dataSource.isDefault && <Tag key="default-tag" name={'default'} colorIndex={1} />,
  28. ]}
  29. </Card.Meta>
  30. </Card>
  31. </li>
  32. );
  33. })}
  34. </ul>
  35. );
  36. };
  37. export default DataSourcesList;
  38. const getStyles = () => {
  39. return {
  40. list: css({
  41. listStyle: 'none',
  42. display: 'grid',
  43. // gap: '8px', Add back when legacy support for old Card interface is dropped
  44. }),
  45. logo: css({
  46. objectFit: 'contain',
  47. }),
  48. };
  49. };