refactor(editor-ui): leverage the editor url in frontend (#4085)

* refactor(editor-ui): remove unused interfaces

* refactor(editor-ui): add urlBaseEditor setting to application state

* fix(editor-ui): webhook urls for test and production

* fix(editor-ui): jsPlumb Anchor interface
This commit is contained in:
Csaba Tuncsik 2022-09-13 09:54:23 +02:00 committed by GitHub
parent f1a569791d
commit c4fd8ce28b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 9 deletions

View file

@ -6,14 +6,10 @@ import {
ICredentialsEncrypted, ICredentialsEncrypted,
ICredentialType, ICredentialType,
IDataObject, IDataObject,
ILoadOptions,
INode, INode,
INodeCredentials,
INodeIssues, INodeIssues,
INodeParameters, INodeParameters,
INodePropertyOptions,
INodeTypeDescription, INodeTypeDescription,
INodeTypeNameVersion,
IPinData, IPinData,
IRunExecutionData, IRunExecutionData,
IRun, IRun,
@ -37,6 +33,7 @@ declare module 'jsplumb' {
outlineWidth?: number; outlineWidth?: number;
} }
// Extend jsPlumb Anchor interface
interface Anchor { interface Anchor {
lastReturnValue: number[]; lastReturnValue: number[];
} }
@ -140,7 +137,6 @@ export interface INodeUpdatePropertiesInformation {
export type XYPosition = [number, number]; export type XYPosition = [number, number];
export type MessageType = 'success' | 'warning' | 'info' | 'error';
export interface INodeUi extends INode { export interface INodeUi extends INode {
position: XYPosition; position: XYPosition;
color?: string; color?: string;
@ -413,8 +409,6 @@ export interface IExecutionDeleteFilter {
ids?: string[]; ids?: string[];
} }
export type IPushDataType = IPushData['type'];
export type IPushData = export type IPushData =
| PushDataExecutionFinished | PushDataExecutionFinished
| PushDataExecutionStarted | PushDataExecutionStarted
@ -700,6 +694,7 @@ export interface IN8nUISettings {
oauth1: string; oauth1: string;
oauth2: string; oauth2: string;
}; };
urlBaseEditor: string;
urlBaseWebhook: string; urlBaseWebhook: string;
versionCli: string; versionCli: string;
n8nMetadata?: { n8nMetadata?: {
@ -878,6 +873,7 @@ export interface IRootState {
nodeViewMoveInProgress: boolean; nodeViewMoveInProgress: boolean;
selectedNodes: INodeUi[]; selectedNodes: INodeUi[];
sessionId: string; sessionId: string;
urlBaseEditor: string;
urlBaseWebhook: string; urlBaseWebhook: string;
workflow: IWorkflowDb; workflow: IWorkflowDb;
sidebarMenuItems: IMenuItem[]; sidebarMenuItems: IMenuItem[];

View file

@ -128,6 +128,7 @@ const module: Module<ISettingsState, IRootState> = {
// todo refactor to this store // todo refactor to this store
context.commit('setUrlBaseWebhook', settings.urlBaseWebhook, {root: true}); context.commit('setUrlBaseWebhook', settings.urlBaseWebhook, {root: true});
context.commit('setUrlBaseEditor', settings.urlBaseEditor, {root: true});
context.commit('setEndpointWebhook', settings.endpointWebhook, {root: true}); context.commit('setEndpointWebhook', settings.endpointWebhook, {root: true});
context.commit('setEndpointWebhookTest', settings.endpointWebhookTest, {root: true}); context.commit('setEndpointWebhookTest', settings.endpointWebhookTest, {root: true});
context.commit('setSaveDataErrorExecution', settings.saveDataErrorExecution, {root: true}); context.commit('setSaveDataErrorExecution', settings.saveDataErrorExecution, {root: true});

View file

@ -85,6 +85,7 @@ const state: IRootState = {
nodeViewMoveInProgress: false, nodeViewMoveInProgress: false,
selectedNodes: [], selectedNodes: [],
sessionId: Math.random().toString(36).substring(2, 15), sessionId: Math.random().toString(36).substring(2, 15),
urlBaseEditor: 'http://localhost:5678',
urlBaseWebhook: 'http://localhost:5678/', urlBaseWebhook: 'http://localhost:5678/',
isNpmAvailable: false, isNpmAvailable: false,
workflow: { workflow: {
@ -567,7 +568,12 @@ export const store = new Vuex.Store({
// Webhooks // Webhooks
setUrlBaseWebhook(state, urlBaseWebhook: string) { setUrlBaseWebhook(state, urlBaseWebhook: string) {
Vue.set(state, 'urlBaseWebhook', urlBaseWebhook); const url = urlBaseWebhook.endsWith('/') ? urlBaseWebhook : `${urlBaseWebhook}/`;
Vue.set(state, 'urlBaseWebhook', url);
},
setUrlBaseEditor(state, urlBaseEditor: string) {
const url = urlBaseEditor.endsWith('/') ? urlBaseEditor : `${urlBaseEditor}/`;
Vue.set(state, 'urlBaseEditor', url);
}, },
setEndpointWebhook(state, endpointWebhook: string) { setEndpointWebhook(state, endpointWebhook: string) {
Vue.set(state, 'endpointWebhook', endpointWebhook); Vue.set(state, 'endpointWebhook', endpointWebhook);
@ -759,7 +765,7 @@ export const store = new Vuex.Store({
return `${state.urlBaseWebhook}${state.endpointWebhook}`; return `${state.urlBaseWebhook}${state.endpointWebhook}`;
}, },
getWebhookTestUrl: (state): string => { getWebhookTestUrl: (state): string => {
return `${state.urlBaseWebhook}${state.endpointWebhookTest}`; return `${state.urlBaseEditor}${state.endpointWebhookTest}`;
}, },
getStateIsDirty: (state): boolean => { getStateIsDirty: (state): boolean => {