-
Notifications
You must be signed in to change notification settings - Fork 57
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
bulk update separation #356
Conversation
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
@@ -46,9 +46,12 @@ export class SaveAsCurrentVisualization extends SavedQuerySaver { | |||
} | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate and unused variable?
@@ -46,9 +46,12 @@ export class SaveAsCurrentVisualization extends SavedQuerySaver { | |||
} | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- use
uuidRx.test(id.panel.id)
id
variable 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_vis
don'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
dashboards-observability/public/services/saved_objects/saved_object_client/saved_objects_actions.ts
Lines 74 to 88 in 775a77e
/** * Delete a list of objects. Assumes object is osd visualization if id is a * UUID. Rest and failed ids will then be deleted by PPL client. * * @param params - SavedObjectsDeleteBulkParams * @returns SavedObjectsDeleteResponse */ static async deleteBulk( params: SavedObjectsDeleteBulkParams ): Promise<SavedObjectsDeleteResponse> { const idMap = params.objectIdList.reduce((prev, id) => { const type = OSDSavedObjectClient.extractType(id); const key = type === '' ? 'non_osd' : type; return { ...prev, [key]: [...(prev[key] || []), id] }; }, {} as { [k in 'non_osd' | ObservabilitySavedObjectsType]: string[] });
@@ -76,9 +76,12 @@ export class SaveAsNewVisualization extends SavedQuerySaver { | |||
} | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar comments and probably define regex globally
…vability into bulk-update Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>
public/services/saved_objects/saved_object_savers/ppl/save_as_current_vis.ts
Outdated
Show resolved
Hide resolved
Signed-off-by: Derek Ho <[email protected]>
|
||
const allVisualizations = panel!.visualizations; | ||
|
||
const visualizationsWithNewPanel = addVisualizationPanel(vizId, undefined, allVisualizations); |
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.
@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:
dashboards-observability/public/components/custom_panels/helpers/add_visualization_helper.ts
Line 57 in 5f2b777
export const addVisualizationPanel = ( |
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.
Yes, this is correct for adding panels to a visualization. For replace workflow, you can use the same function and pass OldVisualizationId.
@@ -58,7 +58,7 @@ export const addVisualizationPanel = ( | |||
// client: ILegacyScopedClusterClient, | |||
// panelId: string, | |||
savedVisualizationId: string, | |||
oldVisualizationId?: string, | |||
oldVisualizationId: string | undefined, |
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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...
@@ -358,7 +356,7 @@ export const Home = ({ | |||
chrome={chrome} | |||
parentBreadcrumbs={customPanelBreadCrumbs} | |||
cloneCustomPanel={cloneCustomPanel} | |||
deleteCustomPanel={deleteCustomPanel} | |||
deleteCustomPanel={deleteCustomPanelSO} |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can modify this in a follow up PR
@@ -76,9 +83,14 @@ export class SaveAsNewVisualization extends SavedQuerySaver { | |||
} | |||
|
|||
addToPanel({ selectedPanels, saveTitle, notifications, visId }) { | |||
const { dispatch } = this.dispatchers; |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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 <[email protected]> * fix up pr Signed-off-by: Derek Ho <[email protected]> * individual panel delete SO Signed-off-by: Derek Ho <[email protected]> * also separate out on newly created ones Signed-off-by: Derek Ho <[email protected]> * resolve pr comments Signed-off-by: Derek Ho <[email protected]> * bulk update new so panels Signed-off-by: Derek Ho <[email protected]> * fix PR Signed-off-by: Derek Ho <[email protected]> --------- Signed-off-by: Derek Ho <[email protected]> (cherry picked from commit b0a87fc) Signed-off-by: Peter Fitzgibbons <[email protected]>
* bulk update separation Signed-off-by: Derek Ho <[email protected]> * fix up pr Signed-off-by: Derek Ho <[email protected]> * individual panel delete SO Signed-off-by: Derek Ho <[email protected]> * also separate out on newly created ones Signed-off-by: Derek Ho <[email protected]> * resolve pr comments Signed-off-by: Derek Ho <[email protected]> * bulk update new so panels Signed-off-by: Derek Ho <[email protected]> * fix PR Signed-off-by: Derek Ho <[email protected]> --------- Signed-off-by: Derek Ho <[email protected]>
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.