Skip to content

Commit 2d112a1

Browse files
committed
Displays invalid workflows in the table
1 parent 03e55ca commit 2d112a1

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

app/javascript/components/miq-data-table/index.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ const MiqDataTable = ({
128128
/** Function to identify if the row is clickable or not and the returns a class name */
129129
const classNameRow = (item) => {
130130
if (item) {
131-
const { clickable, id } = item;
131+
const { clickable, id, disabled } = item;
132+
if (disabled) return 'disabled-row';
132133
if (clickable === false) return 'simple-row';
133134
if (clickable === true || clickable === null) {
134135
return (gridChecks.includes(id)

app/javascript/components/workflows/helper.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@ const celInfo = (workflow) => [
1313
/** Function to return the row information for the list */
1414
const rowInfo = (headers, response) => {
1515
const headerKeys = headers.map((item) => item.key);
16-
const rows = response.resources.filter((item) => item.payload).map((workflow) => ({
17-
id: workflow.id.toString(), cells: celInfo(workflow), clickable: true,
18-
}));
16+
const rows = response.resources.map((workflow) => {
17+
const isValid = !!workflow.payload;
18+
return {
19+
id: workflow.id.toString(),
20+
cells: celInfo(workflow),
21+
clickable: isValid,
22+
disabled: !isValid,
23+
};
24+
});
1925
const miqRows = rowData(headerKeys, rows, false);
2026
return miqRows.rowItems;
2127
};

app/javascript/components/workflows/workflow-entry-points.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ const WorkflowEntryPoints = ({
3434

3535
/** Function to handle a row's click event. */
3636
const onSelect = (selectedItemId) => {
37+
// Find the row to check if it's disabled
38+
const selectedRow = data.list.rows.find((row) => row.id === selectedItemId);
39+
40+
// Don't allow selection of disabled rows
41+
if (selectedRow && selectedRow.disabled) {
42+
return;
43+
}
44+
3745
setData({
3846
...data,
3947
selectedItemId: (data.selectedItemId === selectedItemId) ? undefined : selectedItemId,

app/stylesheet/miq-data-table.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@
6262
cursor: pointer;
6363
}
6464

65+
&.disabled-row {
66+
opacity: 0.5;
67+
cursor: not-allowed;
68+
pointer-events: none;
69+
color: #8d8d8d;
70+
71+
&:hover {
72+
background-color: transparent;
73+
}
74+
}
75+
6576
.cell {
6677
display: flex;
6778
align-items: flex-start;

0 commit comments

Comments
 (0)