Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOP-4356 reverse slack modal sort #990

Merged
merged 13 commits into from
Feb 8, 2024
16 changes: 13 additions & 3 deletions src/services/slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,23 @@ export class SlackConnector implements ISlackConnector {
};
reposToShow.push(opt);
});
// THis is the limitation enforced by slack as no more 100 items are allowd in the dropdown

// This is the limitation enforced by slack as no more 100 items are allowd in the dropdown
//Sort the list so that any inactive versions are at the end and will be truncated if any items must be truncated
//'[ERROR] no more than 100 items allowed [json-pointer:/view/blocks/0/element/options]'

if (reposToShow.length > 100) {
reposToShow = reposToShow.splice(0, 100);
reposToShow = reposToShow.sort().reverse().splice(0, 100);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally using a sort method without a compare function makes me sweat but simply because Github enforces rules on owner names and repo names in respect to symbols, this is safe to me. I'm 99.99% sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm ok, do you think I should add a sort function of some ~sort?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to be the very rare time when I say you don't have to 😆

}
reposToShow.sort();

//sort versions like so: 4.1, 4.2, 4.11
reposToShow.sort((a, b) => {
return b.text.text
.toString()
.replace(/\d+/g, (n) => +n + 100000)
.localeCompare(a.text.text.toString().replace(/\d+/g, (n) => +n + 100000));
});

return this._getDropDownView(triggerId, reposToShow);
}
}
Loading