-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Synonyms UI] Synonyms UI base plugin #203284
base: main
Are you sure you want to change the base?
Conversation
7db5d71
to
ba7c1f4
Compare
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.
It would be good to also add enabling the feature flag in this serverless config.feature_flags.ts and adding some very light FTRs with these changes as well. Just something that checks for the page to render or the link in the side nav that would give a place to build from.
You'll also want to add the app id to the apps list in the serverless FTR config.
And we would need to do the same in x-pack/test/functional/config.base.js when we want to add FTRs functional_search.
core: CoreSetup<AppPluginStartDependencies, SearchSynonymsPluginStart>, | ||
_: AppPluginSetupDependencies | ||
): SearchSynonymsPluginSetup { | ||
if (!this.config.ui?.enabled && !core.uiSettings.get<boolean>(SYNONYMS_UI_FLAG, false)) { |
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'm not sure we need the config.ui
for this plugin. Those were added for the other plugins to share backend without sharing the frontend. Now that these plugins should always use both I think we can leave this out.
|
||
defineRoutes({ router, logger: this.logger }); | ||
|
||
plugins.features.registerKibanaFeature({ |
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.
❤️
privileges: { | ||
all: { | ||
app: ['kibana', PLUGIN_ID], | ||
api: [], |
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.
we should have privileges for the APIs as well as the UI since we're handling the KibanaFeature
from creation.
}, | ||
ui: [], | ||
}, | ||
read: { |
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.
We should implement read privileges with the feature so that we don't have to add it later. We should be able to follow other plugin (not search) for examples.
This will mean that you'll need to setup APIs with correct privileges as well for read vs all.
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 experimented a bit on this, I will update these with the next PR where I actually use them otherwise it will complicate. Also will include a cluster permission registration as well since we need those for the APIs.
Do you think changing these freely until we release the feature would cause a problem ? @TattdCodeMonkey
|
||
const configSchema = schema.object({ | ||
enabled: schema.boolean({ defaultValue: true }), | ||
ui: schema.object({ |
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.
see other comment, I think we can ditch this config value.
deepLinks: [ | ||
{ | ||
id: 'synonyms', | ||
path: PLUGIN_PATH, |
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.
PLUGIN_PATH = '/synonyms'
so the full URL path is going to be /app/elasticsearch/synonyms/synonyms
should that be /app/elasticsearch/synonyms/list
or something else? the double /synonyms
seems like it could be better.
@@ -18,6 +18,7 @@ export const SERVERLESS_ES_CONNECTORS_ID = 'serverlessConnectors'; | |||
export const SERVERLESS_ES_WEB_CRAWLERS_ID = 'serverlessWebCrawlers'; | |||
export const ES_SEARCH_PLAYGROUND_ID = 'searchPlayground'; | |||
export const SERVERLESS_ES_SEARCH_INFERENCE_ENDPOINTS_ID = 'searchInferenceEndpoints'; | |||
export const SERVERLESS_ES_SEARCH_SYNONYMS_ID = 'searchSynonyms'; |
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 we can drop SERVERLESS_
since this app id/deep link will be used in both serverless and stack.
export const SERVERLESS_ES_SEARCH_SYNONYMS_ID = 'searchSynonyms'; | |
export const ES_SEARCH_SYNONYMS_ID = 'searchSynonyms'; |
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.
Core changes LGTM
@elasticmachine merge upstream |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
async chunk count
ESLint disabled line counts
Total ESLint disabled count
History
|
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.
LGTM, code reviews only
ACK: will review PR today, sorry for the delay |
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.
Overall, LGTM, but there are a number of rough edges that I think we might want to polish before merging this. Sorry if some of the suggestions feel like nitpicking, but adding a new plugin is a rare opportunity for the platform team to share knowledge and best practices with the rest of the Kibana contributors.
Thanks!
|
||
|
||
# Synonyms UI | ||
xpack.searchSynonyms.enabled: false |
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.
note: Since the plugin is disabled for all solutions/project-types, please disable it in the serverless.yml
file instead of adding three identical entries in each solution-specific configuration file. This approach makes it much easier to reason about the plugin’s status in Serverless.
But, I’m not sure you even need anything in the configuration files since your plugin is already disabled by default through its configuration schema.
xpack.searchSynonyms.enabled: false |
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.
Yeah given that it's disabled by default, I would keep this flag out of the Serverless configs.
@@ -0,0 +1,3 @@ | |||
# Search Synonyms |
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.
@gsoldevila I know we’re relocating plugins into solution-specific folders (x-pack/solutions
) right now, but I don’t see a dedicated folder for the Search solution. Is the current recommendation to still place new plugins related to the Search solution within x-pack/plugins
?
|
||
export const config: PluginConfigDescriptor<SearchPlaygroundConfig> = { | ||
exposeToBrowser: { | ||
enabled: 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.
Caution
If the plugin is disabled, the client-side plugin won’t even be initialized to read this value. And if it’s initialized, that would implicitly mean it’s enabled. Why do you need to expose this to the browser? Do you happen to observe a different behavior?
We should only expose configuration to the browser if it’s absolutely necessary, as it increases both the initial payload size and the risk of accidentally exposing something that shouldn’t be exposed (these values are accessible to any user, authenticated or not).
} | ||
|
||
public setup(core: CoreSetup, plugins: SearchSynonymsPluginSetupDependencies) { | ||
this.logger.debug('searchSynonyms: Setup'); |
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.
question: is there any practical value in this log line (trying to reduce a noise in our logs when we have to enable debug
to actually ... debug something 🙂)? Kibana already logs which plugins are enabled/disabled when it starts, and if plugin and all its required dependencies are enabled its setup
is always called.
|
||
plugins.features.registerKibanaFeature({ | ||
id: PLUGIN_ID, | ||
name: PLUGIN_NAME, |
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.
Caution
The name is user-facing and should be a localizable string, even though it currently retains its value across different languages, as this might not always be the case.
core: CoreSetup<AppPluginStartDependencies, SearchSynonymsPluginStart>, | ||
_: AppPluginSetupDependencies | ||
): SearchSynonymsPluginSetup { | ||
if (!this.config.enabled || !core.uiSettings.get<boolean>(SYNONYMS_UI_FLAG, false)) { |
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.
Caution
The core.uiSettings
is deprecated
if (!this.config.enabled || !core.uiSettings.get<boolean>(SYNONYMS_UI_FLAG, false)) { | |
if (!this.config.enabled || !core.settings.get<boolean>(SYNONYMS_UI_FLAG, false)) { |
"requiredPlugins": [ | ||
"licensing", | ||
"features", | ||
], | ||
"optionalPlugins": [ | ||
"cloud", | ||
"console", | ||
"usageCollection", | ||
"searchNavigation", | ||
], | ||
"requiredBundles": [ | ||
"kibanaReact", | ||
] |
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.
Caution
Let's only add dependencies when we know we need them.
"requiredPlugins": [ | |
"licensing", | |
"features", | |
], | |
"optionalPlugins": [ | |
"cloud", | |
"console", | |
"usageCollection", | |
"searchNavigation", | |
], | |
"requiredBundles": [ | |
"kibanaReact", | |
] | |
"requiredPlugins": [ | |
"features" | |
], | |
"optionalPlugins": [ | |
"searchNavigation" | |
], | |
"requiredBundles": [ | |
"kibanaReact" | |
] |
export interface AppPluginStartDependencies { | ||
history: AppMountParameters['history']; | ||
console?: ConsolePluginStart; | ||
searchNavigation: SearchNavigationPluginStart; |
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.
Caution
This dependency is declared as optional in the manifest, but here it's defined as required (without ?
).
import { AppMountParameters } from '@kbn/core/public'; | ||
import type { ConsolePluginStart } from '@kbn/console-plugin/public'; |
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.
optional nit: it feels a bit weird that your imports go after export
that uses them...
@@ -37,6 +37,9 @@ export default createTestConfig({ | |||
searchPlayground: { | |||
pathname: '/app/search_playground', | |||
}, | |||
searchSynonyms: { | |||
pathname: '/app/search_synonyms', |
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.
Caution
Didn't you define your appRoute
as /app/elasticsearch/synonyms
in public/plugin.ts
?
Summary
Creates a plugin for Synonyms UI implementation. It is hidden under the UI flag and config option which is off by default.
Serverless Search:
Stack Search
Checklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.
release_note:breaking
label should be applied in these situations.release_note:*
label is applied per the guidelines