Browse Source

ref(select): Choices -> options accountNotificationFineTuning (#28810)

David Wang 3 years ago
parent
commit
461a9cbff1

+ 3 - 3
static/app/views/settings/account/accountNotificationFineTuning.tsx

@@ -65,7 +65,7 @@ const AccountNotificationsByProject = ({projects, field}: ANBPProps) => {
               <SelectField
               <SelectField
                 defaultValue={f.defaultValue}
                 defaultValue={f.defaultValue}
                 name={f.name}
                 name={f.name}
-                choices={f.choices}
+                options={f.options}
                 label={f.label}
                 label={f.label}
               />
               />
             </PanelBodyLineItem>
             </PanelBodyLineItem>
@@ -101,7 +101,7 @@ const AccountNotificationsByOrganization = ({organizations, field}: ANBOProps) =
           <SelectField
           <SelectField
             defaultValue={f.defaultValue}
             defaultValue={f.defaultValue}
             name={f.name}
             name={f.name}
-            choices={f.choices}
+            options={f.options}
             label={f.label}
             label={f.label}
           />
           />
         </PanelBodyLineItem>
         </PanelBodyLineItem>
@@ -183,7 +183,7 @@ class AccountNotificationFineTuning extends AsyncView<Props, State> {
 
 
     if (fineTuneType === 'email') {
     if (fineTuneType === 'email') {
       // Fetch verified email addresses
       // Fetch verified email addresses
-      field.choices = this.emailChoices.map(({email}) => [email, email]);
+      field.options = this.emailChoices.map(({email}) => ({value: email, label: email}));
     }
     }
 
 
     if (!notifications || !fineTuneData) {
     if (!notifications || !fineTuneData) {

+ 19 - 18
static/app/views/settings/account/notifications/fields.tsx

@@ -1,10 +1,11 @@
 import {t} from 'app/locale';
 import {t} from 'app/locale';
+import {SelectValue} from 'app/types';
 
 
 export type FineTuneField = {
 export type FineTuneField = {
   title: string;
   title: string;
   description: string;
   description: string;
   type: 'select';
   type: 'select';
-  choices?: string[][];
+  options?: SelectValue<string>[];
   defaultValue?: string;
   defaultValue?: string;
   defaultFieldName?: string;
   defaultFieldName?: string;
 };
 };
@@ -16,10 +17,10 @@ export const ACCOUNT_NOTIFICATION_FIELDS: Record<string, FineTuneField> = {
       'Notifications from Alert Rules that your team has setup. You’ll always receive notifications from Alerts configured to be sent directly to you.'
       'Notifications from Alert Rules that your team has setup. You’ll always receive notifications from Alerts configured to be sent directly to you.'
     ),
     ),
     type: 'select',
     type: 'select',
-    choices: [
-      ['-1', t('Default')],
-      ['1', t('On')],
-      ['0', t('Off')],
+    options: [
+      {value: '-1', label: t('Default')},
+      {value: '1', label: t('On')},
+      {value: '0', label: t('Off')},
     ],
     ],
     defaultValue: '-1',
     defaultValue: '-1',
     defaultFieldName: 'subscribeByDefault',
     defaultFieldName: 'subscribeByDefault',
@@ -30,11 +31,11 @@ export const ACCOUNT_NOTIFICATION_FIELDS: Record<string, FineTuneField> = {
       'Control workflow notifications, e.g. changes in issue assignment, resolution status, and comments.'
       'Control workflow notifications, e.g. changes in issue assignment, resolution status, and comments.'
     ),
     ),
     type: 'select',
     type: 'select',
-    choices: [
-      ['-1', t('Default')],
-      ['0', t('Always')],
-      ['1', t('Only on issues I subscribe to')],
-      ['2', t('Never')],
+    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')},
     ],
     ],
     defaultValue: '-1',
     defaultValue: '-1',
     defaultFieldName: 'workflowNotifications',
     defaultFieldName: 'workflowNotifications',
@@ -45,11 +46,11 @@ export const ACCOUNT_NOTIFICATION_FIELDS: Record<string, FineTuneField> = {
       'Control deploy notifications that include release, environment, and commit overviews.'
       'Control deploy notifications that include release, environment, and commit overviews.'
     ),
     ),
     type: 'select',
     type: 'select',
-    choices: [
-      ['-1', t('Default')],
-      ['2', t('Always')],
-      ['3', t('Only on deploys with my commits')],
-      ['4', t('Never')],
+    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')},
     ],
     ],
     defaultValue: '-1',
     defaultValue: '-1',
     defaultFieldName: 'deployNotifications',
     defaultFieldName: 'deployNotifications',
@@ -62,9 +63,9 @@ export const ACCOUNT_NOTIFICATION_FIELDS: Record<string, FineTuneField> = {
     type: 'select',
     type: 'select',
     // API only saves organizations that have this disabled, so we should default to "On"
     // API only saves organizations that have this disabled, so we should default to "On"
     defaultValue: '1',
     defaultValue: '1',
-    choices: [
-      ['1', t('On')],
-      ['0', t('Off')],
+    options: [
+      {value: '1', label: t('On')},
+      {value: '0', label: t('Off')},
     ],
     ],
     defaultFieldName: 'weeklyReports',
     defaultFieldName: 'weeklyReports',
   },
   },