Skip to content

Commit

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

//create a sort function to sort the options by their text
//return the list of branches as a an array of objects for a given repo
//sorted by branch name
const repoOption = {
label: {
type: 'plain_text',
text: repoOwner,
text: repoName,
},
options: options.sort((branchOne, branchTwo) => {
return branchOne.text.text.localeCompare(branchTwo.text.text);
return branchTwo.text.text
.toString()
.replace(/\d+/g, (n) => +n + 100000)
.localeCompare(branchOne.text.text.toString().replace(/\d+/g, (n) => +n + 100000));
}),
};
repoOptions.push(repoOption);
}
return repoOptions;
//return repoOptions list sorted alphabetically by repo name
return repoOptions.sort((repoOne, repoTwo) => {
return repoOne.label.repoName.localeCompare(repoTwo.label.repoName);
});
}

export function getQSString(qs: string) {
Expand Down

0 comments on commit 34e3ca9

Please sign in to comment.