From 04ae9cb847cd54dabc9847cace25fb8a0536cf8c Mon Sep 17 00:00:00 2001 From: Tyler Ohlsen Date: Thu, 6 Jul 2023 12:16:46 -0700 Subject: [PATCH] Add TODOs (#4513) Signed-off-by: Tyler Ohlsen --- .../object_view/saved_object_view.tsx | 3 +++ .../public/triggers/saved_object_delete_trigger.ts | 7 +++---- .../public/actions/saved_object_delete_action.ts | 3 +++ .../public/embeddable/visualize_embeddable.ts | 11 ++++++++--- .../application/components/visualize_listing.tsx | 4 ++++ 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/plugins/saved_objects_management/public/management_section/object_view/saved_object_view.tsx b/src/plugins/saved_objects_management/public/management_section/object_view/saved_object_view.tsx index 47691fcdbb47..30627e69084c 100644 --- a/src/plugins/saved_objects_management/public/management_section/object_view/saved_object_view.tsx +++ b/src/plugins/saved_objects_management/public/management_section/object_view/saved_object_view.tsx @@ -170,6 +170,9 @@ export class SavedObjectEdition extends Component< buttonColor: 'danger', } ); + // TODO: This trigger should be maintained and emitted by the saved objects plugin + // when an obj is deleted. Tracking issue: + // https://github.com/opensearch-project/OpenSearch-Dashboards/issues/4499 if (confirmed) { this.props.uiActions .getTrigger(SAVED_OBJECT_DELETE_TRIGGER) diff --git a/src/plugins/saved_objects_management/public/triggers/saved_object_delete_trigger.ts b/src/plugins/saved_objects_management/public/triggers/saved_object_delete_trigger.ts index 88c25155fa72..c9104ec4176a 100644 --- a/src/plugins/saved_objects_management/public/triggers/saved_object_delete_trigger.ts +++ b/src/plugins/saved_objects_management/public/triggers/saved_object_delete_trigger.ts @@ -7,11 +7,10 @@ import { i18n } from '@osd/i18n'; import { Trigger } from '../../../ui_actions/public'; /** - * This action is currently being used behind-the-scenes in the vis_augmenter plugin + * TODO: This action is currently being used behind-the-scenes in the vis_augmenter plugin * to clean up related augment-vis saved objects when a visualization is deleted. - * This could be improved upon by potentially moving and maintaining this in the - * saved_objects plugin, expanding to other situations where automatic cleanup may - * be helpful, and communicating this better on the UI (modals, callouts, etc.) + * This should be moved and maintained by the saved objects plugin. Tracking issue: + * https://github.com/opensearch-project/OpenSearch-Dashboards/issues/4499 */ export const SAVED_OBJECT_DELETE_TRIGGER = 'SAVED_OBJECT_DELETE_TRIGGER'; export const savedObjectDeleteTrigger: Trigger<'SAVED_OBJECT_DELETE_TRIGGER'> = { diff --git a/src/plugins/vis_augmenter/public/actions/saved_object_delete_action.ts b/src/plugins/vis_augmenter/public/actions/saved_object_delete_action.ts index aa03ac67bdd5..56194e281540 100644 --- a/src/plugins/vis_augmenter/public/actions/saved_object_delete_action.ts +++ b/src/plugins/vis_augmenter/public/actions/saved_object_delete_action.ts @@ -36,6 +36,9 @@ export class SavedObjectDeleteAction implements Action * If deletion of a vis saved object has been triggered, we want to clean up * any augment-vis saved objects that have a reference to this vis since it * is now stale. + * TODO: this should be automatically handled by the saved objects plugin, instead + * of this specific scenario in the vis_augmenter plugin. Tracking issue: + * https://github.com/opensearch-project/OpenSearch-Dashboards/issues/4499 */ public async execute({ type, savedObjectId }: SavedObjectDeleteContext) { if (!(await this.isCompatible({ type, savedObjectId }))) { diff --git a/src/plugins/visualizations/public/embeddable/visualize_embeddable.ts b/src/plugins/visualizations/public/embeddable/visualize_embeddable.ts index 284fbc0b4d02..e47052bfcd50 100644 --- a/src/plugins/visualizations/public/embeddable/visualize_embeddable.ts +++ b/src/plugins/visualizations/public/embeddable/visualize_embeddable.ts @@ -561,9 +561,14 @@ export class VisualizeEmbeddable )) as ExprVisLayers; const visLayers = exprVisLayers.layers; - // There may be some stale saved objs if any plugin resources have been deleted since last time - // data was fetched from them via the expression functions. Execute this trigger so any listening - // action can perform cleanup. + /** + * There may be some stale saved objs if any plugin resources have been deleted since last time + * data was fetched from them via the expression functions. Execute this trigger so any listening + * action can perform cleanup. + * + * TODO: this should be automatically handled by the saved objects plugin. Tracking issue: + * https://github.com/opensearch-project/OpenSearch-Dashboards/issues/4499 + */ getUiActions().getTrigger(PLUGIN_RESOURCE_DELETE_TRIGGER).exec({ savedObjs: augmentVisSavedObjs, visLayers, diff --git a/src/plugins/visualize/public/application/components/visualize_listing.tsx b/src/plugins/visualize/public/application/components/visualize_listing.tsx index 67c06665e4f2..5dab2f11051c 100644 --- a/src/plugins/visualize/public/application/components/visualize_listing.tsx +++ b/src/plugins/visualize/public/application/components/visualize_listing.tsx @@ -141,6 +141,10 @@ export const VisualizeListing = () => { savedObjects.client .delete(item.savedObjectType, item.id) .then(() => { + /** + * TODO: this should be automatically handled by the saved objects plugin. Tracking issue: + * https://github.com/opensearch-project/OpenSearch-Dashboards/issues/4499 + */ uiActions .getTrigger(SAVED_OBJECT_DELETE_TRIGGER) .exec({ type: item.savedObjectType, savedObjectId: item.id });