Skip to content

[Controls] Add "Apply" button#174714

Merged
Heenawter merged 95 commits intoelastic:mainfrom
Heenawter:controls-apply-button_2023-01-3
Mar 12, 2024
Merged

[Controls] Add "Apply" button#174714
Heenawter merged 95 commits intoelastic:mainfrom
Heenawter:controls-apply-button_2023-01-3

Conversation

@Heenawter
Copy link
Copy Markdown
Contributor

@Heenawter Heenawter commented Jan 11, 2024

Closes #170396
Closes #135459

Summary

This PR adds the option to stop selections from being auto-applied - instead, authors can make it so that their selections are only applied once the new apply button is clicked:

Screen.Recording.2024-03-04.at.4.39.15.PM.mov

Brief Summary of Changes

  • Publishing Filters
    We used to publish the control group filters as soon as any child changed its output - however, if the apply button is enabled, this logic no longer works. So, we added an extra step to the publishing of filters:

    1. When a child's output changes, we check if the apply button is enabled
    2. If it is disabled, we publish the filters to the control group output right away (like we used to); otherwise, we push the new filters to the unpublishedFilters array.
    3. Clicking the apply button will publish the unpublishedFilters array.
  • Unsaved Changes
    We used to publish control group unsaved changes whenever anything about the children panels' persistable input changed - however, this no longer works with the apply button because we don't want selections to trigger unsaved changes when it is enabled.

    To get around this, we no longer take into account selections when checking for unsaved changes - instead, we compare the output filters from the control group to determine whether anything about the children changed. As described above, if the control group has "auto-apply selections" turned off, the control group waits to change its output until the apply button is clicked - therefore, unsaved changes will also not be triggered until the apply button is clicked. This unsaved changes logic works regardless of if the apply button is enabled or not.

  • Saved Object
    This required changes to the dashboard saved object because of how we store the control group input as part of the dashboard SO - so, we are now on a second version for the Dashboard SO. I've also made this version slightly less strict by allowing unknown attributes in the schema - that way, unknown attributes will no longer throw an error (as they do on version 1).

Checklist

For maintainers

@Heenawter Heenawter added release_note:enhancement enhancement New value added to drive a business result Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas t// backport:skip This PR does not require backporting labels Jan 11, 2024
@Heenawter Heenawter self-assigned this Jan 11, 2024
@Heenawter Heenawter force-pushed the controls-apply-button_2023-01-3 branch 2 times, most recently from c24a5e0 to 80d9080 Compare January 15, 2024 20:46
@Heenawter Heenawter force-pushed the controls-apply-button_2023-01-3 branch 2 times, most recently from b509f77 to db8aa09 Compare January 31, 2024 16:23
@Heenawter Heenawter force-pushed the controls-apply-button_2023-01-3 branch from 32536c4 to c2cc71f Compare February 5, 2024 18:03
Copy link
Copy Markdown
Contributor

@nickpeihl nickpeihl left a comment

Choose a reason for hiding this comment

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

Adding a few questions while I continue reviewing.

Comment on lines +309 to +325
<EuiFlexItem grow={false}>
<EuiButtonIcon
size="m"
disabled={!applyButtonEnabled}
iconSize="m"
display="fill"
color={'success'}
iconType={'check'}
data-test-subj="controlGroup--applyFiltersButton"
aria-label={ControlGroupStrings.management.getApplyButtonTitle(
applyButtonEnabled
)}
onClick={() => {
if (unpublishedFilters) controlGroup.publishFilters(unpublishedFilters);
}}
/>
</EuiFlexItem>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

While I understand the issue with the tooltip bug, it's still not a great experience IMO. The Refresh button above shows a tooltip on hover so I kinda wish this button also showed the tooltip. That said, this is just a small annoyance to me and probably not worth holding up the PR.

apply-button.mp4

}),
getPlayButtonDisabledTooltip: () =>
i18n.translate('controls.timeSlider.playButtonTooltip.disabled', {
defaultMessage: 'Only applicable when auto-apply selections is enabled.',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should probably align with the copy in the Control Settings. Maybe something like "Apply selections automatically" is disabled in Control Settings.

cc @amyjtechwriter

Copy link
Copy Markdown
Contributor Author

@Heenawter Heenawter Mar 7, 2024

Choose a reason for hiding this comment

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

I'm not convinced we even need this tooltip, as described in #174714 (comment).... Interested in what @andreadelrio and @amyjtechwriter think.

Copy link
Copy Markdown
Contributor Author

@Heenawter Heenawter Mar 8, 2024

Choose a reason for hiding this comment

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

Text changed in 88f418e

image

cc @amyjtechwriter

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are we allowed to remove the tooltip completely still? I'd vote for that option.

Copy link
Copy Markdown
Contributor Author

@Heenawter Heenawter Mar 11, 2024

Choose a reason for hiding this comment

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

@amyjtechwriter We've decided to keep the tooltip only in edit mode - so, with that in mind, does the copy sound okay to you?

controlStyle: { type: 'keyword', index: false, doc_values: false },
chainingSystem: { type: 'keyword', index: false, doc_values: false },
panelsJSON: { type: 'text', index: false },
showApplySelections: { type: 'boolean', index: false },
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think (@jloleysens please keep me honest here 😅) ideally the dashboard.controlGroupInput mapping in packages/kbn-check-mappings-update-cli/current_mappings.json would be similar to the lens.state mapping. The data is still stored in _source but not in separate fields. However, we might need multiple modelVersions to achieve that.

e.g.

...
"dashboard": {
    "properties": {
      "controlGroupInput": {
        "dynamic": false,
        "properties": {}
      },
...

But I wonder if we can keep the index: false, doc_values: false settings to unblock this PR and remove those fields in a separate PR later?

Copy link
Copy Markdown
Contributor

@andreadelrio andreadelrio left a comment

Choose a reason for hiding this comment

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

Left you a comment about the disabled state.

@Heenawter
Copy link
Copy Markdown
Contributor Author

Heenawter commented Mar 8, 2024

@andreadelrio Addressed in #174714 (comment) and #174714 (comment) 🙇

Copy link
Copy Markdown
Contributor

@nickpeihl nickpeihl left a comment

Choose a reason for hiding this comment

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

lgtm! thanks for getting us closer to parity on input controls!

code review and tested controls and time slider controls with and without apply button

@andreadelrio andreadelrio self-requested a review March 8, 2024 22:00
Copy link
Copy Markdown
Contributor

@andreadelrio andreadelrio left a comment

Choose a reason for hiding this comment

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

🚀 Design changes LGTM. Fantastic job @Heenawter! Exciting to see our new controls even closer to the legacy ones.

@kibana-ci
Copy link
Copy Markdown

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #55 / SLO API Tests Delete SLOs deletes new slo saved object and transforms

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
dashboard 430 429 -1

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
controls 324 332 +8

Async chunks

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

id before after diff
controls 202.3KB 201.9KB -324.0B
dashboard 383.9KB 383.9KB -43.0B
securitySolution 12.8MB 12.8MB -2.0B
total -369.0B

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
controls 16 20 +4

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
controls 42.1KB 42.5KB +328.0B
dashboard 37.3KB 37.4KB +110.0B
presentationUtil 36.2KB 36.3KB +77.0B
total +515.0B
Unknown metric groups

API count

id before after diff
controls 332 340 +8

History

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

cc @Heenawter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting enhancement New value added to drive a business result Feature:Input Control Input controls visualization impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. loe:large Large Level of Effort Project:Controls release_note:enhancement Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas t// v8.14.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Controls] Add "Apply" button [Accessibility] [Controls] Controls should inform users of instant page changes

10 participants