refactor: Migrate genericHelpers mixin to composable (#8220)

## Summary
- Moved out canvas loading handling to canvas store
- Tag editable routes via meta to remove router dependency from generic
helpers
- Replace all occurrences of `genericHelpers` mixin with composable and
audit usage
- Moved out `isRedirectSafe` and `getRedirectQueryParameter` out of
genericHelpers to remove dependency on router

Removing the router dependency is important, because `useRouter` and
`useRoute` compostables are only available if called from component
instance. So if composable is nested within another composable, we
wouldn't be able to use these. In this case we'd always need to inject
the router and pass it through several composables. That's why I moved
the `readonly` logic to router meta and `isRedirectSafe` and
`getRedirectQueryParameter` out as they were only used in a single
component.

---------

Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
This commit is contained in:
oleg
2024-01-05 12:23:28 +01:00
committed by GitHub
parent f53c482939
commit 184ed8e17d
38 changed files with 199 additions and 221 deletions

View File

@@ -607,7 +607,6 @@ import BinaryDataDisplay from '@/components/BinaryDataDisplay.vue';
import NodeErrorView from '@/components/Error/NodeErrorView.vue';
import JsonEditor from '@/components/JsonEditor/JsonEditor.vue';
import { genericHelpers } from '@/mixins/genericHelpers';
import type { PinDataSource } from '@/composables/usePinnedData';
import { usePinnedData } from '@/composables/usePinnedData';
import { dataPinningEventBus } from '@/event-bus';
@@ -621,6 +620,7 @@ import { useNodeHelpers } from '@/composables/useNodeHelpers';
import { useToast } from '@/composables/useToast';
import { isObject } from 'lodash-es';
import { useExternalHooks } from '@/composables/useExternalHooks';
import { useSourceControlStore } from '@/stores/sourceControl.store';
const RunDataTable = defineAsyncComponent(async () => import('@/components/RunDataTable.vue'));
const RunDataJson = defineAsyncComponent(async () => import('@/components/RunDataJson.vue'));
@@ -644,7 +644,6 @@ export default defineComponent({
RunDataHtml,
RunDataSearch,
},
mixins: [genericHelpers],
props: {
node: {
type: Object as PropType<INodeUi>,
@@ -759,7 +758,10 @@ export default defineComponent({
this.hidePinDataDiscoveryTooltip();
},
computed: {
...mapStores(useNodeTypesStore, useNDVStore, useWorkflowsStore),
...mapStores(useNodeTypesStore, useNDVStore, useWorkflowsStore, useSourceControlStore),
isReadOnlyRoute() {
return this.$route?.meta?.readOnlyCanvas === true;
},
activeNode(): INodeUi | null {
return this.ndvStore.activeNode;
},
@@ -1402,7 +1404,7 @@ export default defineComponent({
}
},
async downloadJsonData() {
const fileName = this.node!.name.replace(/[^\w\d]/g, '_');
const fileName = this.node.name.replace(/[^\w\d]/g, '_');
const blob = new Blob([JSON.stringify(this.rawInputData, null, 2)], {
type: 'application/json',
});
@@ -1413,7 +1415,7 @@ export default defineComponent({
this.binaryDataDisplayVisible = true;
this.binaryDataDisplayData = {
node: this.node!.name,
node: this.node.name,
runIndex: this.runIndex,
outputIndex: this.currentOutputIndex,
index,