-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Pass scoped context to tutorial providers when building tutorials #22260
Conversation
💔 Build Failed |
flaky visualize test
|
jenkins, test this |
💔 Build Failed |
For my understanding: After this PR is merged the space plugin still needs to be modified to register the contextFactory? |
That's correct, this is focused on the architecture to allow the plugins to register additional information that can be used within the tutorials. |
src/ui/tutorials_mixin.js
Outdated
return _.cloneDeep(tutorials); | ||
server.decorate('server', 'getTutorials', (request) => { | ||
const initialContext = {}; | ||
const scopedContext = scopedTutorialContextFactoryies.reduce((accumulatedContext, contextFactory) => { |
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.
nit: the plural of factory is factories.
src/ui/tutorials_mixin.js
Outdated
server.decorate('server', 'getTutorials', (request) => { | ||
const initialContext = {}; | ||
const scopedContext = scopedTutorialContextFactoryies.reduce((accumulatedContext, contextFactory) => { | ||
return { ...accumulatedContext, ...contextFactory(request) }; |
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.
Should we throw an error if we have two context factories try to set the same values?
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 have no preference.
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 don't have a strong preference either way, so LGTM!
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
💔 Build Failed |
jenkins, test this pretty please with sugar on top |
💔 Build Failed |
💚 Build Succeeded |
…astic#22260) * Pass scoped context to tutorial providers when building tutorials * only generated scoped context one time * spelling
Part of the solution to Support for Kibana Spaces in Beats modules.
Talked through a solution with @elastic/kibana-security. The conversation revolved around providing a way for plugins to decorate tutorials by registering a
contextFactory
. ThecontextFactory
is a function that is called with therequest
and returns an object of properties.tutorialSpecProvider
will now be called with an additional parameter,context
, which contains the output of all registered contextFactories merged into a single object.tutorialSpecProvider
can use thecontext
object and its properties to conditionally modify the generated tutorial spec.In the cases of spaces, the spaces plugin will decorate tutorials with a
contextFactory
that returns the spaceId. So when the tutorialSpecProvider is called, if spaces plugin is running and the request is within a space, then the context will include{ spaceId: "value"}
@ycombinator @ruflin @elastic/kibana-sharing @alexfrancoeur