DashboardActions.tsx 813 B

12345678910111213141516171819202122232425262728293031
  1. import React, { FC } from 'react';
  2. import { HorizontalGroup, LinkButton } from '@grafana/ui';
  3. export interface Props {
  4. folderId?: number;
  5. isEditor: boolean;
  6. canEdit?: boolean;
  7. }
  8. export const DashboardActions: FC<Props> = ({ folderId, isEditor, canEdit }) => {
  9. const actionUrl = (type: string) => {
  10. let url = `dashboard/${type}`;
  11. if (folderId) {
  12. url += `?folderId=${folderId}`;
  13. }
  14. return url;
  15. };
  16. return (
  17. <div>
  18. <HorizontalGroup spacing="md" align="center">
  19. {canEdit && <LinkButton href={actionUrl('new')}>New Dashboard</LinkButton>}
  20. {!folderId && isEditor && <LinkButton href="dashboards/folder/new">New Folder</LinkButton>}
  21. {canEdit && <LinkButton href={actionUrl('import')}>Import</LinkButton>}
  22. </HorizontalGroup>
  23. </div>
  24. );
  25. };