Skip to content

Commit

Permalink
Made shouldDisplayEditButton() a pure function.
Browse files Browse the repository at this point in the history
  • Loading branch information
tanu-chahal committed Dec 17, 2024
1 parent 510411e commit 81d9f5f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions extension-requests/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ async function createExtensionCard(data, dev) {
attributes: { class: 'edit-button', 'data-testid': 'edit-button' },
});
if (dev) {
if (shouldDisplayEditButton(data.assigneeId)) {
if (shouldDisplayEditButton(data.assigneeId, currentUserDetails)) {
extensionCardButtons.appendChild(editButton);
}
} else {
Expand Down Expand Up @@ -1455,11 +1455,10 @@ async function createExtensionCard(data, dev) {
}
}

function shouldDisplayEditButton(assigneeId) {
function shouldDisplayEditButton(assigneeId, currentUserData) {
return (
currentUserDetails &&
(assigneeId === currentUserDetails.id ||
currentUserDetails.roles.super_user)
currentUserData &&
(assigneeId === currentUserData.id || currentUserData.roles.super_user)
);
}

Expand Down

0 comments on commit 81d9f5f

Please sign in to comment.