mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
FSL-1.0-Apache-2.0 grants us the code, not the name. "Sentry" is Functional Software's trademark, so every place the running app says it to a user -- page titles, onboarding, empty states, toasts, settings copy, the self-hosted footer -- now says Sentinel. Attribution is the other half of the deal and stays untouched: upstream copyright headers, LICENSE, NOTICE. So does anything where the mark is a fact rather than a brand -- @sentry/* packages, sentry-cli, the wizard and bundler plugins, docs.sentry.io, the whole gettingStartedDocs tree. Renaming those would leave instructions that no longer work. Nothing structural moved. No import, identifier, route path, feature flag, API field or test id changed; the diff is 312 lines in and 312 out. Colocated specs were updated in lockstep with the copy they assert. Marketing and community links point at hanzo.ai, only where a real page exists to point at. Co-authored-by: Hanzo Dev <[email protected]>
174 lines
5.5 KiB
TypeScript
174 lines
5.5 KiB
TypeScript
import {Fragment} from 'react';
|
|
import type {RouteComponentProps} from 'react-router';
|
|
|
|
import AlertLink from 'sentry/components/alertLink';
|
|
import {LinkButton} from 'sentry/components/button';
|
|
import Form from 'sentry/components/forms/form';
|
|
import JsonForm from 'sentry/components/forms/jsonForm';
|
|
import LoadingError from 'sentry/components/loadingError';
|
|
import LoadingIndicator from 'sentry/components/loadingIndicator';
|
|
import PanelAlert from 'sentry/components/panels/panelAlert';
|
|
import PluginList from 'sentry/components/pluginList';
|
|
import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
|
|
import {fields} from 'sentry/data/forms/projectAlerts';
|
|
import {IconMail} from 'sentry/icons';
|
|
import {t} from 'sentry/locale';
|
|
import type {Plugin, Project} from 'sentry/types';
|
|
import type {ApiQueryKey} from 'sentry/utils/queryClient';
|
|
import {setApiQueryData, useApiQuery, useQueryClient} from 'sentry/utils/queryClient';
|
|
import routeTitleGen from 'sentry/utils/routeTitle';
|
|
import useOrganization from 'sentry/utils/useOrganization';
|
|
import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader';
|
|
import PermissionAlert from 'sentry/views/settings/project/permissionAlert';
|
|
|
|
interface ProjectAlertSettingsProps extends RouteComponentProps<{projectId: string}, {}> {
|
|
canEditRule: boolean;
|
|
}
|
|
|
|
function makeFetchProjectPluginsQueryKey(
|
|
organizationSlug: string,
|
|
projectSlug: string
|
|
): ApiQueryKey {
|
|
return [`/projects/${organizationSlug}/${projectSlug}/plugins/`];
|
|
}
|
|
|
|
function ProjectAlertSettings({canEditRule, params}: ProjectAlertSettingsProps) {
|
|
const organization = useOrganization();
|
|
const queryClient = useQueryClient();
|
|
|
|
const projectSlug = params.projectId;
|
|
const {
|
|
data: project,
|
|
isLoading: isProjectLoading,
|
|
isError: isProjectError,
|
|
refetch: refetchProject,
|
|
} = useApiQuery<Project>([`/projects/${organization.slug}/${projectSlug}/`], {
|
|
staleTime: 0,
|
|
cacheTime: 0,
|
|
});
|
|
const {
|
|
data: pluginList = [],
|
|
isLoading: isPluginListLoading,
|
|
isError: isPluginListError,
|
|
refetch: refetchPluginList,
|
|
} = useApiQuery<Plugin[]>(
|
|
makeFetchProjectPluginsQueryKey(organization.slug, projectSlug),
|
|
{staleTime: 0, cacheTime: 0}
|
|
);
|
|
|
|
if ((!isProjectLoading && !project) || isPluginListError || isProjectError) {
|
|
return (
|
|
<LoadingError
|
|
onRetry={() => {
|
|
isProjectError && refetchProject();
|
|
isPluginListError && refetchPluginList();
|
|
}}
|
|
/>
|
|
);
|
|
}
|
|
|
|
const updatePlugin = (plugin: Plugin, enabled: boolean) => {
|
|
setApiQueryData<Plugin[]>(
|
|
queryClient,
|
|
makeFetchProjectPluginsQueryKey(organization.slug, projectSlug),
|
|
oldState =>
|
|
oldState.map(p => {
|
|
if (p.id !== plugin.id) {
|
|
return p;
|
|
}
|
|
return {
|
|
...plugin,
|
|
enabled,
|
|
};
|
|
})
|
|
);
|
|
};
|
|
|
|
const handleEnablePlugin = (plugin: Plugin) => {
|
|
updatePlugin(plugin, true);
|
|
};
|
|
|
|
const handleDisablePlugin = (plugin: Plugin) => {
|
|
updatePlugin(plugin, false);
|
|
};
|
|
|
|
return (
|
|
<Fragment>
|
|
<SentryDocumentTitle
|
|
title={routeTitleGen(t('Alerts Settings'), projectSlug, false)}
|
|
/>
|
|
<SettingsPageHeader
|
|
title={t('Alerts Settings')}
|
|
action={
|
|
<LinkButton
|
|
to={{
|
|
pathname: `/organizations/${organization.slug}/alerts/rules/`,
|
|
query: {project: project?.id},
|
|
}}
|
|
size="sm"
|
|
>
|
|
{t('View Alert Rules')}
|
|
</LinkButton>
|
|
}
|
|
/>
|
|
<PermissionAlert project={project} />
|
|
<AlertLink to="/settings/account/notifications/" icon={<IconMail />}>
|
|
{t(
|
|
'Looking to fine-tune your personal notification preferences? Visit your Account Settings'
|
|
)}
|
|
</AlertLink>
|
|
|
|
{isProjectLoading || isPluginListLoading ? (
|
|
<LoadingIndicator />
|
|
) : (
|
|
<Fragment>
|
|
<Form
|
|
saveOnBlur
|
|
allowUndo
|
|
initialData={{
|
|
subjectTemplate: project.subjectTemplate,
|
|
digestsMinDelay: project.digestsMinDelay,
|
|
digestsMaxDelay: project.digestsMaxDelay,
|
|
}}
|
|
apiMethod="PUT"
|
|
apiEndpoint={`/projects/${organization.slug}/${project.slug}/`}
|
|
>
|
|
<JsonForm
|
|
disabled={!canEditRule}
|
|
title={t('Email Settings')}
|
|
fields={[fields.subjectTemplate]}
|
|
/>
|
|
|
|
<JsonForm
|
|
title={t('Digests')}
|
|
disabled={!canEditRule}
|
|
fields={[fields.digestsMinDelay, fields.digestsMaxDelay]}
|
|
renderHeader={() => (
|
|
<PanelAlert type="info">
|
|
{t(
|
|
'Sentinel will automatically digest alerts sent by some services to avoid flooding your inbox with individual issue notifications. To control how frequently notifications are delivered, use the sliders below.'
|
|
)}
|
|
</PanelAlert>
|
|
)}
|
|
/>
|
|
</Form>
|
|
|
|
{canEditRule && (
|
|
<PluginList
|
|
organization={organization}
|
|
project={project}
|
|
pluginList={(pluginList ?? []).filter(
|
|
p => p.type === 'notification' && p.hasConfiguration
|
|
)}
|
|
onEnablePlugin={handleEnablePlugin}
|
|
onDisablePlugin={handleDisablePlugin}
|
|
/>
|
|
)}
|
|
</Fragment>
|
|
)}
|
|
</Fragment>
|
|
);
|
|
}
|
|
|
|
export default ProjectAlertSettings;
|