projectToolbar.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import Access from 'sentry/components/acl/access';
  2. import Form from 'sentry/components/forms/form';
  3. import JsonForm from 'sentry/components/forms/jsonForm';
  4. import type {JsonFormObject} from 'sentry/components/forms/types';
  5. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  6. import {t} from 'sentry/locale';
  7. import type {RouteComponentProps} from 'sentry/types/legacyReactRouter';
  8. import type {Organization} from 'sentry/types/organization';
  9. import type {Project} from 'sentry/types/project';
  10. import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader';
  11. import PermissionAlert from 'sentry/views/settings/project/permissionAlert';
  12. type RouteParams = {
  13. projectId: string;
  14. };
  15. type Props = RouteComponentProps<RouteParams, {}> & {
  16. organization: Organization;
  17. project: Project;
  18. };
  19. function ProjectToolbarSettings({organization, project, params: {projectId}}: Props) {
  20. const formGroups: JsonFormObject[] = [
  21. {
  22. title: 'Settings',
  23. fields: [
  24. {
  25. name: 'sentry:toolbar_allowed_origins',
  26. type: 'textarea',
  27. rows: 3,
  28. autosize: true,
  29. // additional data/props that is related to rendering of form field rather than data
  30. label: t('Allowed Origins'),
  31. help: t(
  32. 'Domain URLs where the dev toolbar can be installed and access your data. Wildcards (*) are supported. Please separate multiple entries with a newline.'
  33. ),
  34. getData: data => ({options: data}),
  35. },
  36. ],
  37. },
  38. ];
  39. return (
  40. <SentryDocumentTitle title={t('Toolbar Settings')} projectSlug={project.slug}>
  41. <SettingsPageHeader title={t('Developer Toolbar')} />
  42. <PermissionAlert project={project} />
  43. <Form
  44. apiMethod="PUT"
  45. apiEndpoint={`/projects/${organization.slug}/${projectId}/`}
  46. initialData={project.options}
  47. saveOnBlur
  48. >
  49. <Access access={['project:write']} project={project}>
  50. {({hasAccess}) => (
  51. <JsonForm
  52. disabled={!hasAccess}
  53. features={new Set(organization.features)}
  54. forms={formGroups}
  55. />
  56. )}
  57. </Access>
  58. </Form>
  59. </SentryDocumentTitle>
  60. );
  61. }
  62. export default ProjectToolbarSettings;