projectPlugins.tsx 3.0 KB

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