Commit 2432aa6
Fix stale duplicate validation for automation scripts (#2402)
The duplicate script validation used useWatch values inside the validate
closure, which are stale within the same event handler (React state hasn't
re-rendered yet). Replaced with getValues() which reads directly from
react-hook-form's internal store.
Also added deps to re-validate sibling scripts when any name changes, and
trigger all script names on guestType/scriptType change so stale errors
clear when the conflict resolves.
Resolves: MTV-4945
Signed-off-by: Aviv Turgeman <aturgema@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent a71d06a commit 2432aa6
3 files changed
Lines changed: 70 additions & 42 deletions
File tree
- src/plans
- create/steps/customization-scripts
- hooks
- details/tabs/Automation/components/ScriptEdit
Lines changed: 20 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | | - | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | 39 | | |
41 | 40 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
55 | 46 | | |
56 | 47 | | |
57 | 48 | | |
| |||
64 | 55 | | |
65 | 56 | | |
66 | 57 | | |
67 | | - | |
68 | 58 | | |
69 | 59 | | |
70 | 60 | | |
| |||
85 | 75 | | |
86 | 76 | | |
87 | 77 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
| 78 | + | |
96 | 79 | | |
97 | 80 | | |
98 | 81 | | |
| |||
115 | 98 | | |
116 | 99 | | |
117 | 100 | | |
118 | | - | |
119 | 101 | | |
120 | 102 | | |
121 | 103 | | |
122 | | - | |
123 | | - | |
| 104 | + | |
124 | 105 | | |
125 | 106 | | |
126 | 107 | | |
| |||
144 | 125 | | |
145 | 126 | | |
146 | 127 | | |
147 | | - | |
| 128 | + | |
148 | 129 | | |
149 | 130 | | |
150 | 131 | | |
| |||
172 | 153 | | |
173 | 154 | | |
174 | 155 | | |
175 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
176 | 159 | | |
177 | 160 | | |
178 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
179 | 168 | | |
180 | 169 | | |
181 | 170 | | |
| |||
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
Lines changed: 16 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | | - | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | | - | |
| 34 | + | |
33 | 35 | | |
34 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
35 | 44 | | |
36 | 45 | | |
37 | 46 | | |
| |||
62 | 71 | | |
63 | 72 | | |
64 | 73 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
| 74 | + | |
| 75 | + | |
71 | 76 | | |
72 | 77 | | |
73 | 78 | | |
| |||
96 | 101 | | |
97 | 102 | | |
98 | 103 | | |
99 | | - | |
| 104 | + | |
100 | 105 | | |
101 | 106 | | |
102 | 107 | | |
| |||
120 | 125 | | |
121 | 126 | | |
122 | 127 | | |
123 | | - | |
| 128 | + | |
124 | 129 | | |
125 | 130 | | |
126 | 131 | | |
| |||
0 commit comments