diff --git a/src/services/slack.ts b/src/services/slack.ts index 4cc0d39f2..4370a8500 100644 --- a/src/services/slack.ts +++ b/src/services/slack.ts @@ -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); } - 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); } }