Skip to content

[Workplace Search] Wire up write view for Blocked windows#114696

Merged
scottybollinger merged 13 commits intoelastic:masterfrom
scottybollinger:scottybollinger/sync-sched-5
Oct 13, 2021
Merged

[Workplace Search] Wire up write view for Blocked windows#114696
scottybollinger merged 13 commits intoelastic:masterfrom
scottybollinger:scottybollinger/sync-sched-5

Conversation

@scottybollinger
Copy link
Contributor

@scottybollinger scottybollinger commented Oct 12, 2021

Summary

This PR wraps up the Sync Scheduling UI. It enables the form for Blocked windows and persisting to the server.

blocked_windows.mp4

image

Checklist

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
@scottybollinger scottybollinger added release_note:skip Skip the PR/issue when compiling release notes auto-backport Deprecated - use backport:version if exact versions are needed v7.16.0 labels Oct 12, 2021
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.
@scottybollinger scottybollinger marked this pull request as ready for review October 12, 2021 18:01
@scottybollinger scottybollinger requested a review from a team October 12, 2021 18:01
Syncronization -> Synchronization (+h)
Copy link
Contributor

@yakhinvadim yakhinvadim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall, just a couple questions:

Comment on lines +215 to +228
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;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it'll work, but maybe we can replace the switch statement with this?

blockedWindow[prop] = value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷

Comment on lines +48 to +50
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`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this link correct? It doesn't work for me and I'm not sure if ## is a typo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely a typo; nice catch!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double-checking, should it be the same link as SYNCHRONIZATION_DOCS_URL?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was the directive given here. Have asked for clarification. Nice catch!

@scottybollinger scottybollinger enabled auto-merge (squash) October 12, 2021 21:20
Was unable to figure out the TypeScript  but did some more digging
@scottybollinger scottybollinger enabled auto-merge (squash) October 12, 2021 23:35
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
enterpriseSearch 1.4MB 1.4MB +834.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@scottybollinger scottybollinger merged commit 3025942 into elastic:master Oct 13, 2021
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 13, 2021
…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
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Oct 13, 2021
…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>
@scottybollinger scottybollinger deleted the scottybollinger/sync-sched-5 branch March 15, 2022 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes v7.16.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants