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:
@@ -5,18 +5,18 @@ import { BulkCommand, Command } from '@/models/history';
|
||||
import { useHistoryStore } from '@/stores/history.store';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
|
||||
import { onMounted, onUnmounted, nextTick, getCurrentInstance } from 'vue';
|
||||
import { onMounted, onUnmounted, nextTick } from 'vue';
|
||||
import { useDebounceHelper } from './useDebounce';
|
||||
import { useDeviceSupport } from 'n8n-design-system/composables/useDeviceSupport';
|
||||
import { getNodeViewTab } from '@/utils/canvasUtils';
|
||||
import type { Route } from 'vue-router';
|
||||
import { useTelemetry } from './useTelemetry';
|
||||
|
||||
const UNDO_REDO_DEBOUNCE_INTERVAL = 100;
|
||||
const ELEMENT_UI_OVERLAY_SELECTOR = '.el-overlay';
|
||||
|
||||
export function useHistoryHelper(activeRoute: Route) {
|
||||
const instance = getCurrentInstance();
|
||||
const telemetry = instance?.proxy.$telemetry;
|
||||
const telemetry = useTelemetry();
|
||||
|
||||
const ndvStore = useNDVStore();
|
||||
const historyStore = useHistoryStore();
|
||||
@@ -85,9 +85,9 @@ export function useHistoryHelper(activeRoute: Route) {
|
||||
|
||||
function trackCommand(command: Undoable, type: 'undo' | 'redo'): void {
|
||||
if (command instanceof Command) {
|
||||
telemetry?.track(`User hit ${type}`, { commands_length: 1, commands: [command.name] });
|
||||
telemetry.track(`User hit ${type}`, { commands_length: 1, commands: [command.name] });
|
||||
} else if (command instanceof BulkCommand) {
|
||||
telemetry?.track(`User hit ${type}`, {
|
||||
telemetry.track(`User hit ${type}`, {
|
||||
commands_length: command.commands.length,
|
||||
commands: command.commands.map((c) => c.name),
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ref } from 'vue';
|
||||
import { ref, computed } from 'vue';
|
||||
import { useI18n } from '@/composables/useI18n';
|
||||
import { ElLoading as Loading } from 'element-plus';
|
||||
|
||||
@@ -36,8 +36,11 @@ export function useLoadingService() {
|
||||
}
|
||||
}
|
||||
|
||||
const isLoading = computed(() => loadingService.value !== null);
|
||||
|
||||
return {
|
||||
loadingService,
|
||||
isLoading,
|
||||
startLoading,
|
||||
setLoadingText,
|
||||
stopLoading,
|
||||
|
||||
@@ -544,7 +544,6 @@ export function useNodeHelpers() {
|
||||
return [];
|
||||
}
|
||||
|
||||
// TODO: Is this problematic?
|
||||
let data: ITaskDataConnections | undefined = taskData.data;
|
||||
if (paneType === 'input' && taskData.inputOverride) {
|
||||
data = taskData.inputOverride!;
|
||||
|
||||
Reference in New Issue
Block a user