|
@@ -27,7 +27,7 @@ import type {
|
|
|
} from './constants';
|
|
|
import {SUPPORTED_PROVIDERS} from './constants';
|
|
|
import {ACCOUNT_NOTIFICATION_FIELDS} from './fields';
|
|
|
-import {NOTIFICATION_SETTING_FIELDS, QUOTA_FIELDS} from './fields2';
|
|
|
+import {NOTIFICATION_SETTING_FIELDS, QUOTA_FIELDS, SPEND_FIELDS} from './fields2';
|
|
|
import NotificationSettingsByEntity from './notificationSettingsByEntity';
|
|
|
import type {Identity} from './types';
|
|
|
import UnlinkedAlert from './unlinkedAlert';
|
|
@@ -183,7 +183,7 @@ class NotificationSettingsByTypeV2 extends DeprecatedAsyncComponent<Props, State
|
|
|
}
|
|
|
|
|
|
getFields(): Field[] {
|
|
|
- const {notificationType} = this.props;
|
|
|
+ const {notificationType, organizations} = this.props;
|
|
|
|
|
|
const help = isGroupedByProject(notificationType)
|
|
|
? t('This is the default for all projects.')
|
|
@@ -193,20 +193,42 @@ class NotificationSettingsByTypeV2 extends DeprecatedAsyncComponent<Props, State
|
|
|
// if a quota notification is not disabled, add in our dependent fields
|
|
|
// but do not show the top level controller
|
|
|
if (notificationType === 'quota') {
|
|
|
- fields.push(
|
|
|
- ...QUOTA_FIELDS.map(field => ({
|
|
|
- ...field,
|
|
|
- type: 'select' as const,
|
|
|
- getData: data => {
|
|
|
- return {
|
|
|
- type: field.name,
|
|
|
- scopeType: 'user',
|
|
|
- scopeIdentifier: ConfigStore.get('user').id,
|
|
|
- value: data[field.name],
|
|
|
- };
|
|
|
- },
|
|
|
- }))
|
|
|
- );
|
|
|
+ if (
|
|
|
+ organizations.some(organization =>
|
|
|
+ organization.features?.includes('spend-visibility-notifications')
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ fields.push(
|
|
|
+ ...SPEND_FIELDS.map(field => ({
|
|
|
+ ...field,
|
|
|
+ type: 'select' as const,
|
|
|
+ getData: data => {
|
|
|
+ return {
|
|
|
+ type: field.name,
|
|
|
+ scopeType: 'user',
|
|
|
+ scopeIdentifier: ConfigStore.get('user').id,
|
|
|
+ value: data[field.name],
|
|
|
+ };
|
|
|
+ },
|
|
|
+ }))
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ // TODO(isabella): Once GA, remove this case
|
|
|
+ fields.push(
|
|
|
+ ...QUOTA_FIELDS.map(field => ({
|
|
|
+ ...field,
|
|
|
+ type: 'select' as const,
|
|
|
+ getData: data => {
|
|
|
+ return {
|
|
|
+ type: field.name,
|
|
|
+ scopeType: 'user',
|
|
|
+ scopeIdentifier: ConfigStore.get('user').id,
|
|
|
+ value: data[field.name],
|
|
|
+ };
|
|
|
+ },
|
|
|
+ }))
|
|
|
+ );
|
|
|
+ }
|
|
|
} else {
|
|
|
const defaultField: Field = Object.assign(
|
|
|
{},
|
|
@@ -342,10 +364,22 @@ class NotificationSettingsByTypeV2 extends DeprecatedAsyncComponent<Props, State
|
|
|
};
|
|
|
|
|
|
renderBody() {
|
|
|
- const {notificationType} = this.props;
|
|
|
+ const {notificationType, organizations} = this.props;
|
|
|
const {notificationOptions} = this.state;
|
|
|
const unlinkedSlackOrgs = this.getUnlinkedOrgs('slack');
|
|
|
+ const notificationDetails = ACCOUNT_NOTIFICATION_FIELDS[notificationType];
|
|
|
+ // TODO(isabella): Once GA, remove this
|
|
|
+ if (
|
|
|
+ notificationType === 'quota' &&
|
|
|
+ organizations.some(org => org.features?.includes('spend-visibility-notifications'))
|
|
|
+ ) {
|
|
|
+ notificationDetails.title = t('Spend Notifications');
|
|
|
+ notificationDetails.description = t(
|
|
|
+ 'Control the notifications you receive for organization spend.'
|
|
|
+ );
|
|
|
+ }
|
|
|
const {title, description} = ACCOUNT_NOTIFICATION_FIELDS[notificationType];
|
|
|
+
|
|
|
const entityType = isGroupedByProject(notificationType) ? 'project' : 'organization';
|
|
|
return (
|
|
|
<Fragment>
|