Navigation Menu

Skip to content

Commit

Permalink
JENKINS-41360 - sort step selections (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
kzantow committed Jan 27, 2017
1 parent c341fdd commit f7a05c3
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/main/js/components/editor/AddStepSelectionSheet.jsx
Expand Up @@ -15,6 +15,33 @@ const isStepValidForSelectionUI = (step) => {
return true;
};

// JENKINS-41360
const knownStepOrder = [
'sh', // Shell Script
'echo', // Print Message
'timeout', // Enforce Time Limit
'retry', // Retry the body...
'sleep', // Sleep
'bat', // Windows Bash Script
'archiveArtifacts', // Archive The artifacts
'node', // Allocate Node
];

const stepSorter = (a,b) => {
const ai = knownStepOrder.indexOf(a.functionName);
const bi = knownStepOrder.indexOf(b.functionName);
if (ai < 0 && bi < 0) {
return a.displayName.localeCompare(b.displayName);
}
if (ai < 0) {
return 1;
}
if (bi < 0) {
return -1;
}
return ai < bi ? -1 : 1;
};

type Props = {
onClose?: () => any,
onStepSelected: (step:StepInfo) => any,
Expand Down Expand Up @@ -79,7 +106,7 @@ export class AddStepSelectionSheet extends Component<DefaultProps, Props, State>
placeholder="Find steps by name" />
</div>
<div className="editor-step-selector">
{steps && steps.filter(isStepValidForSelectionUI).filter(this.state.searchFilter).map(step =>
{steps && steps.filter(isStepValidForSelectionUI).filter(this.state.searchFilter).sort(stepSorter).map(step =>
<div tabIndex="0" onKeyPress={e => this.selectItemByKeyPress(e, step)}
onClick={() => this.addStep(step)}>
{step.displayName}
Expand Down

0 comments on commit f7a05c3

Please sign in to comment.