projectPlugins.tsx 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import {Component} from 'react';
  2. import type {RouteComponentProps} from 'react-router';
  3. import Access from 'sentry/components/acl/access';
  4. import Link from 'sentry/components/links/link';
  5. import LoadingIndicator from 'sentry/components/loadingIndicator';
  6. import Panel from 'sentry/components/panels/panel';
  7. import PanelAlert from 'sentry/components/panels/panelAlert';
  8. import PanelBody from 'sentry/components/panels/panelBody';
  9. import PanelHeader from 'sentry/components/panels/panelHeader';
  10. import PanelItem from 'sentry/components/panels/panelItem';
  11. import {t, tct} from 'sentry/locale';
  12. import type {Plugin} from 'sentry/types/integrations';
  13. import type {Organization} from 'sentry/types/organization';
  14. import type {Project} from 'sentry/types/project';
  15. import RouteError from 'sentry/views/routeError';
  16. import ProjectPluginRow from './projectPluginRow';
  17. type Props = {
  18. error: React.ComponentProps<typeof RouteError>['error'];
  19. loading: boolean;
  20. onChange: React.ComponentProps<typeof ProjectPluginRow>['onChange'];
  21. organization: Organization;
  22. plugins: Plugin[];
  23. project: Project;
  24. } & RouteComponentProps<{}, {}>;
  25. class ProjectPlugins extends Component<Props> {
  26. render() {
  27. const {plugins, loading, error, onChange, routes, organization, project} = this.props;
  28. const hasError = error;
  29. const isLoading = !hasError && loading;
  30. if (hasError) {
  31. return <RouteError error={error} />;
  32. }
  33. if (isLoading) {
  34. return <LoadingIndicator />;
  35. }
  36. const params = {orgId: organization.slug, projectId: project.slug};
  37. return (
  38. <Access access={['org:integrations']} project={project}>
  39. {({hasAccess}) => (
  40. <Panel>
  41. <PanelHeader>
  42. <div>{t('Legacy Integration')}</div>
  43. <div />
  44. </PanelHeader>
  45. <PanelBody>
  46. <PanelAlert type="warning">
  47. {hasAccess
  48. ? tct(
  49. "Legacy Integrations must be configured per-project. It's recommended to prefer organization integrations over the legacy project integrations when available. Visit the [link:organization integrations] settings to manage them.",
  50. {
  51. link: <Link to={`/settings/${organization.slug}/integrations`} />,
  52. }
  53. )
  54. : t(
  55. "Legacy Integrations must be configured per-project. It's recommended to prefer organization integrations over the legacy project integrations when available."
  56. )}
  57. </PanelAlert>
  58. {plugins
  59. .filter(p => {
  60. return !p.isHidden;
  61. })
  62. .map(plugin => (
  63. <PanelItem key={plugin.id}>
  64. <ProjectPluginRow
  65. params={params}
  66. routes={routes}
  67. project={project}
  68. {...plugin}
  69. onChange={onChange}
  70. />
  71. </PanelItem>
  72. ))}
  73. </PanelBody>
  74. </Panel>
  75. )}
  76. </Access>
  77. );
  78. }
  79. }
  80. export default ProjectPlugins;