Browse Source

fix(alerts): add alerts permission selector to API key generation page (#81190)

As I mentioned in https://github.com/getsentry/sentry/pull/81002, there
is no option to select the alerts:write permission when generating an
API key, so members are not able to create alert rules if the member
alert creation feature is turned on (team admins are also unable to
create alert rules if the member alert creation feature is turned off).
Introduce the ability to grant this scope to API keys.
Michelle Fu 3 months ago
parent
commit
e604ffb279

+ 10 - 1
static/app/constants/index.tsx

@@ -121,8 +121,8 @@ export type PermissionChoice = {
 
 type PermissionObj = {
   choices: {
-    admin: PermissionChoice;
     'no-access': PermissionChoice;
+    admin?: PermissionChoice;
     read?: PermissionChoice;
     write?: PermissionChoice;
   };
@@ -199,6 +199,15 @@ export const SENTRY_APP_PERMISSIONS: PermissionObj[] = [
       admin: {label: 'Admin', scopes: ['member:read', 'member:write', 'member:admin']},
     },
   },
+  {
+    resource: 'Alerts',
+    help: 'Manage Alerts',
+    choices: {
+      'no-access': {label: 'No Access', scopes: []},
+      read: {label: 'Read', scopes: ['alerts:read']},
+      write: {label: 'Read & Write', scopes: ['alerts:read', 'alerts:write']},
+    },
+  },
 ];
 
 export const DEFAULT_TOAST_DURATION = 6000;

+ 1 - 0
static/app/types/integrations.tsx

@@ -23,6 +23,7 @@ export type Permissions = {
   Project: PermissionValue;
   Release: PermissionValue;
   Team: PermissionValue;
+  Alerts?: PermissionValue;
 };
 
 export type PermissionResource = keyof Permissions;

+ 1 - 0
static/app/views/settings/account/apiNewToken.tsx

@@ -37,6 +37,7 @@ export default class ApiNewToken extends Component<{}, State> {
         Project: 'no-access',
         Release: 'no-access',
         Organization: 'no-access',
+        Alerts: 'no-access',
       },
       newToken: null,
     };