projectPlugins.tsx 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 {
  7. Panel,
  8. PanelAlert,
  9. PanelBody,
  10. PanelHeader,
  11. PanelItem,
  12. } from 'sentry/components/panels';
  13. import {t, tct} from 'sentry/locale';
  14. import {Plugin, Project} from 'sentry/types';
  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. plugins: Plugin[];
  22. project: Project;
  23. } & RouteComponentProps<{orgId: string}, {}>;
  24. class ProjectPlugins extends Component<Props> {
  25. render() {
  26. const {plugins, loading, error, onChange, routes, params, project} = this.props;
  27. const {orgId} = this.props.params;
  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. return (
  37. <Panel>
  38. <PanelHeader>
  39. <div>{t('Legacy Integration')}</div>
  40. <div>{t('Enabled')}</div>
  41. </PanelHeader>
  42. <PanelBody>
  43. <PanelAlert type="warning">
  44. <Access access={['org:integrations']}>
  45. {({hasAccess}) =>
  46. hasAccess
  47. ? tct(
  48. "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.",
  49. {
  50. link: <Link to={`/settings/${orgId}/integrations`} />,
  51. }
  52. )
  53. : t(
  54. "Legacy Integrations must be configured per-project. It's recommended to prefer organization integrations over the legacy project integrations when available."
  55. )
  56. }
  57. </Access>
  58. </PanelAlert>
  59. {plugins
  60. .filter(p => {
  61. return !p.isHidden;
  62. })
  63. .map(plugin => (
  64. <PanelItem key={plugin.id}>
  65. <ProjectPluginRow
  66. params={params}
  67. routes={routes}
  68. project={project}
  69. {...plugin}
  70. onChange={onChange}
  71. />
  72. </PanelItem>
  73. ))}
  74. </PanelBody>
  75. </Panel>
  76. );
  77. }
  78. }
  79. export default ProjectPlugins;