Skip to content
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

Add TODOs regarding saved obj cleanup/deletion #4513

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export class SavedObjectDeleteAction implements Action<SavedObjectDeleteContext>
* 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 }))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down