Browse Source

feat(team-roles): Disable retired org-roles when inviting members to org (#39869)

### With feature flag:
<img width="796" alt="Screen Shot 2022-10-10 at 4 33 31 PM"
src="https://user-images.githubusercontent.com/1748388/194972549-eadd90f3-f58b-41ad-bada-1b06d26758b5.png">

### No feature flag
<img width="792" alt="Screen Shot 2022-10-10 at 5 23 08 PM"
src="https://user-images.githubusercontent.com/1748388/194972566-baa60a51-26e3-4cea-b7e1-293aa6d90cee.png">
Danny Lee 2 years ago
parent
commit
933aee6c30

+ 30 - 16
fixtures/js-stubs/roleList.js

@@ -1,6 +1,9 @@
 export function OrgRoleList(params = [], fullAccess = false) {
   return [
     {
+      id: 'member',
+      name: 'Member',
+      desc: 'Members can view and act on events, as well as view most other data within the organization.',
       scopes: [
         'event:read',
         'event:write',
@@ -11,14 +14,17 @@ export function OrgRoleList(params = [], fullAccess = false) {
         'member:read',
         'team:read',
       ],
-      is_global: false,
-      name: 'Member',
       allowed: true,
-      id: 'member',
-      desc: 'Members can view and act on events, as well as view most other data within the organization.',
+      isAllowed: true,
+      is_global: false,
+      isGlobal: false,
+      isRetired: false,
       minimumTeamRole: 'contributor',
     },
     {
+      id: 'admin',
+      name: 'Admin',
+      desc: "Admin privileges on any teams of which they're a member. They can create new teams and projects, as well as remove teams and projects on which they already hold membership (or all teams, if open membership is enabled). Additionally, they can manage memberships of teams that they are members of. They cannot invite members to the organization.",
       scopes: [
         'event:read',
         'event:write',
@@ -34,14 +40,17 @@ export function OrgRoleList(params = [], fullAccess = false) {
         'team:write',
         'org:integrations',
       ],
-      is_global: false,
-      name: 'Admin',
       allowed: fullAccess,
-      id: 'admin',
-      desc: "Admin privileges on any teams of which they're a member. They can create new teams and projects, as well as remove teams and projects on which they already hold membership (or all teams, if open membership is enabled). Additionally, they can manage memberships of teams that they are members of. They cannot invite members to the organization.",
+      isAllowed: fullAccess,
+      is_global: false,
+      isGlobal: false,
+      isRetired: false,
       minimumTeamRole: 'admin',
     },
     {
+      id: 'manager',
+      name: 'Manager',
+      desc: 'Gains admin access on all teams as well as the ability to add and remove members.',
       scopes: [
         'event:read',
         'event:write',
@@ -60,14 +69,17 @@ export function OrgRoleList(params = [], fullAccess = false) {
         'member:read',
         'team:write',
       ],
-      is_global: true,
-      name: 'Manager',
       allowed: fullAccess,
-      id: 'manager',
-      desc: 'Gains admin access on all teams as well as the ability to add and remove members.',
+      isAllowed: fullAccess,
+      is_global: true,
+      isGlobal: true,
+      isRetired: false,
       minimumTeamRole: 'admin',
     },
     {
+      id: 'owner',
+      name: 'Owner',
+      desc: 'Gains full permission across the organization. Can manage members as well as perform catastrophic operations such as removing the organization.',
       scopes: [
         'org:write',
         'member:write',
@@ -87,11 +99,11 @@ export function OrgRoleList(params = [], fullAccess = false) {
         'event:read',
         'team:write',
       ],
-      is_global: true,
-      name: 'Owner',
       allowed: fullAccess,
-      id: 'owner',
-      desc: 'Gains full permission across the organization. Can manage members as well as perform catastrophic operations such as removing the organization.',
+      isAllowed: fullAccess,
+      is_global: true,
+      isGlobal: true,
+      isRetired: false,
       minimumTeamRole: 'admin',
     },
     ...params,
@@ -116,6 +128,7 @@ export function TeamRoleList(params = []) {
         'alerts:read',
         'alerts:write',
       ],
+      isRetired: false,
     },
     {
       id: 'admin',
@@ -138,6 +151,7 @@ export function TeamRoleList(params = []) {
         'alerts:read',
         'alerts:write',
       ],
+      isRetired: false,
       is_minimum_role_for: 'admin',
     },
     ...params,

+ 1 - 1
static/app/components/roleSelectControl.tsx

@@ -30,7 +30,7 @@ function RoleSelectControl({roles, disableUnallowed, ...props}: Props) {
           ({
             value: r.id,
             label: r.name,
-            disabled: disableUnallowed && !r.allowed,
+            disabled: (disableUnallowed && !r.allowed) || r.isRetired,
             details: <Details>{r.desc}</Details>,
           } as OptionType)
       )}

+ 3 - 2
static/app/types/organization.tsx

@@ -90,12 +90,13 @@ export interface MemberRole {
   desc: string;
   id: string;
   name: string;
-  allowed?: boolean;
+  allowed?: boolean; // Deprecated: use isAllowed
+  isAllowed?: boolean;
+  isRetired?: boolean;
 }
 export interface OrgRole extends MemberRole {
   minimumTeamRole: string;
   isGlobal?: boolean;
-  isRetired?: boolean;
   is_global?: boolean; // Deprecated: use isGlobal
 }
 export interface TeamRole extends MemberRole {

+ 1 - 1
static/app/views/settings/organizationMembers/inviteMember/orgRoleSelect.tsx

@@ -54,7 +54,7 @@ class OrganizationRoleSelect extends Component<Props> {
                 <Label>
                   <Radio id={id} value={name} checked={id === roleSelected} readOnly />
                   <div style={{flex: 1, padding: '0 16px'}}>
-                    {name} {isRetired && t('(Deprecated)')}
+                    {name}
                     <TextBlock noMargin>
                       <div className="help-block">{desc}</div>
                     </TextBlock>