mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
80 lines
2.0 KiB
TypeScript
80 lines
2.0 KiB
TypeScript
import {disablePlugin, enablePlugin} from 'sentry/actionCreators/plugins';
|
|
import {hasEveryAccess} from 'sentry/components/acl/access';
|
|
import InactivePlugins from 'sentry/components/inactivePlugins';
|
|
import Panel from 'sentry/components/panels/panel';
|
|
import PanelItem from 'sentry/components/panels/panelItem';
|
|
import PluginConfig from 'sentry/components/pluginConfig';
|
|
import {t} from 'sentry/locale';
|
|
import type {Organization, Plugin, Project} from 'sentry/types';
|
|
|
|
type Props = {
|
|
organization: Organization;
|
|
pluginList: Plugin[];
|
|
project: Project;
|
|
onDisablePlugin?: (plugin: Plugin) => void;
|
|
onEnablePlugin?: (plugin: Plugin) => void;
|
|
};
|
|
|
|
function PluginList({
|
|
organization,
|
|
project,
|
|
pluginList,
|
|
onDisablePlugin = () => {},
|
|
onEnablePlugin = () => {},
|
|
}: Props) {
|
|
const hasWriteAccess = hasEveryAccess(['project:write'], {organization, project});
|
|
|
|
const handleEnablePlugin = (plugin: Plugin) => {
|
|
enablePlugin({
|
|
projectId: project.slug,
|
|
orgId: organization.slug,
|
|
pluginId: plugin.slug,
|
|
});
|
|
|
|
onEnablePlugin(plugin);
|
|
};
|
|
|
|
const handleDisablePlugin = (plugin: Plugin) => {
|
|
disablePlugin({
|
|
projectId: project.slug,
|
|
orgId: organization.slug,
|
|
pluginId: plugin.slug,
|
|
});
|
|
|
|
onDisablePlugin(plugin);
|
|
};
|
|
|
|
if (!pluginList.length) {
|
|
return (
|
|
<Panel>
|
|
<PanelItem>
|
|
{t("Oops! Looks like there aren't any available integrations installed.")}
|
|
</PanelItem>
|
|
</Panel>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
{pluginList
|
|
.filter(p => p.enabled)
|
|
.map(plugin => (
|
|
<PluginConfig
|
|
plugin={plugin}
|
|
project={project}
|
|
key={plugin.id}
|
|
onDisablePlugin={handleDisablePlugin}
|
|
/>
|
|
))}
|
|
|
|
<InactivePlugins
|
|
disabled={!hasWriteAccess}
|
|
plugins={pluginList.filter(p => !p.enabled && !p.isHidden)}
|
|
onEnablePlugin={handleEnablePlugin}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default PluginList;
|