Skip to content

Commit

Permalink
make auto layout a toolbar tool
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectronicBlueberry committed Nov 13, 2024
1 parent 1ca5505 commit 86de9ec
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
10 changes: 1 addition & 9 deletions client/src/components/Workflow/Editor/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ import { LastQueue } from "@/utils/lastQueue";
import { errorMessageAsString } from "@/utils/simple-error";
import { Services } from "../services";
import { AutoLayoutAction, InsertStepAction, useStepActions } from "./Actions/stepActions";
import { InsertStepAction, useStepActions } from "./Actions/stepActions";
import { CopyIntoWorkflowAction, SetValueActionHandler } from "./Actions/workflowActions";
import { defaultPosition } from "./composables/useDefaultStepPosition";
import { useSpecialWorkflowActivities, workflowEditorActivities } from "./modules/activities";
Expand Down Expand Up @@ -743,10 +743,6 @@ export default {
this.onUpgrade();
}
if (activityId === "workflow-auto-layout") {
this.onLayout();
}
if (activityId === "workflow-run") {
this.onRun();
}
Expand All @@ -755,10 +751,6 @@ export default {
await this.saveOrCreate();
}
},
onLayout() {
const action = new AutoLayoutAction(this.id);
this.undoRedoStore.applyAction(action);
},
onAnnotation(nodeId, newAnnotation) {
this.stepActions.setAnnotation(this.steps[nodeId], newAnnotation);
},
Expand Down
22 changes: 19 additions & 3 deletions client/src/components/Workflow/Editor/Tools/ToolBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { useMagicKeys, whenever } from "@vueuse/core";
import { BButton, BButtonGroup, BFormInput } from "bootstrap-vue";
//@ts-ignore deprecated package without types (vue 2, remove this comment on vue 3 migration)
import { BoxSelect } from "lucide-vue";
import { BoxSelect, Workflow } from "lucide-vue";
import { storeToRefs } from "pinia";
import { computed, toRefs, watch } from "vue";
Expand All @@ -27,6 +27,7 @@ import { useWorkflowStores } from "@/composables/workflowStores";
import { type CommentTool } from "@/stores/workflowEditorToolbarStore";
import { match } from "@/utils/utils";
import { AutoLayoutAction } from "../Actions/stepActions";
import { useSelectionOperations } from "./useSelectionOperations";
import { useToolLogic } from "./useToolLogic";
Expand All @@ -46,7 +47,7 @@ library.add(
faTrash
);
const { toolbarStore, undoRedoStore, commentStore } = useWorkflowStores();
const { toolbarStore, undoRedoStore, commentStore, workflowId } = useWorkflowStores();
const { snapActive, currentTool } = toRefs(toolbarStore);
const { commentOptions } = toolbarStore;
Expand Down Expand Up @@ -128,7 +129,7 @@ function onRemoveAllFreehand() {
useToolLogic();
const { ctrl_1, ctrl_2, ctrl_3, ctrl_4, ctrl_5, ctrl_6, ctrl_7, ctrl_8 } = useMagicKeys();
const { ctrl_1, ctrl_2, ctrl_3, ctrl_4, ctrl_5, ctrl_6, ctrl_7, ctrl_8, ctrl_9 } = useMagicKeys();
whenever(ctrl_1!, () => (toolbarStore.currentTool = "pointer"));
whenever(ctrl_2!, () => (toolbarStore.snapActive = !toolbarStore.snapActive));
Expand All @@ -138,6 +139,7 @@ whenever(ctrl_5!, () => (toolbarStore.currentTool = "frameComment"));
whenever(ctrl_6!, () => (toolbarStore.currentTool = "freehandComment"));
whenever(ctrl_7!, () => (toolbarStore.currentTool = "freehandEraser"));
whenever(ctrl_8!, () => (toolbarStore.currentTool = "boxSelect"));
whenever(ctrl_9!, () => autoLayout());
const toggleVisibilityButtonTitle = computed(() => {
if (toolbarVisible.value) {
Expand All @@ -148,6 +150,10 @@ const toggleVisibilityButtonTitle = computed(() => {
});
const { anySelected, selectedCountText, deleteSelection, deselectAll, duplicateSelection } = useSelectionOperations();
function autoLayout() {
undoRedoStore.applyAction(new AutoLayoutAction(workflowId));
}
</script>

<template>
Expand Down Expand Up @@ -242,6 +248,16 @@ const { anySelected, selectedCountText, deleteSelection, deselectAll, duplicateS
@click="onClickBoxSelect">
<BoxSelect />
</BButton>

<BButton
v-b-tooltip.hover.noninteractive.right
title="Auto Layout (Ctrl + 9)"
data-tool="auto_layout"
class="button"
variant="outline-primary"
@click="autoLayout">
<Workflow />
</BButton>
</template>

<BButton
Expand Down
11 changes: 0 additions & 11 deletions client/src/components/Workflow/Editor/modules/activities.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { faSave as farSave } from "@fortawesome/free-regular-svg-icons";
import {
faAlignLeft,
faDownload,
faEdit,
faHistory,
Expand Down Expand Up @@ -96,16 +95,6 @@ export const workflowEditorActivities = [
click: true,
optional: true,
},
{
title: "Auto Layout",
id: "workflow-auto-layout",
description: "Automatically align the nodes in this workflow.",
tooltip: "Automatically align nodes",
icon: faAlignLeft,
visible: true,
click: true,
optional: true,
},
{
title: "Upgrade",
id: "workflow-upgrade",
Expand Down
1 change: 1 addition & 0 deletions client/src/composables/workflowStores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export function useWorkflowStores(workflowId?: Ref<string> | string) {
const undoRedoStore = useUndoRedoStore(id);

return {
workflowId: id,
connectionStore,
stateStore,
stepStore,
Expand Down

0 comments on commit 86de9ec

Please sign in to comment.