-
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
[Dashboard First] Unlink from Library Action With ReferenceOrValueEmbeddable #74905
[Dashboard First] Unlink from Library Action With ReferenceOrValueEmbeddable #74905
Conversation
…tic#73870 to show the option
…kFromLibraryAction2
…can be treated as either by reference or by value
…tions to test the referenceOrValueEmbeddable interface.
…enceOrvalueInterface
…enceOrvalueInterface
…enceOrvalueInterface
…omson/kibana into feature/unlinkFromLibraryAction2
…kFromLibraryAction2
…kFromLibraryActionWithInterface
f8a672d
to
37cca10
Compare
Pinging @elastic/kibana-app (Team:KibanaApp) |
@@ -103,7 +104,12 @@ export class BookEmbeddable extends Embeddable<BookEmbeddableInput, BookEmbeddab | |||
}; | |||
|
|||
getInputAsValueType = async (): Promise<BookByValueInput> => { | |||
return this.attributeService.getInputAsValueType(this.input); | |||
const input = |
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.
can we simplify this statement a bit?
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 realized that getting the explicitInput
of an embeddable will be a common enough task.
The reason this is needed is so that the 'unlink' or 'add' actions don't make inherited input into explicit input.
I added a helper to the attribute service in the add to library PR #75098.:
kibana/src/plugins/dashboard/public/attribute_service/attribute_service.tsx
Lines 126 to 133 in b41eae8
public getExplicitInputFromEmbeddable(embeddable: IEmbeddable): ValType | RefType { | |
return embeddable.getRoot() && | |
(embeddable.getRoot() as Container).getInput().panels[embeddable.id].explicitInput | |
? ((embeddable.getRoot() as Container).getInput().panels[embeddable.id].explicitInput as | |
| ValType | |
| RefType) | |
: (embeddable.getInput() as ValType | RefType); | |
} |
It can be simplified a little bit with optional chaining, and I will update it to reflect that over there.
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 tested this according to instructions and can confirm adding and removing from library works as expected. Love the unit test with different scenarios, which make it very easy to follow the expected flow.
Two questions:
-
If the panel is "by value", why is it still showing in the list of panels when adding a new panel? It shouldn't live outside of the dashboard, right?
-
What happens if we save two panels with the same title? Eg:
- I have a panel, it's by value
- I clone it -> clone is by value
- I add an original to the library -> works as expected
- I add a clone to the library -> this works
We normally don't allow saving two visualizations with the same name. Is this just an example that works like this? Or will this be an expected flow from now on?
src/plugins/dashboard/public/application/actions/unlink_from_library_action.test.tsx
Outdated
Show resolved
Hide resolved
type: embeddable.type, | ||
explicitInput: { ...newInput, id: uuid.v4() }, | ||
}; | ||
dashboard.replacePanel(panelToReplace, newPanel); |
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.
not related to this PR, but really shows how much we need an updatePanel
rather than replacePanel
functionality 😞
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 absolutely agree, fingers crossed that this #74253 will handle it.
@elasticmachine merge upstream |
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
…kFromLibraryActionWithInterface
Answers to the above questions from @majagrubic
|
💚 Build SucceededBuild metrics@kbn/optimizer bundle module count
page load bundle size
History
To update your PR or re-run it, just comment with: |
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 and works great!
…eddable (elastic#74905) * Added an unlink from library action which works with the ReferenceOrValue interface. Once
* master: Skip failing test in CI (elastic#75266) [Task Manager] time out work when it overruns in poller (elastic#74980) [Drilldowns] misc improvements & fixes (elastic#75276) Small README note on bumping memory for builds (elastic#75247) [Security Solution][Detections] Adds exception modal tests (elastic#74596) [Dashboard] Sample data link does not work (elastic#75262) [Dashboard First] Unlink from Library Action With ReferenceOrValueEmbeddable (elastic#74905) [Form lib] Fix issue where serializer on fields are called on every change (elastic#75166) convert processor labels to sentence case (elastic#75278) [Monaco] Refactor the way XJSON grammar checker gets registered (elastic#75160) Clarify no documents error message when filtering by is_training (elastic#75227) [Lens] Fix crash when two layers xychart switches to pie (elastic#75267) [Observability Homepage] Fix console error because of side effect (elastic#75258) [Usage Collection] Add `legacy=true` option to the /api/stats request in the docs (elastic#75146) [ML] Functional tests - re-activate DFA test suites (elastic#75257) GS providers improvements (elastic#75174) [Visualize] First version of by-value visualize editor (elastic#72256)
…emove-header * saved-objects/version-on-create: (59 commits) remove version when loading sample data omit version from SO import/export Skip failing test in CI (elastic#75266) [Task Manager] time out work when it overruns in poller (elastic#74980) [Drilldowns] misc improvements & fixes (elastic#75276) Small README note on bumping memory for builds (elastic#75247) [Security Solution][Detections] Adds exception modal tests (elastic#74596) Revert "Revert "added missing core docs"" Revert "Revert "added version to saved object bulk creation"" [Dashboard] Sample data link does not work (elastic#75262) [Dashboard First] Unlink from Library Action With ReferenceOrValueEmbeddable (elastic#74905) [Form lib] Fix issue where serializer on fields are called on every change (elastic#75166) convert processor labels to sentence case (elastic#75278) [Monaco] Refactor the way XJSON grammar checker gets registered (elastic#75160) Clarify no documents error message when filtering by is_training (elastic#75227) [Lens] Fix crash when two layers xychart switches to pie (elastic#75267) [Observability Homepage] Fix console error because of side effect (elastic#75258) [Usage Collection] Add `legacy=true` option to the /api/stats request in the docs (elastic#75146) [ML] Functional tests - re-activate DFA test suites (elastic#75257) GS providers improvements (elastic#75174) ...
Summary
Counterpart / Opposite of #75098
Adds an embeddable panel action to unlink by reference embeddables from their library item, turning them into by value embeddables. This action should work with any embeddable that implements the
ReferenceOrValueEmbeddable
interface from #74302.How to test this?
This is just one part of a much larger change, so all changes in this PR are hidden behind a configuration value. In order for the 'by value' workflow to be made default, some architectural changes need to be completed including #67931, #71499, and #61663
you'll need to set the
allowByValueEmbeddables
config value totrue
:kibana/src/plugins/dashboard/config.ts
Line 23 in 5b64a4c
There are no production ready embeddables that implement the
ReferenceOrValueEmbeddable
yet so you will have to start the developer examples.yarn start --run-examples
Open a dashboard, and use the add panels functionality to add a Book embeddable. You should be able to then unlink it from its library item.
Checklist
For maintainers