[Workplace Search] Wire up write view for Blocked windows#114696
[Workplace Search] Wire up write view for Blocked windows#114696scottybollinger merged 13 commits intoelastic:masterfrom
Conversation
We already added a reducer for this but forgot to implement this. Because we have shared state between the tabs, we need to overrule the unsaved changes prompt when simply navigating between tabs.
After wiring up the backend and converting to UTC, some changes to mocks and time formats had to be made.
This commit refactors to make use of the already-in-state schedule object. Previously, while wiring up the static views, I used a blockedWindows array directly on the state tree. This simplifies things so that equality checks can be done with one object.
It was hard to test removing an item from an array that doesn’t exist so I changed the code to expect the array to be present (! operator), since the other path is not possible. Also updated the server value from deletion to delete to match the API
(test was covered in previous commit)
One of the links was removed intentionally
The API omits the key when there are no items so we need to have the item removed as well in the UI state. Otherwise, removing the last item will cause the UI to say there are unsaved changes when there are not. I tried setting it as: schedule.blockedWindows = undefined but the selector did not see those as equal but deleting the key does.
Syncronization -> Synchronization (+h)
yakhinvadim
left a comment
There was a problem hiding this comment.
LGTM overall, just a couple questions:
| switch (prop) { | ||
| case 'jobType': | ||
| blockedWindow.jobType = value as SyncJobType; | ||
| break; | ||
| case 'day': | ||
| blockedWindow.day = value as DayOfWeek | 'all'; | ||
| break; | ||
| case 'start': | ||
| blockedWindow.start = value; | ||
| break; | ||
| case 'end': | ||
| blockedWindow.end = value; | ||
| break; | ||
| } |
There was a problem hiding this comment.
Not sure if it'll work, but maybe we can replace the switch statement with this?
blockedWindow[prop] = value
There was a problem hiding this comment.
This certainly would be the easiest way to do this. However, I spent well over an hour trying to make TypeScript accept this and nothing I did could please the TypeScript gods.
| export const SYNCHRONIZATION_DOCS_URL = `${DOCS_PREFIX}}/workplace-search-customizing-indexing-rules.html#workplace-search-customizing-indexing-rules`; | ||
| export const DIFFERENT_SYNC_TYPES_DOCS_URL = `${DOCS_PREFIX}}/workplace-search-customizing-indexing-rules.html#_indexing_schedule`; | ||
| export const OBJECTS_AND_ASSETS_DOCS_URL = `${DOCS_PREFIX}}/workplace-search-customizing-indexing-rules.html##workplace-search-customizing-indexing-rules`; |
There was a problem hiding this comment.
Is this link correct? It doesn't work for me and I'm not sure if ## is a typo.
There was a problem hiding this comment.
Definitely a typo; nice catch!
There was a problem hiding this comment.
Double-checking, should it be the same link as SYNCHRONIZATION_DOCS_URL?
There was a problem hiding this comment.
That was the directive given here. Have asked for clarification. Nice catch!
Was unable to figure out the TypeScript but did some more digging
💚 Build SucceededMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
…4696) * Fix unsaved changes prompt showing up between tabs We already added a reducer for this but forgot to implement this. Because we have shared state between the tabs, we need to overrule the unsaved changes prompt when simply navigating between tabs. * Fix some timezone issues After wiring up the backend and converting to UTC, some changes to mocks and time formats had to be made. * Refactor to remove blockedWindows reducer This commit refactors to make use of the already-in-state schedule object. Previously, while wiring up the static views, I used a blockedWindows array directly on the state tree. This simplifies things so that equality checks can be done with one object. * Wire up ability to remove blocked window * Fix key and remove fallback It was hard to test removing an item from an array that doesn’t exist so I changed the code to expect the array to be present (! operator), since the other path is not possible. Also updated the server value from deletion to delete to match the API * Wire up blocked windows form to change values and update state * Pass formatted blocked_windows to server (test was covered in previous commit) * Update link text, hrefs, and replace temp copy One of the links was removed intentionally * Fix typo * Fix edge case where unsaved changes shown when removing last item The API omits the key when there are no items so we need to have the item removed as well in the UI state. Otherwise, removing the last item will cause the UI to say there are unsaved changes when there are not. I tried setting it as: schedule.blockedWindows = undefined but the selector did not see those as equal but deleting the key does. * More typo fixes Syncronization -> Synchronization (+h) * Fix link address * Refactor for simplicity Was unable to figure out the TypeScript but did some more digging
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
…114743) * Fix unsaved changes prompt showing up between tabs We already added a reducer for this but forgot to implement this. Because we have shared state between the tabs, we need to overrule the unsaved changes prompt when simply navigating between tabs. * Fix some timezone issues After wiring up the backend and converting to UTC, some changes to mocks and time formats had to be made. * Refactor to remove blockedWindows reducer This commit refactors to make use of the already-in-state schedule object. Previously, while wiring up the static views, I used a blockedWindows array directly on the state tree. This simplifies things so that equality checks can be done with one object. * Wire up ability to remove blocked window * Fix key and remove fallback It was hard to test removing an item from an array that doesn’t exist so I changed the code to expect the array to be present (! operator), since the other path is not possible. Also updated the server value from deletion to delete to match the API * Wire up blocked windows form to change values and update state * Pass formatted blocked_windows to server (test was covered in previous commit) * Update link text, hrefs, and replace temp copy One of the links was removed intentionally * Fix typo * Fix edge case where unsaved changes shown when removing last item The API omits the key when there are no items so we need to have the item removed as well in the UI state. Otherwise, removing the last item will cause the UI to say there are unsaved changes when there are not. I tried setting it as: schedule.blockedWindows = undefined but the selector did not see those as equal but deleting the key does. * More typo fixes Syncronization -> Synchronization (+h) * Fix link address * Refactor for simplicity Was unable to figure out the TypeScript but did some more digging Co-authored-by: Scotty Bollinger <scotty.bollinger@elastic.co>
Summary
This PR wraps up the Sync Scheduling UI. It enables the form for Blocked windows and persisting to the server.
blocked_windows.mp4
Checklist