index.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 useOrganization from 'sentry/utils/useOrganization';
  6. import WidgetLegendSelectionState from '../widgetLegendSelectionState';
  7. import WidgetBuilder from './widgetBuilder';
  8. interface WidgetBuilderProps
  9. extends Omit<React.ComponentProps<typeof WidgetBuilder>, 'organization'> {}
  10. function WidgetBuilderContainer(props: WidgetBuilderProps) {
  11. const organization = useOrganization();
  12. return (
  13. <Feature
  14. features="dashboards-edit"
  15. organization={organization}
  16. renderDisabled={() => (
  17. <Layout.Page withPadding>
  18. <Alert type="warning">{t("You don't have access to this feature")}</Alert>
  19. </Layout.Page>
  20. )}
  21. >
  22. <WidgetBuilder
  23. {...props}
  24. organization={organization}
  25. widgetLegendState={
  26. new WidgetLegendSelectionState({
  27. location: props.location,
  28. organization,
  29. dashboard: props.dashboard,
  30. router: props.router,
  31. })
  32. }
  33. />
  34. </Feature>
  35. );
  36. }
  37. export type {WidgetBuilderProps};
  38. export default WidgetBuilderContainer;