add error message

This commit is contained in:
Mutasem 2021-07-02 12:09:47 +02:00
parent 750188def9
commit 20fe805c61
2 changed files with 42 additions and 3 deletions

View file

@ -1,5 +1,5 @@
import { Notification } from 'element-ui'; import { Notification } from 'element-ui';
import { ElNotificationOptions } from 'element-ui/types/notification'; import { ElNotificationComponent, ElNotificationOptions } from 'element-ui/types/notification';
import mixins from 'vue-typed-mixins'; import mixins from 'vue-typed-mixins';
import { externalHooks } from '@/components/mixins/externalHooks'; import { externalHooks } from '@/components/mixins/externalHooks';
@ -15,6 +15,26 @@ export const showMessage = mixins(externalHooks).extend({
return Notification(messageData); return Notification(messageData);
}, },
$showWarning(title: string, message: string, config?: {onClick?: () => void, duration?: number, customClass?: string, closeOnClick?: boolean}) {
let notification: ElNotificationComponent;
if (config && config.closeOnClick) {
const cb = config.onClick;
config.onClick = () => {
notification && notification.close();
cb && cb();
};
}
notification = this.$showMessage({
title,
message,
type: 'warning',
...(config || {}),
});
return notification;
},
$showError(error: Error, title: string, message?: string) { $showError(error: Error, title: string, message?: string) {
const messageLine = message ? `${message}<br/>` : ''; const messageLine = message ? `${message}<br/>` : '';
this.$showMessage({ this.$showMessage({

View file

@ -166,6 +166,7 @@ import {
XYPositon, XYPositon,
IPushDataExecutionFinished, IPushDataExecutionFinished,
ITag, ITag,
IVersion,
IWorkflowTemplate, IWorkflowTemplate,
} from '../Interface'; } from '../Interface';
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
@ -2235,8 +2236,26 @@ export default mixins(
} }
this.stopLoading(); this.stopLoading();
setTimeout(() => { setTimeout(async () => {
this.$store.dispatch('versions/fetchVersions'); await this.$store.dispatch('versions/fetchVersions');
const currentVersion: IVersion | undefined = this.$store.getters['versions/currentVersion'];
if (currentVersion && currentVersion.hasSecurityIssue) {
const fixVersion = currentVersion.securityIssueFixVersion;
let message = `Please update to latest version.`;
if (fixVersion) {
message = `Please update to version ${fixVersion} or higher.`;
}
message = `${message}<br/><a class="primary-color">More info</a>`;
this.$showWarning('Critical Update', message, {
onClick: () => {
this.$store.dispatch('ui/openVersionsModal');
},
closeOnClick: true,
customClass: 'clickable',
duration: 0,
});
}
}, 0); }, 0);
}); });