Skip to content

Commit 329932c

Browse files
committed
Disables Apply button when no row is selected
1 parent 1f0c6df commit 329932c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ const WorkflowEntryPoints = ({
6161
http.post('/catalog/ae_tree_select_toggle?button=cancel', {}, { headers: {}, skipJsonParsing: true });
6262
}
6363
};
64+
/** Function to check if a valid workflow is selected */
65+
const isValidSelection = () => {
66+
if (!data.selectedItemId) {
67+
return false;
68+
}
69+
const selectedRow = data.list.rows.find((row) => row.id === data.selectedItemId);
70+
return selectedRow && !selectedRow.disabled;
71+
};
72+
6473
/** Function to handle the modal box apply button click event. */
6574
const onApply = () => {
6675
const seletedItem = data.list.rows.find((item) => item.id === data.selectedItemId);
@@ -89,6 +98,7 @@ const WorkflowEntryPoints = ({
8998
open
9099
modalHeading={sprintf(__('Select Embedded Workflow - %s Entry Point'), workflowTypes[type])}
91100
primaryButtonText={__('Apply')}
101+
primaryButtonDisabled={!isValidSelection()}
92102
secondaryButtonText={__('Cancel')}
93103
onRequestSubmit={onApply}
94104
onRequestClose={onCloseModal}

0 commit comments

Comments
 (0)