-
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
[Visualize] First version of by-value visualize editor #72256
[Visualize] First version of by-value visualize editor #72256
Conversation
Fixing broken behavior and applying relevant changes Adding changes to dashboard Removing unnecessary empty line Removing unnecessary deepClone Fixing some stuff in dashboard container Extracting logic into common components Fixing eslint Fix breadcrumbs Fixing error in search interceptor Reintroduce mistakenly removed empty lines Renaming function
e693822
to
b4972da
Compare
Pinging @elastic/kibana-app (Team:KibanaApp) |
@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.
app arch changes code 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.
Tested basic behavior of Visualize app, I can confirm it works well after these changes. I didn't notice any regressions, except next one:
-
the
Save as
button works incorrect when edit a visualization through a dashboard panel:actual behavior - copies a vis without any requested info;
expected behavior - modal appears:
About edit_by_value
feature, I noticed couple of confusing things:
-
using browser's
back/forward
buttons, I trap into an empty screen since the visualization can't be loaded without data. The same thing occur if I reload a page.My suggestion is to play around with the url tracker (e.x. erase the visited visualize page or replace with the actual dashbord);
-
lack of visualization title when created through the dashboard in edit by value mode;
-
can't unlink from the saved search ( details here );
@@ -48,6 +53,9 @@ export const VisualizeApp = () => { | |||
|
|||
return ( | |||
<Switch> | |||
<Route exact path={`${VisualizeConstants.EDIT_BY_VALUE_PATH}`}> | |||
<VisualizeByValueEditor /> |
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.
What if you try instead to use the same <VisualizeEditor />
at this route, but use another effects inside when you trap into /edit_by_value
path? It seems this will help to get rid of VisualizeEditorCommon
ccomponent and code duplications between VisualizeByValueEditor <---> VisualizeEditor
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 am not sure how? Hooks need to be run in order and they don't like branching statements. I thought having separate components was actually cleaner.
eventEmitter, | ||
byValueVisInstance | ||
); | ||
const { isEmbeddableRendered, currentAppState } = useEditorUpdates( |
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 useEditorUpdates
subscribes on the appState updates (which can be changed through the url).
Seems you don't need that subscription at all?
src/plugins/visualize/public/application/utils/get_top_nav_config.tsx
Outdated
Show resolved
Hide resolved
src/plugins/visualize/public/application/utils/get_top_nav_config.tsx
Outdated
Show resolved
Hide resolved
delete savedVis.savedSearchId; | ||
delete vis.data.savedSearchId; | ||
} else { | ||
// TODO: something to do for when it's not a saved vis? |
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.
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'd really like to keep this PR as small as possible and build on it incrementally. I believe for the first pass it can work without saved search linking/unlinking.
@elasticmachine merge upstream |
Hey @sulemanof, this should be ready for another review. I addressed 3 main concerns from the last review:
As for two separate editors, I'd like to keep it this way for now. I think the separation of concerns is pretty good and it's following the implementation of the original visualize editor. Also, another side note: This is not getting released soon, so we can make incremental changes in the meantime. |
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 in chrome, and spent a little while going over the code.
This is looking quite stable overall! Splitting up the editor into three components actually resulted in far less code duplication than I thought it would, which is good to see.
One issue that I noticed is that editing a by reference visualization, then hitting save and return will duplicate the embeddable. I think what's happening here is that the visualize editor is accidentally putting the by value version of the embeddable into the state transfer service when it should just save the vis by reference and redirect back to dashboard.
Other than that, I have some additional small comments/suggestions that could be handled in this PR, or in a follow-up.
Unified Config Setting: It would be awesome for us to tie all of the embeddable by value changes behind a single config setting. I added one to the dashboard start contract recently and will update my lens PR to reference that one.
kibana/src/plugins/dashboard/config.ts
Line 23 in 5b64a4c
allowByValueEmbeddables: schema.boolean({ defaultValue: false }), |
Attribute Service / Interface: Most likely a follow up PR, but implementing the ReferenceOrValueEmbeddable
interface should be a priority so visualize embeddables work correctly with the unlink & add to library actions right out of the gate. Additionally, it'll be good to keep in mind that using the attribute service can make this implementation a lot easier.
Cancel Button: Should be a super easy addition in another PR. #70650
Save and return / Save as I think it's important to allow the user to opt out of the by value paradigm through the editor if they want to. To that end, I switched the menu bar UI in the Lens PR to include both the 'save and return' and 'save as' buttons, any time the user has arrived from a dashboard. This results in greater consistency as well, and it would be ideal if the menus worked the same in both visualize and lens.
Dashboard breadcrumb: Great implementation on this one, I'm definitely going to do the same in the lens PR. Wondering how hard it would be to make the dashboard breadcrumb into a link, which would do the same thing as the above mentioned cancel button.
Let me know when I can re-review, very excited to get this in!
Thanks for review @ThomThomson ! great catch about the duplicate embeddable being created, I believe this has been fixed now. To address some other concerns: |
💚 Build SucceededBuild metrics@kbn/optimizer bundle module count
async chunks size
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.
The duplication issue is fixed, and everything is working well - super excited to get this in!
LGTM.
A few notes for the followup PR questions:
Unified Config Setting: I actually exposed this setting in the dashboard start contract specifically so that other plugins can get access to it. The Lens PR doesn't have its own config setting anymore, and is using the dashboard one instead.
Dashboard breadcrumb: We actually already have an easy way to get back to the dashboard due to the 'originatingApp' parameter. It could call something like this:
coreStart.application.navigateToApp(embeddableEditorIncomingState?.originatingApp);
…ity for by value embeddables
* First version of new by-value editor Fixing broken behavior and applying relevant changes Adding changes to dashboard Removing unnecessary empty line Removing unnecessary deepClone Fixing some stuff in dashboard container Extracting logic into common components Fixing eslint Fix breadcrumbs Fixing error in search interceptor Reintroduce mistakenly removed empty lines Renaming function * Adding missing null check * Making typescript play nicely * Fixing failing tests * Applying PR comments * Fixing eslint errors * Fix save as behavior * Fixing HTMLElement type * Passing in setOriginatingApp parameter * Redirect back to dashboard if input is missing * Fixing i18n error * Unlink saved search * Fix duplicating embeddable by reference Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
* 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)
What is this?
This PR implements editing visualization by value inside dashboard and returning the edited visualization back to dashboard.
The idea is as follows:
Note: Sharing of the visualization by-value doesn't work yet.
Implementation details
To support this flow, I introduced a new
edit_by_value
URL and a newvisualize_byValue_editor
. When editing visualization by value, there is no need to sync state from the URL, so the flow becomes a bit simpler. Common functionality was extracted to common components/functions, but some code duplication is probably still present.What didn't change?
There should be no changes to the existing visualize editor. If something is wrong with editing visualizations from saved objects, it's likely a bug not a feature :)
How to test this?
The main focus should be on testing the existing visualize editor and that nothing is broken.
To test the new functionality, you'll need to set the
showNewVisualizeFlow
config value totrue
:kibana/src/plugins/visualize/config.ts
Line 23 in f5061c7
This requires a server restart!
Once the flag has been enabled:
a) create a dashboard
b) create a new visualization (any visualization except Lens) and add it to dashboard
c) from the panel action menu select "Edit visualization" -> this should trigger the new "by-value" editor
Where are functional/unit tests?
Incoming!
Checklist
Delete any items that are not applicable to this PR.
For maintainers