pluginList.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import {disablePlugin, enablePlugin} from 'sentry/actionCreators/plugins';
  2. import InactivePlugins from 'sentry/components/inactivePlugins';
  3. import PluginConfig from 'sentry/components/pluginConfig';
  4. import {t} from 'sentry/locale';
  5. import {Organization, Plugin, Project} from 'sentry/types';
  6. import {Panel, PanelItem} from './panels';
  7. type Props = {
  8. organization: Organization;
  9. pluginList: Plugin[];
  10. project: Project;
  11. onDisablePlugin?: (plugin: Plugin) => void;
  12. onEnablePlugin?: (plugin: Plugin) => void;
  13. };
  14. const PluginList = ({
  15. organization,
  16. project,
  17. pluginList,
  18. onDisablePlugin = () => {},
  19. onEnablePlugin = () => {},
  20. }: Props) => {
  21. const handleEnablePlugin = (plugin: Plugin) => {
  22. enablePlugin({
  23. projectId: project.slug,
  24. orgId: organization.slug,
  25. pluginId: plugin.slug,
  26. });
  27. onEnablePlugin(plugin);
  28. };
  29. const handleDisablePlugin = (plugin: Plugin) => {
  30. disablePlugin({
  31. projectId: project.slug,
  32. orgId: organization.slug,
  33. pluginId: plugin.slug,
  34. });
  35. onDisablePlugin(plugin);
  36. };
  37. if (!pluginList.length) {
  38. return (
  39. <Panel>
  40. <PanelItem>
  41. {t("Oops! Looks like there aren't any available integrations installed.")}
  42. </PanelItem>
  43. </Panel>
  44. );
  45. }
  46. return (
  47. <div>
  48. {pluginList
  49. .filter(p => p.enabled)
  50. .map(data => (
  51. <PluginConfig
  52. data={data}
  53. organization={organization}
  54. project={project}
  55. key={data.id}
  56. onDisablePlugin={handleDisablePlugin}
  57. />
  58. ))}
  59. <InactivePlugins
  60. plugins={pluginList.filter(p => !p.enabled && !p.isHidden)}
  61. onEnablePlugin={handleEnablePlugin}
  62. />
  63. </div>
  64. );
  65. };
  66. export default PluginList;