import { UMB_FOLDER_UPDATE_MODAL } from '../../modal/index.js';
import { UMB_ACTION_EVENT_CONTEXT } from '../../../../action/index.js';
import { UmbEntityActionBase, UmbRequestReloadStructureForEntityEvent } from '../../../../entity-action/index.js';
import { umbOpenModal } from '../../../../modal/index.js';
export class UmbUpdateFolderEntityAction extends UmbEntityActionBase {
    async execute() {
        if (!this.args.unique)
            throw new Error('Unique is not available');
        await umbOpenModal(this, UMB_FOLDER_UPDATE_MODAL, {
            data: {
                folderRepositoryAlias: this.args.meta.folderRepositoryAlias,
                unique: this.args.unique,
            },
        });
        const actionEventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT);
        if (!actionEventContext) {
            throw new Error('Event context not found.');
        }
        const event = new UmbRequestReloadStructureForEntityEvent({
            unique: this.args.unique,
            entityType: this.args.entityType,
        });
        actionEventContext.dispatchEvent(event);
    }
}
