Browse Source

ref(notifications): more cleanup of old notification settings (#60311)

More cleanup notification settings on the UI
Stephen Cefali 1 year ago
parent
commit
33ce9a2038

+ 0 - 41
static/app/data/forms/accountNotificationSettings.tsx

@@ -1,51 +1,10 @@
 import {Field} from 'sentry/components/forms/types';
 import {t} from 'sentry/locale';
 
-// TODO: cleanup unused fields and exports
-
 // Export route to make these forms searchable by label/help
 export const route = '/settings/account/notifications/';
 
 export const fields: {[key: string]: Field} = {
-  subscribeByDefault: {
-    name: 'subscribeByDefault',
-    type: 'boolean',
-    label: t('Send Me Alerts'),
-    // TODO(billy): Make this a real link
-    help: t(
-      'Enable this to receive notifications for Alerts sent to your teams. You will always receive alerts configured to be sent directly to you.'
-    ),
-  },
-  workflowNotifications: {
-    name: 'workflowNotifications',
-    type: 'radio',
-    label: t('Send Me Workflow Notifications'),
-    choices: [
-      [0, t('Always')],
-      [1, t('Only On Issues I Subscribe To')],
-      [2, t('Never')],
-    ],
-    help: t('E.g. changes in issue assignment, resolution status, and comments.'),
-  },
-  weeklyReports: {
-    // Form is not visible because currently not implemented
-    name: 'weeklyReports',
-    type: 'boolean',
-    label: t('Send Me Weekly Reports'),
-    help: t("Reports contain a summary of what's happened within your organization."),
-    disabled: true,
-  },
-  deployNotifications: {
-    name: 'deployNotifications',
-    type: 'radio',
-    label: t('Send Me Deploy Notifications'),
-    choices: [
-      [2, t('Always')],
-      [3, t('Only On Deploys With My Commits')],
-      [4, t('Never')],
-    ],
-    help: t('Deploy emails include release, environment and commit overviews.'),
-  },
   personalActivityNotifications: {
     name: 'personalActivityNotifications',
     type: 'boolean',

+ 0 - 4
static/app/views/settings/account/notifications/constants.tsx

@@ -24,10 +24,6 @@ export const MIN_PROJECTS_FOR_PAGINATION = 100;
 export type SupportedProviders = 'email' | 'slack' | 'msteams';
 export type ProviderValue = 'always' | 'never';
 
-export type NotificationSettingsByProviderObject = {[key: string]: string};
-export type NotificationSettingsObject = {
-  [key: string]: {[key: string]: {[key: string]: NotificationSettingsByProviderObject}};
-};
 interface NotificationBaseObject {
   id: string;
   scopeIdentifier: string;

+ 0 - 3
static/app/views/settings/account/notifications/fields.tsx

@@ -19,7 +19,6 @@ export const ACCOUNT_NOTIFICATION_FIELDS: Record<string, FineTuneField> = {
     ),
     type: 'select',
     options: [
-      {value: '-1', label: t('Default')},
       {value: '1', label: t('On')},
       {value: '0', label: t('Off')},
     ],
@@ -33,7 +32,6 @@ export const ACCOUNT_NOTIFICATION_FIELDS: Record<string, FineTuneField> = {
     ),
     type: 'select',
     options: [
-      {value: '-1', label: t('Default')},
       {value: '0', label: t('Always')},
       {value: '1', label: t('Only on issues I subscribe to')},
       {value: '2', label: t('Never')},
@@ -48,7 +46,6 @@ export const ACCOUNT_NOTIFICATION_FIELDS: Record<string, FineTuneField> = {
     ),
     type: 'select',
     options: [
-      {value: '-1', label: t('Default')},
       {value: '2', label: t('Always')},
       {value: '3', label: t('Only on deploys with my commits')},
       {value: '4', label: t('Never')},

+ 7 - 16
static/app/views/settings/account/notifications/fields2.tsx

@@ -79,10 +79,14 @@ export const NOTIFICATION_SETTING_FIELDS: Record<string, Field> = {
     help: t('Error, transaction, and attachment quota limits.'),
   },
   reports: {
-    name: 'weekly reports',
-    type: 'blank',
+    name: 'reports',
+    type: 'select',
     label: t('Weekly Reports'),
     help: t('A summary of the past week for an organization.'),
+    choices: [
+      ['always', t('On')],
+      ['never', t('Off')],
+    ],
   },
   email: {
     name: 'email routing',
@@ -100,6 +104,7 @@ export const NOTIFICATION_SETTING_FIELDS: Record<string, Field> = {
     ],
     help: t('Notifications about spikes on a per project basis.'),
   },
+  // legacy options
   personalActivityNotifications: {
     name: 'personalActivityNotifications',
     type: 'select',
@@ -122,20 +127,6 @@ export const NOTIFICATION_SETTING_FIELDS: Record<string, Field> = {
   },
 };
 
-export const NOTIFICATION_SETTING_FIELDS_V2: Record<string, Field> = {
-  ...NOTIFICATION_SETTING_FIELDS,
-  reports: {
-    name: 'reports',
-    type: 'select',
-    label: t('Weekly Reports'),
-    help: t('A summary of the past week for an organization.'),
-    choices: [
-      ['always', t('On')],
-      ['never', t('Off')],
-    ],
-  },
-};
-
 // partial field definition for quota sub-categories
 export const QUOTA_FIELDS = [
   {

+ 0 - 1
static/app/views/settings/account/notifications/notificationSettings.spec.tsx

@@ -12,7 +12,6 @@ function renderMockRequests({}: {}) {
     body: {
       personalActivityNotifications: true,
       selfAssignOnResolve: true,
-      weeklyReports: true,
     },
   });
 }

+ 2 - 2
static/app/views/settings/account/notifications/notificationSettingsByEntity.tsx

@@ -19,7 +19,7 @@ import {useApiQuery} from 'sentry/utils/queryClient';
 import useRouter from 'sentry/utils/useRouter';
 
 import type {NotificationOptionsObject} from './constants';
-import {NOTIFICATION_SETTING_FIELDS_V2} from './fields2';
+import {NOTIFICATION_SETTING_FIELDS} from './fields2';
 import {OrganizationSelectHeader} from './organizationSelectHeader';
 
 type Value = 'always' | 'never' | 'subscribe_only' | 'committed_only';
@@ -107,7 +107,7 @@ function NotificationSettingsByEntity({
     handleAddNotificationOption(data);
   };
 
-  const valueOptions = NOTIFICATION_SETTING_FIELDS_V2[notificationType].choices;
+  const valueOptions = NOTIFICATION_SETTING_FIELDS[notificationType].choices;
 
   const renderOverrides = () => {
     const matchedOptions = notificationOptions.filter(

+ 4 - 4
static/app/views/settings/account/notifications/notificationSettingsByType.tsx

@@ -26,7 +26,7 @@ import {
   SupportedProviders,
 } from './constants';
 import {ACCOUNT_NOTIFICATION_FIELDS} from './fields';
-import {NOTIFICATION_SETTING_FIELDS_V2, QUOTA_FIELDS} from './fields2';
+import {NOTIFICATION_SETTING_FIELDS, QUOTA_FIELDS} from './fields2';
 import NotificationSettingsByEntity from './notificationSettingsByEntity';
 import {Identity} from './types';
 import UnlinkedAlert from './unlinkedAlert';
@@ -207,7 +207,7 @@ class NotificationSettingsByTypeV2 extends DeprecatedAsyncComponent<Props, State
     } else {
       const defaultField: Field = Object.assign(
         {},
-        NOTIFICATION_SETTING_FIELDS_V2[notificationType],
+        NOTIFICATION_SETTING_FIELDS[notificationType],
         {
           help,
           defaultValue: 'always',
@@ -231,10 +231,10 @@ class NotificationSettingsByTypeV2 extends DeprecatedAsyncComponent<Props, State
     const {notificationType} = this.props;
     // get the choices but only the ones that are available to the user
     const choices = (
-      NOTIFICATION_SETTING_FIELDS_V2.provider.choices as [SupportedProviders, string][]
+      NOTIFICATION_SETTING_FIELDS.provider.choices as [SupportedProviders, string][]
     ).filter(([providerSlug]) => this.isProviderSupported(providerSlug));
 
-    const defaultField = Object.assign({}, NOTIFICATION_SETTING_FIELDS_V2.provider, {
+    const defaultField = Object.assign({}, NOTIFICATION_SETTING_FIELDS.provider, {
       choices,
       getData: data => {
         return {