|
174 | 174 | <ToggleSwitch |
175 | 175 | v-if="notificationPreferences[notificationTypeId]" |
176 | 176 | v-model="notificationPreferences[notificationTypeId].enabled" |
177 | | - :disabled="!!auth.impersonation" |
| 177 | + :disabled="!!auth.impersonation || notificationType.readOnly" |
178 | 178 | @update:model-value="(enabled) => enabled === false && (notificationPreferences[notificationTypeId]!.emailEnabled = false)" |
179 | 179 | /> |
180 | 180 | <label class="cursor-text text-nowrap">App</label> |
181 | 181 | </div> |
182 | | - <div v-if="notificationType.allowEmail" class="flex items-center gap-2"> |
| 182 | + <div v-if="notificationType.sendEmail" class="flex items-center gap-2"> |
183 | 183 | <ToggleSwitch |
184 | 184 | v-if="notificationPreferences[notificationTypeId]" |
185 | 185 | v-model="notificationPreferences[notificationTypeId].emailEnabled" |
|
401 | 401 | // This builds an object to send to the backend. |
402 | 402 | function normalizeNotificationPreferences () { |
403 | 403 | return Object.fromEntries(Object.keys(notificationTypes.value).sort().map((type) => { |
404 | | - const normalizedPreference: NotificationPreference = { enabled: notificationPreferences.value[type]?.enabled !== false }; |
| 404 | + const normalizedPreference: NotificationPreference = { enabled: notificationTypes.value[type]!.readOnly || notificationPreferences.value[type]?.enabled !== false }; |
405 | 405 |
|
406 | | - if (notificationTypes.value[type]!.allowEmail) { |
| 406 | + if (notificationTypes.value[type]!.sendEmail) { |
407 | 407 | normalizedPreference.emailEnabled = notificationPreferences.value[type]?.emailEnabled !== false; |
408 | 408 | } |
409 | 409 |
|
|
444 | 444 | // Here we are fulfilling default values. |
445 | 445 | const preferences = Object.fromEntries(Object.keys(notificationTypes.value) |
446 | 446 | .map(type => [ type, { |
447 | | - enabled: !allDisabled, |
448 | | - emailEnabled: notificationTypes.value[type]?.allowEmail ? !(allDisabled || allEmailDisabled) : undefined, |
| 447 | + enabled: notificationTypes.value[type]!.readOnly || !allDisabled, |
| 448 | + emailEnabled: notificationTypes.value[type]?.sendEmail ? !(allDisabled || allEmailDisabled) : undefined, |
449 | 449 | parameter: notificationTypes.value[type]?.hasParameter ? String(notificationTypes.value[type]?.defaultParameter) : undefined, |
450 | 450 | }])) as Record<string, { enabled: boolean; emailEnabled?: boolean; parameter?: string }>; |
451 | 451 |
|
452 | 452 | // Here we are overriding default values with user preferences. |
453 | 453 | for (const [ type, preference ] of Object.entries(userPreferences).filter(([ type ]) => type in preferences)) { |
454 | 454 | if (typeof preference?.enabled === 'boolean') { |
455 | | - preferences[type]!.enabled = preference.enabled; |
| 455 | + preferences[type]!.enabled = notificationTypes.value[type]!.readOnly || preference.enabled; |
456 | 456 | preferences[type]!.emailEnabled = preference.enabled; |
457 | 457 | } |
458 | 458 |
|
|
0 commit comments