index.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { featureEnabled } from '@grafana/runtime';
  2. import { ProBadge } from 'app/core/components/Upgrade/ProBadge';
  3. import { config } from 'app/core/config';
  4. import { contextSrv } from 'app/core/services/context_srv';
  5. import { highlightTrial } from 'app/features/admin/utils';
  6. import { addDashboardShareTab, ShareModalTabModel } from 'app/features/dashboard/components/ShareModal';
  7. import { AccessControlAction, StepKey } from '../types';
  8. import { buildExperimentID } from '../utils/featureHighlights';
  9. import { CreateReportTab } from './CreateReportTab';
  10. import Confirm from './ReportForm/Confirm';
  11. import FormatReport from './ReportForm/FormatReport';
  12. import Schedule from './ReportForm/Schedule';
  13. import SelectDashboard from './ReportForm/SelectDashboard';
  14. import Share from './ReportForm/Share';
  15. import { SharePDF } from './SharePDF';
  16. const highlightsEnabled = config.featureToggles.featureHighlights;
  17. const sharePDFTab: ShareModalTabModel = {
  18. label: 'PDF',
  19. value: 'pdf',
  20. component: SharePDF,
  21. };
  22. const createReportTab: ShareModalTabModel = {
  23. label: 'Report',
  24. value: 'report',
  25. tabSuffix:
  26. (highlightsEnabled && !featureEnabled('reports.creation')) || highlightTrial()
  27. ? () => ProBadge({ experimentId: buildExperimentID('reporting-tab-badge') })
  28. : undefined,
  29. component: CreateReportTab,
  30. };
  31. export function initReporting() {
  32. if (!config.reporting?.enabled) {
  33. return;
  34. }
  35. if (featureEnabled('reports.creation')) {
  36. addDashboardShareTab(sharePDFTab);
  37. if (contextSrv.hasAccess(AccessControlAction.ReportingCreate, contextSrv.hasRole('Admin'))) {
  38. addDashboardShareTab(createReportTab);
  39. }
  40. } else if (highlightsEnabled) {
  41. addDashboardShareTab(createReportTab);
  42. }
  43. }
  44. export const reportSteps = [
  45. { id: StepKey.SelectDashboard, name: 'Select dashboard', component: SelectDashboard },
  46. { id: StepKey.FormatReport, name: 'Format report', component: FormatReport },
  47. { id: StepKey.Schedule, name: 'Schedule', component: Schedule },
  48. { id: StepKey.Share, name: 'Share', component: Share },
  49. { id: StepKey.Confirm, name: 'Confirm', component: Confirm },
  50. ];