create.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import React from 'react';
  2. import {RouteComponentProps} from 'react-router';
  3. import Feature from 'app/components/acl/feature';
  4. import Alert from 'app/components/alert';
  5. import {t} from 'app/locale';
  6. import {PageContent} from 'app/styles/organization';
  7. import {Organization} from 'app/types';
  8. import withOrganization from 'app/utils/withOrganization';
  9. import {EMPTY_DASHBOARD} from './data';
  10. import DashboardDetail from './detail';
  11. import {DashboardState} from './types';
  12. import {cloneDashboard} from './utils';
  13. type Props = RouteComponentProps<{orgId: string}, {}> & {
  14. organization: Organization;
  15. children: React.ReactNode;
  16. };
  17. function CreateDashboard(props: Props) {
  18. function renderDisabled() {
  19. return (
  20. <PageContent>
  21. <Alert type="warning">{t("You don't have access to this feature")}</Alert>
  22. </PageContent>
  23. );
  24. }
  25. const dashboard = cloneDashboard(EMPTY_DASHBOARD);
  26. return (
  27. <Feature
  28. features={['dashboards-edit']}
  29. organization={props.organization}
  30. renderDisabled={renderDisabled}
  31. >
  32. <DashboardDetail
  33. {...props}
  34. initialState={DashboardState.CREATE}
  35. dashboard={dashboard}
  36. dashboards={[]}
  37. />
  38. </Feature>
  39. );
  40. }
  41. export default withOrganization(CreateDashboard);