Commit 7419f4c
refactor(web): simplify optimistic rendering (#1399)
* feat(event): introduce WithId type and addId utility function
- Added a new type `WithId` to enhance event objects with a unique `_id` property.
- Implemented the `addId` function to generate and attach a MongoDB ObjectId to events, marking them as optimistic.
- Updated relevant tests to validate the functionality of the new `addId` method and ensure correct event handling during optimistic rendering.
* feat(event): implement pending event handling and cursor updates
- Introduced a new `pendingEventsSlice` to manage events in a pending state, allowing for better user experience during event creation and updates.
- Updated cursor styles and classes in various components to reflect the pending state, enhancing visual feedback for users.
- Refactored event utility functions to replace optimistic checks with pending state checks, ensuring consistent behavior across the application.
- Enhanced context menu and event components to prevent interactions when events are pending, improving usability and preventing errors during event processing.
* refactor(event): replace optimistic event handling with pending state checks
- Removed optimistic ID handling from event types and utility functions, streamlining event management.
- Updated event components and utilities to utilize a new `pendingEventsSlice`, enhancing user experience during event creation and updates.
- Refactored tests to ensure correct behavior when handling pending events, improving overall reliability.
- Adjusted context menus and event interactions to prevent actions on pending events, reducing potential errors.
* refactor(event): update pending event handling and improve state management
- Changed the data structure for pending event IDs from a Set to an array for better compatibility with existing methods.
- Updated event handling logic across various components to utilize the new array-based pending event IDs, ensuring consistent behavior.
- Enhanced the user experience by preventing interactions with events that are in a pending state, reducing potential errors during event processing.
- Refactored related tests to align with the new pending event management approach, improving overall reliability.
* test(event): add unit tests for pending event handling and selectors
- Introduced comprehensive tests for the new pending event management, including sagas and selectors.
- Verified that events are correctly added to and removed from the pending state during creation and editing processes.
- Ensured selectors accurately reflect the pending state of events, improving overall reliability and maintainability of the event handling logic.
* Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* test(SomedayEventForm): enhance hotkey functionality tests
- Updated tests for SomedayEventForm to include new hotkey functionalities.
- Mocked API calls for create, edit, and delete operations to ensure isolated testing.
- Added isDraft and isExistingEvent props to test scenarios, improving coverage for event states.
- Refactored test cases to use 'it' instead of 'test' for consistency and clarity.
* test(draft): enhance setupDraftState for improved store handling
- Updated setupDraftState function to accept an optional store parameter, allowing for better test isolation and flexibility.
- Introduced dispatchSpy option to monitor dispatch calls during tests.
- Refactored related tests in SomedayEventForm to utilize the new setupDraftState functionality, improving test coverage and reliability.
* test(draft): simplify setupDraftState and improve test integration
- Refactored setupDraftState to remove the optional store parameter, streamlining the function for better clarity and usage.
- Updated related tests in SomedayEventForm to align with the simplified setupDraftState, enhancing test reliability and maintainability.
- Introduced dispatchSpy directly in the test setup for improved monitoring of dispatch calls during tests.
* test(context-menu): add tests for ContextMenuItems and enhance pending event handling
- Introduced unit tests for ContextMenuItems to verify rendering and interaction behaviors for both pending and non-pending events.
- Updated ContextMenuItems component to disable actions (edit, duplicate, delete) for pending events, improving user experience and preventing errors.
- Enhanced GridEvent and AllDayEvents components to utilize pending event checks, ensuring consistent behavior across the application.
- Added new tests for GridEvent and AllDayEvents to validate rendering and interaction with pending events.
* test(context-menu): refactor tests for ContextMenuItems to use centralized state creation
- Introduced a new utility function, createStateWithPendingEvents, to streamline the setup of test states for pending events.
- Updated existing tests for ContextMenuItems to utilize the new state creation function, improving code clarity and maintainability.
- Removed redundant initial state definitions, enhancing the overall readability of the test cases.
* test(agenda-events): enhance tests for draggable all-day and timed agenda events
- Added tests to verify dragging behavior for events based on their pending state, ensuring that dragging is disabled for pending events and enabled for non-pending events.
- Updated type assertions for interactions to improve type safety in tests.
- Refactored initial state setup in tests to utilize a centralized state creation utility, enhancing clarity and maintainability.
* test(agenda-events): add isDisabled prop to draggable agenda events
- Introduced an `isDisabled` prop to the DraggableAllDayAgendaEvent and DraggableTimedAgendaEvent components to manage event interaction states.
- Updated tests to verify the behavior of draggable events based on the new `isDisabled` prop, ensuring accurate rendering and interaction handling.
- Removed redundant initial state setups in tests, enhancing clarity and maintainability.
* refactor(agenda-events): update AllDayAgendaEvents and TimedAgendaEvents components to utilize pending event IDs
- Refactored AllDayAgendaEvents and TimedAgendaEvents components to include the `isDisabled` prop for event interactions based on pending event IDs.
- Integrated `selectPendingEventIds` selector to manage the disabled state of draggable events, enhancing user experience by preventing interactions with pending events.
- Improved code clarity and maintainability by consolidating event handling logic across both components.
* test(DND): add test for Draggable component's disabled prop behavior
- Introduced a new test to verify the Draggable component's handling of the disabled prop, ensuring it updates correctly on rerender.
- Mocked the useDraggable hook to check calls with both true and false values for the disabled state, enhancing test coverage for dynamic prop changes.
- Removed unnecessary state management from the Draggable component, simplifying its implementation and improving clarity.
* refactor(events): reorganize event slice utilities and update imports
- Moved event-related utility functions (insert, cancel, convert) from someday.slice.ts to a new file event.slice.util.ts for better modularity and clarity.
- Updated imports in day.slice.ts and week.slice.ts to reference the new utility file, ensuring consistent usage across the event slices.
- Improved code organization by consolidating event handling logic into a dedicated utility module.
* refactor(context-menu): streamline action disabling logic in ContextMenuItems
- Introduced a helper function to determine if actions (edit, duplicate, delete) should be disabled based on the pending state.
- Simplified the rendering logic for menu items by utilizing the new helper function, improving code clarity and maintainability.
- Enhanced user experience by ensuring that disabled actions are visually indicated and non-interactive during pending states.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>1 parent 86d6c53 commit 7419f4c
File tree
43 files changed
+2098
-454
lines changed- packages/web/src
- __tests__/utils/state
- common
- types
- utils/event
- components
- ContextMenu
- DND
- ducks/events
- sagas
- selectors
- slices
- store
- views
- Calendar/components
- Draft/hooks/actions
- Event
- Grid/GridEvent
- Grid
- AllDayRow
- MainGrid
- Day
- components/Agenda/Events
- AllDayAgendaEvent
- TimedAgendaEvent
- hooks/events
- Forms
- SomedayEventForm
- hooks
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
43 files changed
+2098
-454
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
122 | 125 | | |
123 | 126 | | |
124 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | | - | |
4 | 2 | | |
5 | 3 | | |
6 | 4 | | |
| |||
9 | 7 | | |
10 | 8 | | |
11 | 9 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | 10 | | |
21 | 11 | | |
22 | 12 | | |
23 | 13 | | |
24 | 14 | | |
25 | 15 | | |
26 | 16 | | |
27 | | - | |
| 17 | + | |
28 | 18 | | |
29 | 19 | | |
30 | 20 | | |
| |||
79 | 69 | | |
80 | 70 | | |
81 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
| 3 | + | |
8 | 4 | | |
9 | 5 | | |
10 | 6 | | |
| |||
25 | 21 | | |
26 | 22 | | |
27 | 23 | | |
28 | | - | |
29 | 24 | | |
| 25 | + | |
30 | 26 | | |
31 | 27 | | |
32 | 28 | | |
| |||
43 | 39 | | |
44 | 40 | | |
45 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
46 | 57 | | |
47 | 58 | | |
48 | 59 | | |
| |||
248 | 259 | | |
249 | 260 | | |
250 | 261 | | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | 262 | | |
257 | 263 | | |
258 | | - | |
| 264 | + | |
259 | 265 | | |
260 | 266 | | |
261 | | - | |
| 267 | + | |
262 | 268 | | |
263 | 269 | | |
264 | 270 | | |
265 | 271 | | |
266 | 272 | | |
267 | | - | |
| 273 | + | |
268 | 274 | | |
269 | 275 | | |
270 | | - | |
| 276 | + | |
271 | 277 | | |
272 | 278 | | |
273 | 279 | | |
| |||
291 | 297 | | |
292 | 298 | | |
293 | 299 | | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | 300 | | |
306 | 301 | | |
307 | 302 | | |
| |||
Lines changed: 28 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| |||
333 | 332 | | |
334 | 333 | | |
335 | 334 | | |
336 | | - | |
337 | | - | |
338 | | - | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
339 | 338 | | |
340 | 339 | | |
341 | | - | |
| 340 | + | |
342 | 341 | | |
343 | | - | |
| 342 | + | |
344 | 343 | | |
345 | 344 | | |
346 | 345 | | |
| |||
358 | 357 | | |
359 | 358 | | |
360 | 359 | | |
361 | | - | |
362 | | - | |
| 360 | + | |
| 361 | + | |
363 | 362 | | |
364 | 363 | | |
365 | 364 | | |
366 | | - | |
367 | | - | |
368 | | - | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
369 | 368 | | |
370 | 369 | | |
371 | 370 | | |
372 | | - | |
| 371 | + | |
373 | 372 | | |
374 | | - | |
| 373 | + | |
375 | 374 | | |
376 | 375 | | |
377 | 376 | | |
| |||
380 | 379 | | |
381 | 380 | | |
382 | 381 | | |
383 | | - | |
| 382 | + | |
384 | 383 | | |
385 | | - | |
| 384 | + | |
386 | 385 | | |
387 | 386 | | |
388 | 387 | | |
| |||
401 | 400 | | |
402 | 401 | | |
403 | 402 | | |
404 | | - | |
405 | | - | |
| 403 | + | |
| 404 | + | |
406 | 405 | | |
407 | 406 | | |
408 | 407 | | |
409 | | - | |
410 | | - | |
411 | | - | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
412 | 411 | | |
413 | 412 | | |
414 | 413 | | |
415 | 414 | | |
416 | | - | |
| 415 | + | |
417 | 416 | | |
418 | 417 | | |
419 | 418 | | |
420 | 419 | | |
421 | 420 | | |
422 | 421 | | |
423 | 422 | | |
424 | | - | |
| 423 | + | |
425 | 424 | | |
426 | 425 | | |
427 | 426 | | |
| |||
437 | 436 | | |
438 | 437 | | |
439 | 438 | | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
444 | 443 | | |
445 | 444 | | |
446 | 445 | | |
447 | 446 | | |
448 | | - | |
| 447 | + | |
449 | 448 | | |
450 | 449 | | |
451 | 450 | | |
| |||
454 | 453 | | |
455 | 454 | | |
456 | 455 | | |
457 | | - | |
| 456 | + | |
458 | 457 | | |
459 | 458 | | |
460 | 459 | | |
461 | 460 | | |
462 | 461 | | |
463 | 462 | | |
464 | 463 | | |
465 | | - | |
| 464 | + | |
466 | 465 | | |
467 | 466 | | |
468 | 467 | | |
| |||
0 commit comments