projectPlugins.tsx 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import {Component} from 'react';
  2. import * as React from 'react';
  3. import {WithRouterProps} from 'react-router';
  4. import Access from 'app/components/acl/access';
  5. import Link from 'app/components/links/link';
  6. import LoadingIndicator from 'app/components/loadingIndicator';
  7. import {
  8. Panel,
  9. PanelAlert,
  10. PanelBody,
  11. PanelHeader,
  12. PanelItem,
  13. } from 'app/components/panels';
  14. import {t, tct} from 'app/locale';
  15. import {Plugin, Project} from 'app/types';
  16. import RouteError from 'app/views/routeError';
  17. import ProjectPluginRow from './projectPluginRow';
  18. type Props = {
  19. plugins: Plugin[];
  20. loading: boolean;
  21. error: React.ComponentProps<typeof RouteError>['error'];
  22. onChange: React.ComponentProps<typeof ProjectPluginRow>['onChange'];
  23. project: Project;
  24. } & WithRouterProps<{orgId: string}>;
  25. class ProjectPlugins extends Component<Props> {
  26. render() {
  27. const {plugins, loading, error, onChange, routes, params, project} = this.props;
  28. const {orgId} = this.props.params;
  29. const hasError = error;
  30. const isLoading = !hasError && loading;
  31. if (hasError) {
  32. return <RouteError error={error} />;
  33. }
  34. if (isLoading) {
  35. return <LoadingIndicator />;
  36. }
  37. return (
  38. <Panel>
  39. <PanelHeader>
  40. <div>{t('Legacy Integration')}</div>
  41. <div>{t('Enabled')}</div>
  42. </PanelHeader>
  43. <PanelBody>
  44. <PanelAlert type="warning">
  45. <Access access={['org:integrations']}>
  46. {({hasAccess}) =>
  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/${orgId}/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. }
  58. </Access>
  59. </PanelAlert>
  60. {plugins
  61. .filter(p => {
  62. return !p.isHidden;
  63. })
  64. .map(plugin => (
  65. <PanelItem key={plugin.id}>
  66. <ProjectPluginRow
  67. params={params}
  68. routes={routes}
  69. project={project}
  70. {...plugin}
  71. onChange={onChange}
  72. />
  73. </PanelItem>
  74. ))}
  75. </PanelBody>
  76. </Panel>
  77. );
  78. }
  79. }
  80. export default ProjectPlugins;