From 654a443664db267794b6387d863010bec3e49814 Mon Sep 17 00:00:00 2001 From: "Mark E. Haase" Date: Fri, 25 Aug 2023 14:17:42 -0400 Subject: [PATCH] Fix splash screen bugs If you use the menu bar to create or open a flow, it now hides the splash screen. --- .../Commands/AppCommands/GroupCommand.ts | 38 +++++++++++++++++++ .../src/store/Commands/AppCommands/index.ts | 1 + .../src/store/Stores/ContextMenuStore.ts | 14 ++++++- 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 src/attack_flow_builder/src/store/Commands/AppCommands/GroupCommand.ts diff --git a/src/attack_flow_builder/src/store/Commands/AppCommands/GroupCommand.ts b/src/attack_flow_builder/src/store/Commands/AppCommands/GroupCommand.ts new file mode 100644 index 00000000..14040bb3 --- /dev/null +++ b/src/attack_flow_builder/src/store/Commands/AppCommands/GroupCommand.ts @@ -0,0 +1,38 @@ +import { AppCommand } from "../AppCommand"; +import { ApplicationStore } from "@/store/StoreTypes"; + +export class GroupCommand extends AppCommand { + + /** + * The list of commands in order of application. + */ + public readonly commands: ReadonlyArray; + + /** + * Executes a series of page commands. + * @param context + * The application context. + */ + constructor(context: ApplicationStore) { + super(context); + this.commands = []; + } + + /** + * Adds a command to the group. + * @param command + * The command. + */ + public add(command: AppCommand) { + (this.commands as AppCommand[]).push(command); + } + + /** + * Applies the set of commands. + */ + public execute(): void { + for(const command of this.commands) { + command.execute(); + } + } +} diff --git a/src/attack_flow_builder/src/store/Commands/AppCommands/index.ts b/src/attack_flow_builder/src/store/Commands/AppCommands/index.ts index 4598bc6d..55dd4dc0 100644 --- a/src/attack_flow_builder/src/store/Commands/AppCommands/index.ts +++ b/src/attack_flow_builder/src/store/Commands/AppCommands/index.ts @@ -1,5 +1,6 @@ export * from "./ClearPageRecoveryBank"; export * from "./CopySelectedChildren"; +export * from "./GroupCommand"; export * from "./HideSplashMenu"; export * from "./LoadFile"; export * from "./LoadSettings"; diff --git a/src/attack_flow_builder/src/store/Stores/ContextMenuStore.ts b/src/attack_flow_builder/src/store/Stores/ContextMenuStore.ts index a531e22b..fa321875 100644 --- a/src/attack_flow_builder/src/store/Stores/ContextMenuStore.ts +++ b/src/attack_flow_builder/src/store/Stores/ContextMenuStore.ts @@ -61,13 +61,23 @@ export default { { text: "New File", type: MenuType.Item, - data: () => App.LoadFile.fromNew(ctx), + data: async () => { + const cmd = new App.GroupCommand(ctx); + cmd.add(await App.LoadFile.fromNew(ctx)); + cmd.add(new App.HideSplashMenu(ctx)); + return cmd; + }, shortcut: file.new_file, }, { text: `Open File...`, type: MenuType.Item, - data: () => App.LoadFile.fromFileSystem(ctx), + data: async () => { + const cmd = new App.GroupCommand(ctx); + cmd.add(await App.LoadFile.fromFileSystem(ctx)); + cmd.add(new App.HideSplashMenu(ctx)); + return cmd; + }, shortcut: file.open_file, } ],