bulk update separation#356
Conversation
Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
|
|
||
| addToPanel({ selectedPanels, saveTitle, notifications, visId }) { | ||
| const uuidRx = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/; | ||
| const soPanels = selectedPanels.filter((id) => id.panel.id.match(uuidRx)); |
There was a problem hiding this comment.
duplicate and unused variable?
| addToPanel({ selectedPanels, saveTitle, notifications, visId }) { | ||
| const uuidRx = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/; | ||
| const soPanels = selectedPanels.filter((id) => id.panel.id.match(uuidRx)); | ||
| const opsPanels = selectedPanels.filter((id) => !id.panel.id.match(uuidRx)); |
There was a problem hiding this comment.
- use
uuidRx.test(id.panel.id) idvariable name is not accurate- i'm not sure if the logic should be here, e.g. what happens to panels in .observability index?
save_as_current_visdon't support them anymore? - not sure if it helps but you can check .observability and .kibana visualizations handling here as reference, for example bulk delete
| } | ||
|
|
||
| addToPanel({ selectedPanels, saveTitle, notifications, visId }) { | ||
| const uuidRx = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/; |
There was a problem hiding this comment.
similar comments and probably define regex globally
…vability into bulk-update Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Derek Ho <dxho@amazon.com>
public/services/saved_objects/saved_object_savers/ppl/save_as_current_vis.ts
Outdated
Show resolved
Hide resolved
|
|
||
| const allVisualizations = panel!.visualizations; | ||
|
|
||
| const visualizationsWithNewPanel = addVisualizationPanel(vizId, undefined, allVisualizations); |
There was a problem hiding this comment.
@ps48 @joshuali925 can you verify this line makes sense? Since we want to add a viz to panel as a new one, pass in undefined into this function:
?There was a problem hiding this comment.
Yes, this is correct for adding panels to a visualization. For replace workflow, you can use the same function and pass OldVisualizationId.
| // panelId: string, | ||
| savedVisualizationId: string, | ||
| oldVisualizationId?: string, | ||
| oldVisualizationId: string | undefined, |
There was a problem hiding this comment.
I thought var?: string meant string | undefined exactly?
I've even "fixed" my own bugs many times with the ? syntax.
Thuoghts?
There was a problem hiding this comment.
Maybe... I think what it is doing is makes it optional, which it cannot be since a required parameter comes after. This gets rid of it but maybe the more right thing is to put it at the end...
| parentBreadcrumbs={customPanelBreadCrumbs} | ||
| cloneCustomPanel={cloneCustomPanel} | ||
| deleteCustomPanel={deleteCustomPanel} | ||
| deleteCustomPanel={deleteCustomPanelSO} |
There was a problem hiding this comment.
delete savedobject should be in panel_slice. Therefore, we should collapse a reference and just call dispatch(deletePanel) (or whatever) directly from <CustomPanelViewSO>. Dont' pass it in.
We're trying to eliminate all prop-drilling, especially functions.
There was a problem hiding this comment.
I can modify this in a follow up PR
| } | ||
|
|
||
| addToPanel({ selectedPanels, saveTitle, notifications, visId }) { | ||
| const { dispatch } = this.dispatchers; |
There was a problem hiding this comment.
Please consider context here, as well as SRP-SingleResponsibilityPrinciple.
Wer are inside "saved_objects/saved_object_savers".... This, despite it's name, is the Observability index re-invention of saved objects.
We don't want to add any code here. This whole module will (eventually) be deprecated/removed.
Also, wrt. SRP, although "saving things" sounds like a single responsibliity, we can see from the code that saving to SavedObject-Core (via Redux/Dispatch) is very different from using SavedObjectSavers.
These are different responsibilities.
Recommendation :
Lift the filter/split of saved-object (UUID) and Observability (non-UUID) out of this method. Pass the non-UUID into this method, and specifically call dispatch from the caller (which is a component, which is insdie React context, which has correct context for useDispatch() ). This will also remove the prop-drilling of "dispatchers".
There was a problem hiding this comment.
we can see from the code that saving to SavedObject-Core (via Redux/Dispatch) is very different from using SavedObjectSavers
Why does this happen? I didn't look into impl details but essentially the difference between saving SO vs. observability object is the client. If the client can be abstracted, then the same operation should work for both cases
There was a problem hiding this comment.
@joshuali925 @pjfitzgibbons can we merge this in as is? I understand it may not be right but theres a few other p0 items today, once we make the final go-no go call I can refactor to be correct
* bulk update separation Signed-off-by: Derek Ho <dxho@amazon.com> * fix up pr Signed-off-by: Derek Ho <dxho@amazon.com> * individual panel delete SO Signed-off-by: Derek Ho <dxho@amazon.com> * also separate out on newly created ones Signed-off-by: Derek Ho <dxho@amazon.com> * resolve pr comments Signed-off-by: Derek Ho <dxho@amazon.com> * bulk update new so panels Signed-off-by: Derek Ho <dxho@amazon.com> * fix PR Signed-off-by: Derek Ho <dxho@amazon.com> --------- Signed-off-by: Derek Ho <dxho@amazon.com> (cherry picked from commit b0a87fc) Signed-off-by: Peter Fitzgibbons <pjfitz@amazon.com>
* bulk update separation Signed-off-by: Derek Ho <dxho@amazon.com> * fix up pr Signed-off-by: Derek Ho <dxho@amazon.com> * individual panel delete SO Signed-off-by: Derek Ho <dxho@amazon.com> * also separate out on newly created ones Signed-off-by: Derek Ho <dxho@amazon.com> * resolve pr comments Signed-off-by: Derek Ho <dxho@amazon.com> * bulk update new so panels Signed-off-by: Derek Ho <dxho@amazon.com> * fix PR Signed-off-by: Derek Ho <dxho@amazon.com> --------- Signed-off-by: Derek Ho <dxho@amazon.com>
Description
Delete fixed (minus toast for delete and rename), separate out bulk update for event analytics add viz to operational panel flow. Still need to do bulk update for SO to add new and old viz
Issues Resolved
[List any issues this PR will resolve]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.