Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC Adding a global saved query feature permission #166260

Closed
wants to merge 3 commits into from

Conversation

kertal
Copy link
Member

@kertal kertal commented Sep 12, 2023

Summary

WIP

Checklist

Delete any items that are not applicable to this PR.

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

For maintainers

Comment on lines 215 to 217
showSaveQuery={
Boolean(core.application.capabilities.globalSavedQueries?.edit) || props.showSaveQuery
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe rather as a fallback?

Suggested change
showSaveQuery={
Boolean(core.application.capabilities.globalSavedQueries?.edit) || props.showSaveQuery
}
showSaveQuery={props.showSaveQuery ?? Boolean(core.application.capabilities.globalSavedQueries?.edit)}

Copy link
Member Author

Choose a reason for hiding this comment

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

I think when introducing this privilege, it should overwrite local consumers, given it's set to true

Copy link
Contributor

Choose a reason for hiding this comment

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

But with the following code in Discover, you want to disable it for text-based searches, no?

const showSaveQuery =
    !isPlainRecord &&
    (Boolean(services.capabilities.discover.saveQuery) ||
      Boolean(services.capabilities.globalSavedQueries.edit));

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right! Great catch! I guess we would need to solve that case in search_bar.tsx, disabling save queries for ES|QL or other text based langs. This makes also more sense than just solving it in a single plugin 👍

@kibana-ci
Copy link
Collaborator

kibana-ci commented Sep 14, 2023

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #8 / buildOSSFeatures returns features excluding reporting subfeatures
  • [job] [logs] Jest Tests #8 / buildOSSFeatures returns features including reporting subfeatures
  • [job] [logs] Jest Tests #8 / buildOSSFeatures with a basic license returns the savedQueryManagement feature augmented with appropriate sub feature privileges
  • [job] [logs] Jest Tests #8 / buildOSSFeatures with a enterprise license returns the savedQueryManagement feature augmented with appropriate sub feature privileges
  • [job] [logs] Jest Tests #14 / Discover component selected data view with time field displays chart toggle
  • [job] [logs] Jest Tests #14 / Discover component selected data view without time field displays no chart toggle
  • [job] [logs] Jest Tests #14 / Discover component shows the no results error display
  • [job] [logs] Jest Tests #14 / Discover component sidebar should be closed if discover:sidebarClosed is true
  • [job] [logs] Jest Tests #14 / Discover component sidebar should be opened if discover:sidebarClosed is false
  • [job] [logs] Jest Tests #14 / Discover component sidebar should be opened if discover:sidebarClosed was not set
  • [job] [logs] Jest Tests #14 / Discover histogram layout component render should not render null if there is a search session
  • [job] [logs] Jest Tests #14 / Discover topnav component generated config of TopNavMenu config is correct when discover save permissions are assigned
  • [job] [logs] Jest Tests #14 / Discover topnav component generated config of TopNavMenu config is correct when no discover save permissions are assigned
  • [job] [logs] Jest Tests #14 / Discover topnav component search bar customization should render custom Search Bar
  • [job] [logs] Jest Tests #14 / Discover topnav component search bar customization should render CustomDataViewPicker
  • [job] [logs] Jest Tests #14 / Discover topnav component top nav customization should allow disabling default menu items
  • [job] [logs] Jest Tests #14 / Discover topnav component top nav customization should allow reordering default menu items
  • [job] [logs] Jest Tests #14 / Discover topnav component top nav customization should call getMenuItems
  • [job] [logs] Jest Tests #14 / DiscoverMainApp renders
  • [job] [logs] FTR Configs #12 / features Features /api/features with trial license should return a full feature set
  • [job] [logs] FTR Configs #12 / features Features /api/features with trial license should return a full feature set
  • [job] [logs] Jest Tests #8 / Features Plugin returns OSS + registered kibana features
  • [job] [logs] FTR Configs #39 / security (basic license) Privileges GET /api/security/privileges should return a privilege map with all known privileges, without actions
  • [job] [logs] FTR Configs #39 / security (basic license) Privileges GET /api/security/privileges should return a privilege map with all known privileges, without actions
  • [job] [logs] FTR Configs #67 / security Privileges GET /api/security/privileges should return a privilege map with all known privileges, without actions
  • [job] [logs] FTR Configs #67 / security Privileges GET /api/security/privileges should return a privilege map with all known privileges, without actions

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
discover 550.3KB 550.4KB +57.0B

Page load bundle

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

id before after diff
unifiedSearch 34.8KB 35.0KB +161.0B

History

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

Comment on lines +197 to +199
const showSaveQuery =
!isOfAggregateQueryType(query) &&
(Boolean(core.application.capabilities.savedQueryManagement?.edit) || props.showSaveQuery);
Copy link
Member Author

Choose a reason for hiding this comment

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

@davismcphee that's how it works to apply the change on unified search level.
With this the change in Discover of this PR is redundant.

Copy link
Contributor

Choose a reason for hiding this comment

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

Make sense to me! This way is better than the old way anyway since it bakes the ES|QL check directly into Unified Search without needing consumers to know or care 👍

@kertal
Copy link
Member Author

kertal commented Sep 29, 2023

closing in favor of #166937

@kertal kertal closed this Sep 29, 2023
jughosta added a commit that referenced this pull request Sep 29, 2023
…es across Kibana (#166937)

- Resolves #158173

Based on PoC #166260

## Summary

This PR adds a new "Saved Query Management" privilege with 2 options:
- `All` will override any per app privilege and will allow users to save
queries from any Kibana page
- `None` will default to per app privileges (backward-compatible option)

<img width="600" alt="Screenshot 2023-09-21 at 15 26 25"
src="https://github.com/elastic/kibana/assets/1415710/6d53548e-5c5a-4d6d-a86a-1e639cb77202">

### Checklist

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: Matthias Wilhelm <[email protected]>
Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Stratoula Kalafateli <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants