Skip to content

Commit

Permalink
Use switch statement
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas-Avery committed Oct 16, 2023
1 parent 1958864 commit 890d0ad
Showing 1 changed file with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,32 @@ export function convertPotentialGranteesToApItemViewType(
let type: ApItemEnum;
let listName = granteeView.name;
let labelName = granteeView.name;
if (granteeView.type === "user") {
icon = ApItemEnumUtil.itemIcon(ApItemEnum.User);
type = ApItemEnum.User;
if (Utils.isNullOrWhitespace(granteeView.name)) {
listName = granteeView.email;
labelName = granteeView.email;
} else {
listName = `${granteeView.name} (${granteeView.email})`;
}
} else if (granteeView.type === "group") {
icon = ApItemEnumUtil.itemIcon(ApItemEnum.Group);
type = ApItemEnum.Group;
} else if (granteeView.type === "serviceAccount") {
icon = ApItemEnumUtil.itemIcon(ApItemEnum.ServiceAccount);
type = ApItemEnum.ServiceAccount;
} else if (granteeView.type === "project") {
icon = ApItemEnumUtil.itemIcon(ApItemEnum.Project);
type = ApItemEnum.Project;

switch (granteeView.type) {
case "user":
icon = ApItemEnumUtil.itemIcon(ApItemEnum.User);
type = ApItemEnum.User;
if (Utils.isNullOrWhitespace(granteeView.name)) {
listName = granteeView.email;
labelName = granteeView.email;
} else {
listName = `${granteeView.name} (${granteeView.email})`;
}
break;
case "group":
icon = ApItemEnumUtil.itemIcon(ApItemEnum.Group);
type = ApItemEnum.Group;
break;
case "serviceAccount":
icon = ApItemEnumUtil.itemIcon(ApItemEnum.ServiceAccount);
type = ApItemEnum.ServiceAccount;
break;
case "project":
icon = ApItemEnumUtil.itemIcon(ApItemEnum.Project);
type = ApItemEnum.Project;
break;
}

return {
icon: icon,
type: type,
Expand Down

0 comments on commit 890d0ad

Please sign in to comment.