Skip to content

Commit

Permalink
fix more type errors in the FE
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoE105 committed Jun 3, 2024
1 parent 631f077 commit 2fecc2f
Show file tree
Hide file tree
Showing 21 changed files with 49 additions and 41 deletions.
5 changes: 4 additions & 1 deletion packages/design-system/src/types/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export type N8nLocaleTranslateFn = (path: string, options: object) => string;
export type N8nLocaleTranslateFn = (
path: string,
options: { interpolate: Record<string, unknown> },
) => string;

export type N8nLocale = Record<string, string | ((...args: unknown[]) => string)>;
2 changes: 1 addition & 1 deletion packages/editor-ui/src/api/eventbus.ee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export async function deleteDestinationFromDb(context: IRestApiContext, destinat
export async function sendTestMessageToDestination(
context: IRestApiContext,
destination: ApiMessageEventBusDestinationOptions,
) {
): Promise<boolean> {
const data: IDataObject = {
...destination,
};
Expand Down
4 changes: 2 additions & 2 deletions packages/editor-ui/src/api/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
} from '@/Interface';
import { get } from '@/utils/apiUtils';

function stringifyArray(arr: number[]) {
function stringifyArray(arr: string[]) {
return arr.join(',');
}

Expand Down Expand Up @@ -41,7 +41,7 @@ export async function getCollections(

export async function getWorkflows(
apiEndpoint: string,
query: { page: number; limit: number; categories: number[]; search: string },
query: { page: number; limit: number; categories: string[]; search: string },
headers?: RawAxiosRequestHeaders,
): Promise<{
totalWorkflows: number;
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/components/HoverableNodeIcon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div
:class="$style.wrapper"
:style="iconStyleData"
@click="(e) => $emit('click')"
@click="() => $emit('click')"
@mouseover="showTooltip = true"
@mouseleave="showTooltip = false"
>
Expand Down
3 changes: 1 addition & 2 deletions packages/editor-ui/src/components/NodeSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ export default defineComponent({
parameters: {},
} as INodeParameters,
nodeValuesInitialized: false, // Used to prevent nodeValues from being overwritten by defaults on reopening ndv
nodeSettings: [] as INodeProperties[],
COMMUNITY_NODES_INSTALLATION_DOCS_URL,
CUSTOM_NODES_DOCS_URL,
Expand All @@ -450,7 +449,7 @@ export default defineComponent({
};
},
watch: {
node(newNode, oldNode) {
node() {
this.setNodeValues();
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ export default defineComponent({
if (deleteConfirmed !== MODAL_CONFIRM) {
return;
} else {
this.eventBus.emit('remove', this.destination.id);
this.callEVentBus('remove', this.destination.id);
this.uiStore.closeModal(LOG_STREAM_MODAL_KEY);
this.uiStore.stateIsDirty = false;
}
Expand All @@ -459,7 +459,7 @@ export default defineComponent({
this.logStreamingStore.removeDestination(this.nodeParameters.id!);
}
this.ndvStore.activeNodeName = null;
this.eventBus.emit('closing', this.destination.id);
this.callEVentBus('closing', this.destination.id);
this.uiStore.stateIsDirty = false;
},
async saveDestination() {
Expand All @@ -471,7 +471,7 @@ export default defineComponent({
this.hasOnceBeenSaved = true;
this.testMessageSent = false;
this.unchanged = true;
this.eventBus.emit('destinationWasSaved', this.destination.id);
this.callEVentBus('destinationWasSaved', this.destination.id);
this.uiStore.stateIsDirty = false;
const destinationType = (this.nodeParameters.__type ?? 'unknown')
Expand Down Expand Up @@ -503,6 +503,11 @@ export default defineComponent({
});
}
},
callEVentBus(event: string, data: unknown) {
if (this.eventBus) {
this.eventBus.emit(event, data);
}
},
},
});
</script>
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/components/Sticky.vue
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export default defineComponent({
},
isSelected(): boolean {
return (
this.uiStore.getSelectedNodes.find((node: INodeUi) => node.name === this.data.name) !==
this.uiStore.getSelectedNodes.find((node: INodeUi) => node.name === this.data?.name) !==
undefined
);
},
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/composables/useCanvasPanning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function useCanvasPanning(
/**
* Updates the canvas offset position based on the mouse movement
*/
function panCanvas(e: MouseEvent) {
function panCanvas(e: MouseEvent | TouchEvent) {
const offsetPosition = uiStore.nodeViewOffsetPosition;

const [x, y] = getMousePosition(e);
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/composables/useNodeHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export function useNodeHelpers() {
}
}

function updateNodeParameterIssues(node: INodeUi, nodeType?: INodeTypeDescription): void {
function updateNodeParameterIssues(node: INodeUi, nodeType?: INodeTypeDescription | null): void {
const localNodeType = nodeType ?? nodeTypesStore.getNodeType(node.type, node.typeVersion);

if (localNodeType === null) {
Expand Down
6 changes: 1 addition & 5 deletions packages/editor-ui/src/composables/useWorkflowHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,7 @@ function getNodes(): INodeUi[] {
}

// Returns a workflow instance.
function getWorkflow(
nodes: Array<INodeUi | IWorkflowTemplateNode>,
connections: IConnections,
copyData?: boolean,
): Workflow {
function getWorkflow(nodes: INodeUi[], connections: IConnections, copyData?: boolean): Workflow {
return useWorkflowsStore().getWorkflow(nodes, connections, copyData);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useUIStore } from '@/stores/ui.store';
import type { IFakeDoor } from '@/Interface';
import { FAKE_DOOR_FEATURES } from '@/constants';
import type { BaseTextKey } from '@/plugins/i18n';

export function compileFakeDoorFeatures(): IFakeDoor[] {
const store = useUIStore();
Expand All @@ -20,7 +21,7 @@ export function compileFakeDoorFeatures(): IFakeDoor[] {
if (loggingFeature) {
loggingFeature.actionBoxTitle += '.cloud';
loggingFeature.linkURL += '&edition=cloud';
loggingFeature.infoText = '';
loggingFeature.infoText = '' as BaseTextKey;
}

return fakeDoorFeatures;
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/plugins/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const GlobalComponentsPlugin: Plugin<{}> = {
app.component('ParameterInputList', ParameterInputList);

app.use(ElementPlus);
app.use(N8nPlugin);
app.use(N8nPlugin, {});

// app.use(ElLoading);
// app.use(ElNotification);
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/plugins/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ export const i18n: I18nClass = new I18nClass();
export const I18nPlugin: Plugin<{}> = {
async install(app) {
locale.i18n((key: string, options?: { interpolate: Record<string, unknown> }) =>
i18nInstance.global.t(key, options?.interpolate || {}),
i18nInstance.global.t(key, options?.interpolate ?? {}),
);

app.config.globalProperties.$locale = i18n;
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ function withCanvasReadOnlyMeta(route: RouteRecordRaw) {

const router = createRouter({
history: createWebHistory(import.meta.env.DEV ? '/' : window.BASE_PATH ?? '/'),
scrollBehavior(to: RouteLocationNormalized & RouteConfig, from, savedPosition) {
scrollBehavior(to: RouteLocationNormalized & RouteConfig, _, savedPosition) {
// saved position == null means the page is NOT visited from history (back button)
if (savedPosition === null && to.name === VIEWS.TEMPLATES && to.meta?.setScrollPosition) {
// for templates view, reset scroll position in this case
Expand Down
4 changes: 3 additions & 1 deletion packages/editor-ui/src/stores/executions.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ export const useExecutionsStore = defineStore('executions', () => {
}
}

async function fetchExecution(id: string): Promise<IExecutionResponse | undefined> {
async function fetchExecution(
id: string,
): Promise<Omit<IExecutionResponse, 'status'> | undefined> {
const response = await makeRestApiRequest<IExecutionFlattedResponse>(
rootStore.getRestApiContext,
'GET',
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/stores/logStreaming.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export const useLogStreamingStore = defineStore('logStreaming', {
return false;
}
},
async sendTestMessage(destination: MessageEventBusDestinationOptions) {
async sendTestMessage(destination: MessageEventBusDestinationOptions): Promise<boolean> {
if (!hasDestinationId(destination)) {
return false;
}
Expand Down
1 change: 1 addition & 0 deletions packages/editor-ui/src/stores/ndv.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ export const useNDVStore = defineStore(STORES.NDV, {
isDragging: false,
type: '',
data: '',
dimensions: null,
activeTarget: null,
};
},
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/stores/posthog.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export const usePostHog = defineStore('posthog', () => {
trackExperimentsDebounced(featureFlags.value);
} else {
// depend on client side evaluation if serverside evaluation fails
window.posthog?.onFeatureFlags?.((keys: string[], map: FeatureFlags) => {
window.posthog?.onFeatureFlags?.((_, map: FeatureFlags) => {
featureFlags.value = map;

// must be debounced because it is called multiple times by posthog
Expand Down
1 change: 1 addition & 0 deletions packages/editor-ui/src/stores/rbac.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const useRBACStore = defineStore(STORES.RBAC, () => {
license: {},
logStreaming: {},
saml: {},
securityAudit: {},
});

function addGlobalRole(role: IRole) {
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/stores/settings.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, {

this.setSettings(settings);
this.settings.communityNodesEnabled = settings.communityNodesEnabled;
this.setAllowedModules(settings.allowedModules as { builtIn?: string; external?: string });
this.setAllowedModules(settings.allowedModules);
this.setSaveDataErrorExecution(settings.saveDataErrorExecution);
this.setSaveDataSuccessExecution(settings.saveDataSuccessExecution);
this.setSaveManualExecutions(settings.saveManualExecutions);
Expand Down
30 changes: 15 additions & 15 deletions packages/editor-ui/src/views/TemplatesSearchView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,21 @@ export default defineComponent({
TemplateList,
TemplatesView,
},
beforeRouteLeave(_to, _from, next) {
const contentArea = document.getElementById('content');
if (contentArea) {
// When leaving this page, store current scroll position in route data
if (
this.$route.meta?.setScrollPosition &&
typeof this.$route.meta.setScrollPosition === 'function'
) {
this.$route.meta.setScrollPosition(contentArea.scrollTop);
}
}
this.trackSearch();
next();
},
setup() {
const { callDebounced } = useDebounce();
Expand Down Expand Up @@ -406,21 +421,6 @@ export default defineComponent({
}, 0);
},
},
beforeRouteLeave(to, from, next) {
const contentArea = document.getElementById('content');
if (contentArea) {
// When leaving this page, store current scroll position in route data
if (
this.$route.meta?.setScrollPosition &&
typeof this.$route.meta.setScrollPosition === 'function'
) {
this.$route.meta.setScrollPosition(contentArea.scrollTop);
}
}
this.trackSearch();
next();
},
});
</script>

Expand Down

0 comments on commit 2fecc2f

Please sign in to comment.