save action

This commit is contained in:
Niels Lyngsø
2024-03-04 11:17:33 +01:00
parent 2d7f2490d1
commit e142863407

View File

@@ -1,22 +1,17 @@
import type { UmbSaveableWorkspaceContextInterface } from '../../../../workspace-context/saveable-workspace-context.interface.js';
import { UmbWorkspaceActionBase } from '../../workspace-action-base.controller.js';
import { UMB_SAVEABLE_WORKSPACE_CONTEXT, type UmbWorkspaceActionArgs } from '@umbraco-cms/backoffice/workspace';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
// TODO: add interface for repo/partial repo/save-repo
export class UmbSaveWorkspaceAction extends UmbWorkspaceActionBase<UmbSaveableWorkspaceContextInterface> {
constructor(host: UmbControllerHost) {
super(host);
constructor(host: UmbControllerHost, args: UmbWorkspaceActionArgs<UmbSaveableWorkspaceContextInterface>) {
super(host, args);
// TODO: Could we make change label depending on the state?
// So its called 'Create' when the workspace is new and 'Save' when the workspace is not new.
}
/* TODO: we need a solution for all actions to notify the system that is has been executed.
There might be cases where we need to do something after the action has been executed.
Ex. "reset" a workspace after a save action has been executed.
*/
async execute() {
if (!this.workspaceContext) return;
this.workspaceContext.save();
const workspaceContext = await this.getContext(UMB_SAVEABLE_WORKSPACE_CONTEXT);
return workspaceContext.save();
}
}