Skip to content

Commit a60fc7e

Browse files
Merge pull request #9708 from elsamaryv/fix-20077-embedded-workflows
Include invalid workflows and disable them in the embedded workflow component
2 parents ea71691 + 88dda60 commit a60fc7e

File tree

9 files changed

+84
-36
lines changed

9 files changed

+84
-36
lines changed

app/javascript/components/miq-data-table/helper.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export const rowData = (headerKeys, rows, hasCheckbox) => {
133133
const rowItems = [];
134134
const mergedStatus = [];
135135
rows.forEach(({
136-
cells, id, clickable, clickId,
136+
cells, id, clickable, clickId, disabled,
137137
}) => {
138138
const requiredCells = hasCheckbox ? (cells.filter((c) => !c.is_checkbox)) : cells;
139139
const { mergedCells, merged } = mergeIcons(requiredCells);
@@ -143,6 +143,7 @@ export const rowData = (headerKeys, rows, hasCheckbox) => {
143143
result.id = id;
144144
if (clickId) result.clickId = clickId;
145145
result.clickable = clickable;
146+
if (disabled !== undefined) result.disabled = disabled;
146147
return result;
147148
}, {});
148149
rowItems.push(reducedItems);

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/miq-data-table/miq-table-cell.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ const MiqTableCell = ({
2525
const alignClass = longText ? 'vertical_align_top' : '';
2626
const longerTextClass = veryLongText ? 'truncate_longer_text' : '';
2727

28+
const cellTitle = cell.data.title ? cell.data.title : cell.value;
2829
const truncateText = (
29-
<span title={cell.value} className={classNames('bx--front-line', wrapClass, longerTextClass)}>
30+
<span title={cellTitle} className={classNames('bx--front-line', wrapClass, longerTextClass)}>
3031
{cell.value}
3132
</span>
3233
);

app/javascript/components/workflows/helper.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,30 @@ const entryPointsHeaderInfo = () => [
77
];
88

99
/** Function to return the cell data for a row item. */
10-
const cellInfo = (workflow) => [
11-
{ text: workflow.configuration_script_source ? workflow.configuration_script_source.name : '' },
12-
{ text: workflow.name },
13-
];
10+
const cellInfo = (workflow) => {
11+
const isValid = workflow.payload_valid;
12+
const workflowNameTitle = !isValid ? `${workflow.name} (${__('Invalid Workflow')})` : workflow.name;
13+
14+
return [
15+
{ text: workflow.configuration_script_source ? workflow.configuration_script_source.name : '' },
16+
{ text: workflow.name, title: workflowNameTitle },
17+
];
18+
};
1419

1520
/** Function to return the row information for the list */
1621
const rowInfo = (headers, response) => {
1722
const headerKeys = headers.map((item) => item.key);
18-
const rows = response.resources.filter((item) => item.payload).map((workflow) => ({
19-
id: workflow.id.toString(), cells: cellInfo(workflow), clickable: true,
20-
}));
23+
const rows = response.resources.map((workflow) => {
24+
const isValid = workflow.payload_valid;
25+
return {
26+
id: workflow.id.toString(),
27+
name: workflow.name,
28+
cells: cellInfo(workflow),
29+
clickable: isValid,
30+
disabled: !isValid,
31+
};
32+
});
33+
2134
const miqRows = rowData(headerKeys, rows, false);
2235
return miqRows.rowItems;
2336
};

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ const WorkflowEntryPoints = ({
9191

9292
/** Function to handle a row's click event. */
9393
const onSelect = (selectedItemId) => {
94+
// Find the row to check if it's disabled
95+
const selectedRow = data.list.rows.find((row) => row.id === selectedItemId);
96+
97+
// Don't allow selection of disabled rows
98+
if (selectedRow && selectedRow.disabled) {
99+
return;
100+
}
101+
94102
setData({
95103
...data,
96104
selectedItemId: (data.selectedItemId === selectedItemId) ? undefined : selectedItemId,
@@ -110,6 +118,15 @@ const WorkflowEntryPoints = ({
110118
http.post('/catalog/ae_tree_select_toggle?button=cancel', {}, { headers: {}, skipJsonParsing: true });
111119
}
112120
};
121+
/** Function to check if a valid workflow is selected */
122+
const isValidSelection = () => {
123+
if (!data.selectedItemId) {
124+
return false;
125+
}
126+
const selectedRow = data.list.rows.find((row) => row.id === data.selectedItemId);
127+
return selectedRow && !selectedRow.disabled;
128+
};
129+
113130
/** Function to handle the modal box apply button click event. */
114131
const onApply = () => {
115132
const seletedItem = data.list.rows.find((item) => item.id === data.selectedItemId);
@@ -138,7 +155,7 @@ const WorkflowEntryPoints = ({
138155
open
139156
modalHeading={sprintf(__('Select Embedded Workflow - %s Entry Point'), workflowTypes[type])}
140157
primaryButtonText={__('Apply')}
141-
primaryButtonDisabled={!data.selectedItemId}
158+
primaryButtonDisabled={!isValidSelection()}
142159
secondaryButtonText={__('Cancel')}
143160
onRequestSubmit={onApply}
144161
onRequestClose={onCloseModal}

app/javascript/spec/settings-compan-categories/__snapshots__/settings-company-categories.spec.js.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2458,7 +2458,7 @@ exports[`SettingsCompanyCategories component should render a SettingsCompanyCate
24582458
</span>
24592459
<span
24602460
className="bx--front-line"
2461-
title="Delete"
2461+
title="Category cannot be deleted"
24622462
>
24632463
Delete
24642464
</span>
@@ -3617,7 +3617,7 @@ exports[`SettingsCompanyCategories component should render a SettingsCompanyCate
36173617
</span>
36183618
<span
36193619
className="bx--front-line"
3620-
title="Delete"
3620+
title="Click to delete this category"
36213621
>
36223622
Delete
36233623
</span>
@@ -4776,7 +4776,7 @@ exports[`SettingsCompanyCategories component should render a SettingsCompanyCate
47764776
</span>
47774777
<span
47784778
className="bx--front-line"
4779-
title="Delete"
4779+
title="Click to delete this category"
47804780
>
47814781
Delete
47824782
</span>
@@ -5935,7 +5935,7 @@ exports[`SettingsCompanyCategories component should render a SettingsCompanyCate
59355935
</span>
59365936
<span
59375937
className="bx--front-line"
5938-
title="Delete"
5938+
title="Click to delete this category"
59395939
>
59405940
Delete
59415941
</span>

app/javascript/spec/settings-label-tag-mapping/__snapshots__/settings-label-tag-mapping.spec.js.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ exports[`SettingsLabelTagMapping component should render a SettingsLabelTagMappi
13731373
</span>
13741374
<span
13751375
className="bx--front-line"
1376-
title="Delete"
1376+
title="Click to delete this mapping"
13771377
>
13781378
Delete
13791379
</span>
@@ -1887,7 +1887,7 @@ exports[`SettingsLabelTagMapping component should render a SettingsLabelTagMappi
18871887
</span>
18881888
<span
18891889
className="bx--front-line"
1890-
title="Delete"
1890+
title="Click to delete this mapping"
18911891
>
18921892
Delete
18931893
</span>
@@ -2401,7 +2401,7 @@ exports[`SettingsLabelTagMapping component should render a SettingsLabelTagMappi
24012401
</span>
24022402
<span
24032403
className="bx--front-line"
2404-
title="Delete"
2404+
title="Click to delete this mapping"
24052405
>
24062406
Delete
24072407
</span>
@@ -2915,7 +2915,7 @@ exports[`SettingsLabelTagMapping component should render a SettingsLabelTagMappi
29152915
</span>
29162916
<span
29172917
className="bx--front-line"
2918-
title="Delete"
2918+
title="Click to delete this mapping"
29192919
>
29202920
Delete
29212921
</span>
@@ -4292,7 +4292,7 @@ exports[`SettingsLabelTagMapping component should render a SettingsLabelTagMappi
42924292
</span>
42934293
<span
42944294
className="bx--front-line"
4295-
title="Delete"
4295+
title="Click to delete this mapping"
42964296
>
42974297
Delete
42984298
</span>
@@ -4806,7 +4806,7 @@ exports[`SettingsLabelTagMapping component should render a SettingsLabelTagMappi
48064806
</span>
48074807
<span
48084808
className="bx--front-line"
4809-
title="Delete"
4809+
title="Click to delete this mapping"
48104810
>
48114811
Delete
48124812
</span>
@@ -5320,7 +5320,7 @@ exports[`SettingsLabelTagMapping component should render a SettingsLabelTagMappi
53205320
</span>
53215321
<span
53225322
className="bx--front-line"
5323-
title="Delete"
5323+
title="Click to delete this mapping"
53245324
>
53255325
Delete
53265326
</span>
@@ -5834,7 +5834,7 @@ exports[`SettingsLabelTagMapping component should render a SettingsLabelTagMappi
58345834
</span>
58355835
<span
58365836
className="bx--front-line"
5837-
title="Delete"
5837+
title="Click to delete this mapping"
58385838
>
58395839
Delete
58405840
</span>

app/javascript/spec/tenant-quota-form/__snapshots__/tenant-quota-form.spec.js.snap

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ exports[`Tenant Quota Form Component should render the manage quotas form for a
812812
labelText={
813813
<span
814814
className="bx--front-line"
815-
title=""
815+
title="Enforce a Value"
816816
>
817817
818818
</span>
@@ -830,7 +830,7 @@ exports[`Tenant Quota Form Component should render the manage quotas form for a
830830
labelText={
831831
<span
832832
className="bx--front-line"
833-
title=""
833+
title="Enforce a Value"
834834
>
835835
836836
</span>
@@ -859,7 +859,7 @@ exports[`Tenant Quota Form Component should render the manage quotas form for a
859859
>
860860
<span
861861
className="bx--front-line"
862-
title=""
862+
title="Enforce a Value"
863863
/>
864864
<span
865865
className="bx--toggle__switch"
@@ -1493,7 +1493,7 @@ exports[`Tenant Quota Form Component should render the manage quotas form for a
14931493
labelText={
14941494
<span
14951495
className="bx--front-line"
1496-
title=""
1496+
title="Enforce a Value"
14971497
>
14981498
14991499
</span>
@@ -1511,7 +1511,7 @@ exports[`Tenant Quota Form Component should render the manage quotas form for a
15111511
labelText={
15121512
<span
15131513
className="bx--front-line"
1514-
title=""
1514+
title="Enforce a Value"
15151515
>
15161516
15171517
</span>
@@ -1540,7 +1540,7 @@ exports[`Tenant Quota Form Component should render the manage quotas form for a
15401540
>
15411541
<span
15421542
className="bx--front-line"
1543-
title=""
1543+
title="Enforce a Value"
15441544
/>
15451545
<span
15461546
className="bx--toggle__switch"
@@ -2945,7 +2945,7 @@ exports[`Tenant Quota Form Component should render the manage quotas form for a
29452945
labelText={
29462946
<span
29472947
className="bx--front-line"
2948-
title=""
2948+
title="Enforce a Value"
29492949
>
29502950
29512951
</span>
@@ -2963,7 +2963,7 @@ exports[`Tenant Quota Form Component should render the manage quotas form for a
29632963
labelText={
29642964
<span
29652965
className="bx--front-line"
2966-
title=""
2966+
title="Enforce a Value"
29672967
>
29682968
29692969
</span>
@@ -2992,7 +2992,7 @@ exports[`Tenant Quota Form Component should render the manage quotas form for a
29922992
>
29932993
<span
29942994
className="bx--front-line"
2995-
title=""
2995+
title="Enforce a Value"
29962996
/>
29972997
<span
29982998
className="bx--toggle__switch"
@@ -3597,7 +3597,7 @@ exports[`Tenant Quota Form Component should render the manage quotas form for a
35973597
labelText={
35983598
<span
35993599
className="bx--front-line"
3600-
title=""
3600+
title="Enforce a Value"
36013601
>
36023602
36033603
</span>
@@ -3615,7 +3615,7 @@ exports[`Tenant Quota Form Component should render the manage quotas form for a
36153615
labelText={
36163616
<span
36173617
className="bx--front-line"
3618-
title=""
3618+
title="Enforce a Value"
36193619
>
36203620
36213621
</span>
@@ -3644,7 +3644,7 @@ exports[`Tenant Quota Form Component should render the manage quotas form for a
36443644
>
36453645
<span
36463646
className="bx--front-line"
3647-
title=""
3647+
title="Enforce a Value"
36483648
/>
36493649
<span
36503650
className="bx--toggle__switch"

app/stylesheet/miq-data-table.scss

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,21 @@ table.miq_preview {
393393
.workflows-entry-point-modal-body {
394394
.miq-data-table {
395395
margin-top: 0px;
396+
397+
tbody tr.disabled-row {
398+
opacity: 0.5 !important;
399+
cursor: not-allowed !important;
400+
color: #8d8d8d !important;
401+
background-color: #f4f4f4 !important;
402+
403+
&:hover {
404+
background-color: #f4f4f4 !important;
405+
}
406+
407+
td {
408+
color: #8d8d8d !important;
409+
}
410+
}
396411
}
397412
}
398413
}
@@ -424,4 +439,4 @@ table.miq_preview {
424439
width: 50px;
425440
padding-left: 24px;
426441
}
427-
}
442+
}

0 commit comments

Comments
 (0)