-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.6] [Discover] Prevent agg based visualizations of Discover saved o…
…bjects with adhoc data views (#145583) (#146344) # Backport This will backport the following commits from `main` to `8.6`: - [[Discover] Prevent agg based visualizations of Discover saved objects with adhoc data views (#145583)](#145583) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Dmitry Tomashevich","email":"[email protected]"},"sourceCommit":{"committedDate":"2022-11-25T13:16:34Z","message":"[Discover] Prevent agg based visualizations of Discover saved objects with adhoc data views (#145583)\n\n## Summary\r\n\r\nFixes #141812\r\n\r\nThis PR preventing using Discover saved objects with adhoc data views in\r\naggregation based visualisations.\r\n\r\n### Test notes \r\n- Create Saved search based on adhoc data view in Discover\r\n- Open new Agg based visualisations list and choose one\r\n- Created Saved search shouldn't appear in the list. \r\n\r\n### Checklist\r\n\r\n\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"2c9043ab431cebbbdeb77c96aa2a5c0bc5b0ddf4","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Discover","release_note:fix","Feature:Vis Editor","auto-backport","Team:DataDiscovery","v8.6.0","v8.7.0","v8.5.2"],"number":145583,"url":"https://github.com/elastic/kibana/pull/145583","mergeCommit":{"message":"[Discover] Prevent agg based visualizations of Discover saved objects with adhoc data views (#145583)\n\n## Summary\r\n\r\nFixes #141812\r\n\r\nThis PR preventing using Discover saved objects with adhoc data views in\r\naggregation based visualisations.\r\n\r\n### Test notes \r\n- Create Saved search based on adhoc data view in Discover\r\n- Open new Agg based visualisations list and choose one\r\n- Created Saved search shouldn't appear in the list. \r\n\r\n### Checklist\r\n\r\n\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"2c9043ab431cebbbdeb77c96aa2a5c0bc5b0ddf4"}},"sourceBranch":"main","suggestedTargetBranches":["8.6","8.5"],"targetPullRequestStates":[{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/145583","number":145583,"mergeCommit":{"message":"[Discover] Prevent agg based visualizations of Discover saved objects with adhoc data views (#145583)\n\n## Summary\r\n\r\nFixes #141812\r\n\r\nThis PR preventing using Discover saved objects with adhoc data views in\r\naggregation based visualisations.\r\n\r\n### Test notes \r\n- Create Saved search based on adhoc data view in Discover\r\n- Open new Agg based visualisations list and choose one\r\n- Created Saved search shouldn't appear in the list. \r\n\r\n### Checklist\r\n\r\n\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"2c9043ab431cebbbdeb77c96aa2a5c0bc5b0ddf4"}},{"branch":"8.5","label":"v8.5.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Dmitry Tomashevich <[email protected]>
- Loading branch information
1 parent
0a3b9e4
commit 461c04e
Showing
13 changed files
with
94 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/plugins/visualizations/public/wizard/search_selection/show_saved_object.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import type { SimpleSavedObject } from '@kbn/core/public'; | ||
import type { FinderAttributes } from '@kbn/saved-objects-plugin/public'; | ||
import { showSavedObject } from './show_saved_object'; | ||
|
||
describe('showSavedObject', () => { | ||
it('should return true if the saved object is not a text based query', () => { | ||
const savedObject = { | ||
attributes: { isTextBasedQuery: false }, | ||
}; | ||
expect(showSavedObject(savedObject as unknown as SimpleSavedObject<FinderAttributes>)).toBe( | ||
true | ||
); | ||
}); | ||
|
||
it('should return false if the saved object is a text based query', () => { | ||
const savedObject = { | ||
attributes: { isTextBasedQuery: true }, | ||
}; | ||
expect(showSavedObject(savedObject as unknown as SimpleSavedObject<FinderAttributes>)).toBe( | ||
false | ||
); | ||
}); | ||
|
||
it('should return true if the saved object is not of an adhoc data view', () => { | ||
const savedObject = { | ||
attributes: { usesAdHocDataView: false }, | ||
}; | ||
expect(showSavedObject(savedObject as unknown as SimpleSavedObject<FinderAttributes>)).toBe( | ||
true | ||
); | ||
}); | ||
|
||
it('should return false if the saved object is of an adhoc data view', () => { | ||
const savedObject = { | ||
attributes: { usesAdHocDataView: true }, | ||
}; | ||
expect(showSavedObject(savedObject as unknown as SimpleSavedObject<FinderAttributes>)).toBe( | ||
false | ||
); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
src/plugins/visualizations/public/wizard/search_selection/show_saved_object.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import type { SimpleSavedObject, SavedObjectAttributes } from '@kbn/core/public'; | ||
import type { FinderAttributes } from '@kbn/saved-objects-plugin/public'; | ||
|
||
export interface SavedSearchesAttributes extends SavedObjectAttributes { | ||
isTextBasedQuery: boolean; | ||
usesAdHocDataView?: boolean; | ||
} | ||
|
||
export const showSavedObject = (savedObject: SimpleSavedObject<FinderAttributes>) => { | ||
const so = savedObject as unknown as SimpleSavedObject<SavedSearchesAttributes>; | ||
return !so.attributes.isTextBasedQuery && !so.attributes.usesAdHocDataView; | ||
}; |