index.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import Feature from 'sentry/components/acl/feature';
  2. import {Alert} from 'sentry/components/alert';
  3. import * as Layout from 'sentry/components/layouts/thirds';
  4. import {t} from 'sentry/locale';
  5. import {DiscoverDatasets} from 'sentry/utils/discover/types';
  6. import useOrganization from 'sentry/utils/useOrganization';
  7. import {SpanTagsProvider} from 'sentry/views/explore/contexts/spanTagsContext';
  8. import WidgetLegendSelectionState from '../widgetLegendSelectionState';
  9. import WidgetBuilder from './widgetBuilder';
  10. interface WidgetBuilderProps
  11. extends Omit<React.ComponentProps<typeof WidgetBuilder>, 'organization'> {}
  12. function WidgetBuilderContainer(props: WidgetBuilderProps) {
  13. const organization = useOrganization();
  14. return (
  15. <Feature
  16. features="dashboards-edit"
  17. organization={organization}
  18. renderDisabled={() => (
  19. <Layout.Page withPadding>
  20. <Alert type="warning">{t("You don't have access to this feature")}</Alert>
  21. </Layout.Page>
  22. )}
  23. >
  24. <SpanTagsProvider dataset={DiscoverDatasets.SPANS_EAP}>
  25. <WidgetBuilder
  26. {...props}
  27. organization={organization}
  28. widgetLegendState={
  29. new WidgetLegendSelectionState({
  30. location: props.location,
  31. organization,
  32. dashboard: props.dashboard,
  33. router: props.router,
  34. })
  35. }
  36. />
  37. </SpanTagsProvider>
  38. </Feature>
  39. );
  40. }
  41. export type {WidgetBuilderProps};
  42. export default WidgetBuilderContainer;