Browse Source

feat(notifications): sets FE for notification 2.0 weekly emails (#56012)

Need to enable the dropdown for weekly emails in notification 2.0
Stephen Cefali 1 year ago
parent
commit
4ac226530a

+ 13 - 16
static/app/views/settings/account/accountNotificationFineTuningV2.tsx

@@ -236,22 +236,19 @@ class AccountNotificationFineTuningV2 extends DeprecatedAsyncView<Props, State>
         <SettingsPageHeader title={title} />
         {description && <TextBlock>{description}</TextBlock>}
 
-        {field &&
-          field.defaultFieldName &&
-          // not implemented yet
-          field.defaultFieldName !== 'weeklyReports' && (
-            <Form
-              saveOnBlur
-              apiMethod="PUT"
-              apiEndpoint="/users/me/notifications/"
-              initialData={notifications}
-            >
-              <JsonForm
-                title={`Default ${title}`}
-                fields={[fields[field.defaultFieldName]]}
-              />
-            </Form>
-          )}
+        {field && field.defaultFieldName && (
+          <Form
+            saveOnBlur
+            apiMethod="PUT"
+            apiEndpoint="/users/me/notifications/"
+            initialData={notifications}
+          >
+            <JsonForm
+              title={`Default ${title}`}
+              fields={[fields[field.defaultFieldName]]}
+            />
+          </Form>
+        )}
         <Panel>
           <StyledPanelHeader hasButtons={isProject}>
             {isProject ? (

+ 14 - 0
static/app/views/settings/account/notifications/fields2.tsx

@@ -122,6 +122,20 @@ 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 = [
   {

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

@@ -18,7 +18,7 @@ import {Organization, Project} from 'sentry/types';
 import {useApiQuery} from 'sentry/utils/queryClient';
 import withSentryRouter from 'sentry/utils/withSentryRouter';
 import {NotificationOptionsObject} from 'sentry/views/settings/account/notifications/constants';
-import {NOTIFICATION_SETTING_FIELDS} from 'sentry/views/settings/account/notifications/fields2';
+import {NOTIFICATION_SETTING_FIELDS_V2} from 'sentry/views/settings/account/notifications/fields2';
 import {OrganizationSelectHeader} from 'sentry/views/settings/account/notifications/organizationSelectHeader';
 
 type Value = 'always' | 'never' | 'subscribe_only' | 'committed_only';
@@ -231,7 +231,7 @@ function NotificationSettingsByEntity(props: Props) {
     );
   };
 
-  const valueOptions = NOTIFICATION_SETTING_FIELDS[notificationType].choices;
+  const valueOptions = NOTIFICATION_SETTING_FIELDS_V2[notificationType].choices;
   return (
     <Fragment>
       <Panel>

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

@@ -20,7 +20,7 @@ import {
 } from 'sentry/views/settings/account/notifications/constants';
 import {ACCOUNT_NOTIFICATION_FIELDS} from 'sentry/views/settings/account/notifications/fields';
 import {
-  NOTIFICATION_SETTING_FIELDS,
+  NOTIFICATION_SETTING_FIELDS_V2,
   QUOTA_FIELDS,
 } from 'sentry/views/settings/account/notifications/fields2';
 import NotificationSettingsByEntity from 'sentry/views/settings/account/notifications/notificationSettingsByEntity';
@@ -186,7 +186,7 @@ class NotificationSettingsByTypeV2 extends DeprecatedAsyncComponent<Props, State
     } else {
       const defaultField: Field = Object.assign(
         {},
-        NOTIFICATION_SETTING_FIELDS[notificationType],
+        NOTIFICATION_SETTING_FIELDS_V2[notificationType],
         {
           help,
           defaultValue: 'always',
@@ -211,7 +211,7 @@ class NotificationSettingsByTypeV2 extends DeprecatedAsyncComponent<Props, State
     const {organizationIntegrations} = this.state;
     // get the choices but only the ones that are available to the user
     const choices = (
-      NOTIFICATION_SETTING_FIELDS.provider.choices as [string, string][]
+      NOTIFICATION_SETTING_FIELDS_V2.provider.choices as [string, string][]
     ).filter(([providerSlug]) => {
       if (providerSlug === 'email') {
         return true;
@@ -221,7 +221,7 @@ class NotificationSettingsByTypeV2 extends DeprecatedAsyncComponent<Props, State
       );
     });
 
-    const defaultField = Object.assign({}, NOTIFICATION_SETTING_FIELDS.provider, {
+    const defaultField = Object.assign({}, NOTIFICATION_SETTING_FIELDS_V2.provider, {
       choices,
       getData: data => {
         return {