Commit c8f15b3
authored
fix: inconsistent behavior between ImportComponent and Drop on canvas (#1487)
## Description
Closes Shopify/oasis-frontend#226
Refactored component import functionality to use React Query mutations and improved event handling. The main changes include:
- Made `ComponentDuplicateDialog` wait for the import component operation to complete by adding `await`
- Replaced the deprecated `useImportComponent` hook with direct usage of the `ComponentLibraryProvider`
- Added custom DOM event handling for component library events
- Implemented loading state indicators with a spinner during component import
- Added event dispatching when components are added to the library
- Added tests for the new event-based functionality
## Type of Change
- [x] Improvement
- [x] Cleanup/Refactor
## Checklist
- [x] I have tested this does not break current pipelines / runs functionality
- [ ] I have tested the changes on staging
## Test Instructions
1. [Screen Recording 2025-12-06 at 12.18.30 PM.mov <span class="graphite__hidden">(uploaded via Graphite)</span> <img class="graphite__hidden" src="https://app.graphite.com/user-attachments/thumbnails/4afe34ee-da7b-46e2-9134-af5f70655cc2.mov" />](https://app.graphite.com/user-attachments/video/4afe34ee-da7b-46e2-9134-af5f70655cc2.mov)
[Screen Recording 2025-12-06 at 12.15.30 PM.mov <span class="graphite__hidden">(uploaded via Graphite)</span> <img class="graphite__hidden" src="https://app.graphite.com/user-attachments/thumbnails/f6f138a6-e1bf-43fb-bdd9-936a1db085fc.mov" />](https://app.graphite.com/user-attachments/video/f6f138a6-e1bf-43fb-bdd9-936a1db085fc.mov)
Import a component using the import dialog
2. Verify the loading state is displayed correctly
3. Confirm the component is successfully added to the library
4. Check that duplicate component handling works as expected
5. Test that all 3 major ways of importing works exactly same
1. Test import via "Add component" from "Used in Pipelines"
2. Test import via "Drop on canvas"
3. Test import from "Import Dialog"1 parent 861c8e9 commit c8f15b3
File tree
7 files changed
+177
-47
lines changed- src
- hooks
- providers/ComponentLibraryProvider
- services
7 files changed
+177
-47
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| |||
Lines changed: 92 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| 29 | + | |
28 | 30 | | |
29 | | - | |
30 | 31 | | |
31 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
32 | 38 | | |
33 | 39 | | |
34 | 40 | | |
| |||
42 | 48 | | |
43 | 49 | | |
44 | 50 | | |
| 51 | + | |
45 | 52 | | |
46 | 53 | | |
47 | 54 | | |
48 | 55 | | |
49 | 56 | | |
50 | 57 | | |
51 | | - | |
52 | 58 | | |
53 | 59 | | |
54 | 60 | | |
| |||
63 | 69 | | |
64 | 70 | | |
65 | 71 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | 72 | | |
82 | 73 | | |
83 | 74 | | |
| |||
114 | 105 | | |
115 | 106 | | |
116 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
117 | 159 | | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
| 160 | + | |
| 161 | + | |
125 | 162 | | |
126 | 163 | | |
127 | 164 | | |
| |||
132 | 169 | | |
133 | 170 | | |
134 | 171 | | |
135 | | - | |
| 172 | + | |
136 | 173 | | |
137 | 174 | | |
138 | 175 | | |
139 | 176 | | |
140 | 177 | | |
141 | | - | |
142 | 178 | | |
143 | 179 | | |
144 | 180 | | |
145 | | - | |
| 181 | + | |
146 | 182 | | |
147 | 183 | | |
148 | 184 | | |
149 | | - | |
150 | | - | |
| 185 | + | |
151 | 186 | | |
152 | 187 | | |
153 | 188 | | |
| |||
203 | 238 | | |
204 | 239 | | |
205 | 240 | | |
206 | | - | |
| 241 | + | |
207 | 242 | | |
208 | 243 | | |
209 | 244 | | |
| |||
263 | 298 | | |
264 | 299 | | |
265 | 300 | | |
266 | | - | |
| 301 | + | |
267 | 302 | | |
268 | 303 | | |
269 | 304 | | |
| |||
293 | 328 | | |
294 | 329 | | |
295 | 330 | | |
296 | | - | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
297 | 338 | | |
298 | 339 | | |
299 | 340 | | |
| |||
310 | 351 | | |
311 | 352 | | |
312 | 353 | | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
313 | 373 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
20 | 23 | | |
21 | 24 | | |
22 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
| |||
Lines changed: 42 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
362 | 404 | | |
363 | 405 | | |
364 | 406 | | |
| |||
Lines changed: 34 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
| |||
418 | 420 | | |
419 | 421 | | |
420 | 422 | | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
421 | 442 | | |
422 | 443 | | |
423 | 444 | | |
| |||
429 | 450 | | |
430 | 451 | | |
431 | 452 | | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
| 453 | + | |
437 | 454 | | |
438 | 455 | | |
439 | 456 | | |
| |||
454 | 471 | | |
455 | 472 | | |
456 | 473 | | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
461 | 482 | | |
462 | 483 | | |
463 | 484 | | |
464 | 485 | | |
465 | 486 | | |
466 | 487 | | |
467 | | - | |
468 | | - | |
469 | | - | |
| 488 | + | |
470 | 489 | | |
471 | 490 | | |
472 | 491 | | |
| |||
505 | 524 | | |
506 | 525 | | |
507 | 526 | | |
| 527 | + | |
| 528 | + | |
508 | 529 | | |
509 | 530 | | |
510 | 531 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
334 | | - | |
| 334 | + | |
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
| |||
0 commit comments