index.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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
  25. dataset={DiscoverDatasets.SPANS_EAP}
  26. enabled={organization.features.includes('dashboards-eap')}
  27. >
  28. <WidgetBuilder
  29. {...props}
  30. organization={organization}
  31. widgetLegendState={
  32. new WidgetLegendSelectionState({
  33. location: props.location,
  34. organization,
  35. dashboard: props.dashboard,
  36. router: props.router,
  37. })
  38. }
  39. />
  40. </SpanTagsProvider>
  41. </Feature>
  42. );
  43. }
  44. export type {WidgetBuilderProps};
  45. export default WidgetBuilderContainer;