-
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
[Dashboard First] Decouple Attribute Service and By Value Embeddables #74302
[Dashboard First] Decouple Attribute Service and By Value Embeddables #74302
Conversation
…can be treated as either by reference or by value
…tions to test the referenceOrValueEmbeddable interface.
…enceOrvalueInterface
…enceOrvalueInterface
Pinging @elastic/kibana-app (Team:KibanaApp) |
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.
Looks great! Just a few small questions.
|
||
public async wrapAttributes( | ||
newAttributes: SavedObjectAttributes, | ||
useRefType: boolean, |
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.
does this need to be an explicit parameter? can we somehow figure this from attributes?
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 wrap attributes method on the attribute service is meant to transform given attributes in the exact same shape into either of the two input types. This means that somewhere there has to be an explicit switch to determine which one to use. This could potentially be split into two methods, but that would only shift the logic to the editor.
src/plugins/dashboard/public/attribute_service/attribute_service.tsx
Outdated
Show resolved
Hide resolved
const onSave = async (props: OnSaveProps): Promise<SaveResult> => { | ||
try { | ||
const wrappedInput = (await this.wrapAttributes(input.attributes, true)) as RefType; | ||
wrappedInput.title = props.newTitle; |
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.
why is this assignment needed?
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 title is assigned here because adding an embeddable to the library via the attribute service shows a save modal with the opportunity to name (or re-name) the saved 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.
It is not a saved object rename, but just embeddable panel title change? isn't it?
Is this expected?
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.
This modal shows up when adding an item to the library. That item (when it is by value) usually doesn't yet have a saved object title.
When the item already has a saved object title, like in a case where it was previously in the library, you are given the option to change the name. An improvement here would be duplicate detection, which will be added in the follow up PR which adds the actual 'add to library' action.
For book embeddables, the titling is a little strange, which is what you're picking up on I believe. They have a saved Object title input.title
and a book title input.attributes.title
. In the add flyout, they are referred to by their book title.
Edit: The title actually should be taken from the savedObjectAttributes. I have pushed an update that makes this much more aligned.
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.
Tested this on an example scenario, works as expected. I really like moving attributeService
away from embeddable plugin. I am not sure dashboard plugin is the right place to put in though. But for now, since we don't plan to use it outside the dashboard, it should be fine.
I agree about the dashboard plugin not being a permanent home for |
…enceOrvalueInterface
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, tested example plugin.
One question I am curious about: #74302 (comment)
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.
code LGTM
💚 Build SucceededBuild metrics@kbn/optimizer bundle module count
page load bundle size
History
To update your PR or re-run it, just comment with: |
…elastic#74302) * Added an interface that determines if an embeddable can be treated as either by reference or by value
* master: (28 commits) [Task manager] Prevents edge case where already running tasks are reschedule every polling interval (elastic#74606) [Security Solution] Fix the status of timelines' bulk actions (elastic#74560) Data plugin: Suggested enhance pattern (elastic#74505) Use jest.useFakeTimers instead of hard coded timeout for tooltip tests. (elastic#74642) [Security Solution][lists] Adds tests for exception lists and items part 2 (elastic#74815) [Security Solution][Resolver] fix presentation role on edgeline (elastic#74869) [Security Solution][Detections] Refactor ML calls for newest ML permissions (elastic#74582) [bin/kibana-plugin] support KP plugins instead (elastic#74604) Reduce number of indexed fields in index pattern saved object (elastic#74817) [reporting] Pass along generic parameters in high-order route handler (elastic#74892) Migrated last pieces of legacy fixture code (elastic#74470) Empty index patterns page re-design (elastic#68819) [babel] coalese some versions to prevent breaking yarn install (elastic#74864) [Dashboard First] Decouple Attribute Service and By Value Embeddables (elastic#74302) Revert "[reporting] Pass along generic parameters in high-order route handler" (elastic#74891) [reporting] Pass along generic parameters in high-order route handler (elastic#74879) [src/dev/build] implement a getBuildNumber() mock (elastic#74881) [Enterprise Search] Add solution-level side navigation (elastic#74705) [DOCS] Canvas docs 7.9 refresh (elastic#74000) [Security Solution][Resolver]Enzyme test related events closing (elastic#74811) ...
…le-buffer-with-update-of-same-id * upstream/master: (37 commits) [Task manager] Prevents edge case where already running tasks are reschedule every polling interval (elastic#74606) [Security Solution] Fix the status of timelines' bulk actions (elastic#74560) Data plugin: Suggested enhance pattern (elastic#74505) Use jest.useFakeTimers instead of hard coded timeout for tooltip tests. (elastic#74642) [Security Solution][lists] Adds tests for exception lists and items part 2 (elastic#74815) [Security Solution][Resolver] fix presentation role on edgeline (elastic#74869) [Security Solution][Detections] Refactor ML calls for newest ML permissions (elastic#74582) [bin/kibana-plugin] support KP plugins instead (elastic#74604) Reduce number of indexed fields in index pattern saved object (elastic#74817) [reporting] Pass along generic parameters in high-order route handler (elastic#74892) Migrated last pieces of legacy fixture code (elastic#74470) Empty index patterns page re-design (elastic#68819) [babel] coalese some versions to prevent breaking yarn install (elastic#74864) [Dashboard First] Decouple Attribute Service and By Value Embeddables (elastic#74302) Revert "[reporting] Pass along generic parameters in high-order route handler" (elastic#74891) [reporting] Pass along generic parameters in high-order route handler (elastic#74879) [src/dev/build] implement a getBuildNumber() mock (elastic#74881) [Enterprise Search] Add solution-level side navigation (elastic#74705) [DOCS] Canvas docs 7.9 refresh (elastic#74000) [Security Solution][Resolver]Enzyme test related events closing (elastic#74811) ...
Summary
This PR accomplishes 3 things:
It decouples the attribute service from the concept of 'by value' or 'by reference' embeddables. For this, it includes an interface,
ReferenceOrValueEmbeddable
, which can be used by actions such as the unlink from library action [Dashboard First] Unlink from Library Action #73899 and the future add to library action. Implementing the interface, will allow any embeddable to opt into the embeddables by value paradigm. Upon implementation, embeddable authors could either use the attribute_service which requires their input to be in a specific format, or implement their interface in any other way.It moves the
Attribute_service
out of the embeddable plugin and in to the dashboard plugin in order to avoid coupling embeddables and saved objects.It contains an example implementation of the
ReferenceOrValueEmbeddable
, in theBookEmbeddable
, and two example actions for adding a book to the library and unlinking a book from its library item.This PR closes #74297
Checklist
Delete any items that are not applicable to this PR.
For maintainers