index.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import {Fragment} from 'react';
  2. import {RouteComponentProps} from 'react-router';
  3. import {Client} from 'sentry/api';
  4. import ErrorBoundary from 'sentry/components/errorBoundary';
  5. import NotFound from 'sentry/components/errors/notFound';
  6. import LoadingIndicator from 'sentry/components/loadingIndicator';
  7. import {Organization} from 'sentry/types';
  8. import withApi from 'sentry/utils/withApi';
  9. import withOrganization from 'sentry/utils/withOrganization';
  10. import DashboardDetail from './detail';
  11. import OrgDashboards from './orgDashboards';
  12. import {DashboardState} from './types';
  13. import {DashboardBasicFeature} from './view';
  14. type Props = RouteComponentProps<{orgId: string}, {}> & {
  15. api: Client;
  16. children: React.ReactNode;
  17. organization: Organization;
  18. };
  19. function DashboardsV2Container(props: Props) {
  20. const {organization, params, api, location, children} = props;
  21. if (organization.features.includes('dashboards-edit')) {
  22. return <Fragment>{children}</Fragment>;
  23. }
  24. return (
  25. <DashboardBasicFeature organization={organization}>
  26. <OrgDashboards
  27. api={api}
  28. location={location}
  29. params={params}
  30. organization={organization}
  31. >
  32. {({dashboard, dashboards, error, onDashboardUpdate}) => {
  33. return error ? (
  34. <NotFound />
  35. ) : dashboard ? (
  36. <ErrorBoundary>
  37. <DashboardDetail
  38. {...props}
  39. initialState={DashboardState.VIEW}
  40. dashboard={dashboard}
  41. dashboards={dashboards}
  42. onDashboardUpdate={onDashboardUpdate}
  43. />
  44. </ErrorBoundary>
  45. ) : (
  46. <LoadingIndicator />
  47. );
  48. }}
  49. </OrgDashboards>
  50. </DashboardBasicFeature>
  51. );
  52. }
  53. export default withApi(withOrganization(DashboardsV2Container));