-
Notifications
You must be signed in to change notification settings - Fork 919
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
Filter Saved Search Based on AppName Supported by Language #7999
Conversation
Signed-off-by: Suchit Sahoo <[email protected]>
❌ Empty Changelog SectionThe Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7999 +/- ##
==========================================
- Coverage 61.09% 60.58% -0.51%
==========================================
Files 3691 3738 +47
Lines 87310 88687 +1377
Branches 13433 13789 +356
==========================================
+ Hits 53342 53735 +393
- Misses 30721 31665 +944
- Partials 3247 3287 +40
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
src/plugins/saved_objects/public/finder/saved_object_finder.tsx
Outdated
Show resolved
Hide resolved
src/plugins/saved_objects/public/finder/saved_object_finder.tsx
Outdated
Show resolved
Hide resolved
2d11aeb
to
60536f1
Compare
60536f1
to
273b68d
Compare
273b68d
to
2255d36
Compare
@@ -282,7 +282,12 @@ const getEmptyScreenProps = ( | |||
getFactory: embeddable.getEmbeddableFactory, | |||
notifications, | |||
overlays, | |||
SavedObjectFinder: getSavedObjectFinder(savedObjects, uiSettings), | |||
SavedObjectFinder: getSavedObjectFinder( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh sorry about. not catching this earlier. im not sure if we want to update the interface like this as it might be a breaking change for any plugin using this.
i see the saved objects plugin gets started up with the services and with it is the data plugin. potentially the same with the services.application? that way we don't need to update the interface. since i can see it already touches a bunch of plugins within OSD. But no positive any plugins outside this repo (non-OpenSearch project and OpenSearch project)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kavilla I tried this approach, however I see the downstream applications are directly importing the component without using the pluginStart props. Hence I decided against it.
const getSavedObjectFinder = ( | ||
savedObject: SavedObjectsStart, | ||
uiSettings: IUiSettingsClient, | ||
data: DataPublicPluginStart, | ||
application: ApplicationStart | ||
) => { | ||
return (props: SavedObjectFinderProps) => ( | ||
<SavedObjectFinderUi {...props} savedObjects={savedObject} uiSettings={uiSettings} /> | ||
<SavedObjectFinderUi | ||
{...props} | ||
savedObjects={savedObject} | ||
uiSettings={uiSettings} | ||
data={data} | ||
application={application} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kavilla If we want to do a quick fix for this breaking change, we could make the new parameters optional.
data?: DataPublicPluginStart,
application?: ApplicationStart
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @sejli I have taken your idea and made the new parameters as optional. Therefore if you don't pass in these params they should work in a similar way as before.
To highlight the non breaking nature of changes I have reverted back the changes made to the test where we were using it without the new params to ensure it does n't break the functionality elsewhere.
Signed-off-by: Suchit Sahoo <[email protected]>
919eadb
to
1fdbf88
Compare
obj.attributes?.kibanaSavedObjectMeta?.searchSourceJSON ?? null | ||
); | ||
const languageId = sourceObject?.query?.language; | ||
if (this.isSavedSearchLanguageSupported(languageId, currentAppId, this.languageService)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wonder if it makes it a little bit more scalable/safer to just have this as a pass a function
like from the dashboards it could be
SavedObjectFinder: getSavedObjectFinder(
savedObjects,
uiSettings,
searchFilterFn: (obj) => {
const sourceObject = JSON.parse(
obj.attributes?.kibanaSavedObjectMeta?.searchSourceJSON ?? null);
const languageId = sourceObject?.query?.language;
services.data.languageService?.getLanguage(languageId)?.supportedAppNames?.includes(currentAppId) ?? true;
}
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think i only worry ensuring we dont end up adding more required plugins since i know a good amount of community members hit the APIs directly and even though this is the public side the saved objects plugin has been historically didn't need to care about the application which made it reliably abstracted and enforced a pattern for developers.
do we forsee in issues with introducing these concepts of language service to the saved object finder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overall change seems safe and the default behavior without the additional parameters remains unchanged for SavedObjectFinder. The saved_object_finder.test.tsx tests all use the default version of SavedObjectFinder without the optional parameters and the behavior remains unchanged.
In the meanwhile I have created the issue #8122 , which we can use to create a more scalable version of the above when required.
* Filter Saved Search Based on AppName Supported by Language Signed-off-by: Suchit Sahoo <[email protected]> * Fixed test failures Signed-off-by: Suchit Sahoo <[email protected]> --------- Signed-off-by: Suchit Sahoo <[email protected]> (cherry picked from commit f694be4) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* Filter Saved Search Based on AppName Supported by Language Signed-off-by: Suchit Sahoo <[email protected]> * Fixed test failures Signed-off-by: Suchit Sahoo <[email protected]> --------- Signed-off-by: Suchit Sahoo <[email protected]> (cherry picked from commit f694be4) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…8125) * Filter Saved Search Based on AppName Supported by Language * Fixed test failures --------- (cherry picked from commit f694be4) Signed-off-by: Suchit Sahoo <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Description
This PR aims to filter out unsupported Saved Searches (SQL and PPL based Saved Queries are not supported for Visualization) across the application namely in Dashboards and Visualize.
Issues Resolved
Screenshot
Saved Search in Discover (contains all SQL, PPL, DQL, Lucene Searches)
Saved Search in Dashboards (contains DQL, Lucene based searches)
Saved Search in Visualize (contains DQL, Lucene based searches)
Testing the changes
Changelog
Check List
yarn test:jest
yarn test:jest_integration