NoDataSourceCallToAction.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { css } from '@emotion/css';
  2. import React from 'react';
  3. import { LinkButton, CallToActionCard, Icon, useTheme2 } from '@grafana/ui';
  4. import { contextSrv } from 'app/core/core';
  5. import { AccessControlAction } from 'app/types';
  6. export const NoDataSourceCallToAction = () => {
  7. const theme = useTheme2();
  8. const canCreateDataSource =
  9. contextSrv.hasPermission(AccessControlAction.DataSourcesCreate) &&
  10. contextSrv.hasPermission(AccessControlAction.DataSourcesWrite);
  11. const message =
  12. 'Explore requires at least one data source. Once you have added a data source, you can query it here.';
  13. const footer = (
  14. <>
  15. <Icon name="rocket" />
  16. <> ProTip: You can also define data sources through configuration files. </>
  17. <a
  18. href="http://docs.grafana.org/administration/provisioning/#datasources?utm_source=explore"
  19. target="_blank"
  20. rel="noreferrer"
  21. className="text-link"
  22. >
  23. Learn more
  24. </a>
  25. </>
  26. );
  27. const ctaElement = (
  28. <LinkButton size="lg" href="datasources/new" icon="database" disabled={!canCreateDataSource}>
  29. Add data source
  30. </LinkButton>
  31. );
  32. const cardClassName = css`
  33. max-width: ${theme.breakpoints.values.lg}px;
  34. margin-top: ${theme.spacing(2)};
  35. align-self: center;
  36. `;
  37. return (
  38. <CallToActionCard callToActionElement={ctaElement} className={cardClassName} footer={footer} message={message} />
  39. );
  40. };