Skip to content

Commit

Permalink
DOP-4549 fix sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
anabellabuckvar committed Apr 17, 2024
1 parent c88f308 commit 4a8a898
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions api/handlers/slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ export async function buildEntitledGroupsList(entitlement: any, repoBranchesRepo
const buildWithSnooty = branch['buildsWithSnooty'];
if (buildWithSnooty) {
const active = branch['active'];
const repoPath = `${repoName}${directoryPath ? '/' + directoryPath : ''}/${branch['gitBranchName']}`;
const branchName = `${directoryPath ? '/' + directoryPath : ''}/${branch['gitBranchName']}`;
const repoPath = `${repoOwner}/${repoName}/${branchName}`;
let txt: string;
if (!active) {
txt = `(!inactive) ${repoPath}`;
txt = `(!inactive) ${branchName}`;
} else {
txt = repoPath;
txt = branchName;
}
options.push({
text: {
Expand All @@ -70,12 +71,15 @@ export async function buildEntitledGroupsList(entitlement: any, repoBranchesRepo
}
}

//create a sort function to sort the options by their text
const repoOption = {
label: {
type: 'plain_text',
text: repoOwner,
},
options: options.sort(),
options: options.sort((branchOne, branchTwo) => {
return branchOne.text.text.localeCompare(branchTwo.text.text);
}),
};
repoOptions.push(repoOption);
}
Expand Down

0 comments on commit 4a8a898

Please sign in to comment.