set env variables

This commit is contained in:
Mutasem 2021-07-08 09:58:54 +02:00
parent 16b7d55357
commit 3cbe31dd5e
6 changed files with 62 additions and 39 deletions

View file

@ -445,6 +445,12 @@ export interface IPushDataConsoleMessage {
message: string;
}
export interface IVersionNotificationSettings {
enabled: boolean;
endpoint: string;
infoUrl: string;
}
export interface IN8nUISettings {
endpointWebhook: string;
endpointWebhookTest: string;
@ -463,6 +469,7 @@ export interface IN8nUISettings {
n8nMetadata?: {
[key: string]: string | number | undefined;
};
versionNotifications: IVersionNotificationSettings;
}
export interface IWorkflowSettings extends IWorkflowSettingsWorkflow {
@ -635,6 +642,7 @@ export interface IUiState {
}
export interface IVersionsState {
versionNotificationSettings: IVersionNotificationSettings;
nextVersions: IVersion[];
currentVersion: IVersion | undefined;
}

View file

@ -1,7 +1,6 @@
import { IVersion } from '@/Interface';
import { get } from './helpers';
import { VERSIONS_BASE_URL } from '@/constants';
export async function getNextVersions(version: string): Promise<IVersion[]> {
return await get(VERSIONS_BASE_URL, version);
export async function getNextVersions(endpoint: string, version: string): Promise<IVersion[]> {
return await get(endpoint, version);
}

View file

@ -14,7 +14,7 @@
<section :class="$style['description']">
<p>Youre on {{ currentVersion.name }}, which was released <strong>{{currentReleaseDate}}</strong> and is {{ nextVersions.length }} version{{nextVersions.length > 1 ? 's' : ''}} behind the latest and greatest n8n</p>
<a :class="$style.update" :href="UPDATE_INFO_URL" v-if="UPDATE_INFO_URL" target="_blank">
<a :class="$style.update" :href="infoUrl" v-if="infoUrl" target="_blank">
<font-awesome-icon icon="info-circle"></font-awesome-icon>
<span>How to update your n8n version</span>
</a>
@ -38,7 +38,6 @@ import { format } from 'timeago.js';
import Modal from './Modal.vue';
import VersionCard from './VersionCard.vue';
import { UPDATE_INFO_URL } from '@/constants';
export default Vue.extend({
name: 'UpdatesPanel',
@ -47,15 +46,11 @@ export default Vue.extend({
VersionCard,
},
props: ['modalName', 'visible'],
data() {
return {
UPDATE_INFO_URL,
};
},
computed: {
...mapGetters('versions', [
'nextVersions',
'currentVersion',
'infoUrl',
]),
currentReleaseDate() {
return format(this.currentVersion.createdAt);

View file

@ -49,7 +49,3 @@ export const HIDDEN_NODES = ['n8n-nodes-base.start'];
export const WEBHOOK_NODE_NAME = 'n8n-nodes-base.webhook';
export const HTTP_REQUEST_NODE_NAME = 'n8n-nodes-base.httpRequest';
export const REQUEST_NODE_FORM_URL = 'https://n8n-community.typeform.com/to/K1fBVTZ3';
// versions
export const VERSIONS_BASE_URL = `https://api-staging.n8n.io/versions/`;
export const UPDATE_INFO_URL = 'https://docs.n8n.io/';

View file

@ -1,5 +1,4 @@
import { getNextVersions } from '@/api/versions';
import { versions } from 'process';
import { ActionContext, Module } from 'vuex';
import {
IRootState,
@ -10,6 +9,11 @@ import {
const module: Module<IVersionsState, IRootState> = {
namespaced: true,
state: {
versionNotificationSettings: {
enabled: false,
endpoint: '',
infoUrl: '',
},
nextVersions: [],
currentVersion: undefined,
},
@ -23,18 +27,30 @@ const module: Module<IVersionsState, IRootState> = {
currentVersion(state: IVersionsState) {
return state.currentVersion;
},
areNotificationsEnabled(state: IVersionsState) {
return state.versionNotificationSettings.enabled;
},
infoUrl(state: IVersionsState) {
return state.versionNotificationSettings.infoUrl;
},
},
mutations: {
setVersions(state: IVersionsState, {versions, currentVersion}: {versions: IVersion[], currentVersion: string}) {
state.nextVersions = versions.filter((version) => version.name !== currentVersion);
state.currentVersion = versions.find((version) => version.name === currentVersion);
},
setVersionNotificationSettings(state: IVersionsState, settings: {enabled: true, endpoint: string, infoUrl: string}) {
state.versionNotificationSettings = settings;
},
},
actions: {
async fetchVersions(context: ActionContext<IVersionsState, IRootState>) {
const currentVersion = context.rootState.versionCli;
const versions = await getNextVersions(currentVersion);
context.commit('setVersions', {versions, currentVersion});
const enabled = context.state.versionNotificationSettings.enabled;
if (enabled) {
const currentVersion = context.rootState.versionCli;
const versions = await getNextVersions(context.state.versionNotificationSettings.endpoint, currentVersion);
context.commit('setVersions', {versions, currentVersion});
}
},
},
};

View file

@ -2170,6 +2170,7 @@ export default mixins(
this.$store.commit('setVersionCli', settings.versionCli);
this.$store.commit('setOauthCallbackUrls', settings.oauthCallbackUrls);
this.$store.commit('setN8nMetadata', settings.n8nMetadata || {});
this.$store.commit('versions/setVersionNotificationSettings', settings.versionNotifications);
},
async loadNodeTypes (): Promise<void> {
const nodeTypes = await this.restApi().getNodeTypes();
@ -2194,8 +2195,36 @@ export default mixins(
this.stopLoading();
}
},
async checkForNewVersions() {
const enabled = this.$store.getters['versions/areNotificationsEnabled'];
if (!enabled) {
return;
}
await this.$store.dispatch('versions/fetchVersions');
const currentVersion: IVersion | undefined = this.$store.getters['versions/currentVersion'];
const nextVersions: IVersion[] = this.$store.getters['versions/nextVersions'];
if (currentVersion && currentVersion.hasSecurityIssue && nextVersions.length) {
const fixVersion = currentVersion.securityIssueFixVersion;
let message = `Please update to latest version.`;
if (fixVersion) {
message = `Please update to version ${fixVersion} or higher.`;
}
message = `${message} <a class="primary-color">More info</a>`;
this.$showWarning('Critical Update', message, {
onClick: () => {
this.$store.dispatch('ui/openUpdatesPanel');
},
closeOnClick: true,
customClass: 'clickable',
duration: 0,
});
}
},
},
async mounted () {
this.$root.$on('importWorkflowData', async (data: IDataObject) => {
const resData = await this.importWorkflowData(data.data as IWorkflowDataUpdate);
@ -2237,27 +2266,7 @@ export default mixins(
this.stopLoading();
setTimeout(async () => {
await this.$store.dispatch('versions/fetchVersions');
const currentVersion: IVersion | undefined = this.$store.getters['versions/currentVersion'];
const nextVersions: IVersion[] = this.$store.getters['versions/nextVersions'];
if (currentVersion && currentVersion.hasSecurityIssue && nextVersions.length) {
const fixVersion = currentVersion.securityIssueFixVersion;
let message = `Please update to latest version.`;
if (fixVersion) {
message = `Please update to version ${fixVersion} or higher.`;
}
message = `${message} <a class="primary-color">More info</a>`;
this.$showWarning('Critical Update', message, {
onClick: () => {
this.$store.dispatch('ui/openUpdatesPanel');
},
closeOnClick: true,
customClass: 'clickable',
duration: 0,
});
}
this.checkForNewVersions();
}, 0);
});