refactor(editor): Refactor utils files and mixins (#4654)

*  Added `utils` module. Moved `canvasHelpers` and old `utils.ts` file to it
*  Moved rest of utils and helpers
*  Fixing sytax errors
* 🔨 Refactoring new utils files
* 🔨 Organizing imports, adding comments and a bit more refactoring
* ✔️ Fixing tests
* 🔨 Moving mixins to `src`
This commit is contained in:
Milorad FIlipović
2022-11-23 13:41:53 +01:00
committed by GitHub
parent 67983e8f94
commit 5059c57f4a
167 changed files with 748 additions and 674 deletions

View File

@@ -0,0 +1,50 @@
import mixins from 'vue-typed-mixins';
import { showMessage } from './showMessage';
import { VERSIONS_MODAL_KEY } from '@/constants';
import { mapStores } from 'pinia';
import { useUIStore } from '@/stores/ui';
import { useVersionsStore } from '@/stores/versions';
export const newVersions = mixins(
showMessage,
).extend({
computed: {
...mapStores(
useUIStore,
useVersionsStore,
),
},
methods: {
async checkForNewVersions() {
const enabled = this.versionsStore.areNotificationsEnabled;
if (!enabled) {
return;
}
await this.versionsStore.fetchVersions();
const currentVersion = this.versionsStore.currentVersion;
const nextVersions = this.versionsStore.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.$showToast({
title: 'Critical update available',
message,
onClick: () => {
this.uiStore.openModal(VERSIONS_MODAL_KEY);
},
closeOnClick: true,
customClass: 'clickable',
type: 'warning',
duration: 0,
});
}
},
},
});