Skip to content

Commit 1f0c6df

Browse files
committed
Added sorting; valid rows first (alphabetically)
1 parent 3a2c171 commit 1f0c6df

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

app/javascript/components/workflows/helper.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,24 @@ const rowInfo = (headers, response) => {
1717
const isValid = !!workflow.payload;
1818
return {
1919
id: workflow.id.toString(),
20+
name: workflow.name,
2021
cells: celInfo(workflow),
2122
clickable: isValid,
2223
disabled: !isValid,
2324
};
2425
});
25-
const miqRows = rowData(headerKeys, rows, false);
26+
27+
// Sort: valid workflows first (alphabetically), then invalid workflows (alphabetically)
28+
const sortedRows = rows.sort((a, b) => {
29+
// If both have same validity status, sort alphabetically by name
30+
if (a.disabled === b.disabled) {
31+
return a.name.localeCompare(b.name);
32+
}
33+
// Valid (not disabled) workflows come first
34+
return a.disabled ? 1 : -1;
35+
});
36+
37+
const miqRows = rowData(headerKeys, sortedRows, false);
2638
return miqRows.rowItems;
2739
};
2840

0 commit comments

Comments
 (0)