♻️ Refactor key names to use contstants

This commit is contained in:
Alicia Sykes
2021-11-07 22:55:06 +00:00
parent 7e6cce8828
commit c991a46298
5 changed files with 28 additions and 19 deletions

View File

@@ -68,7 +68,7 @@ import Input from '@/components/FormElements/Input';
import StoreKeys from '@/utils/StoreMutations';
import { backup, update, restore } from '@/utils/CloudBackup';
import { localStorageKeys } from '@/utils/defaults';
import { InfoHandler, WarningInfoHandler } from '@/utils/ErrorHandler';
import { InfoHandler, WarningInfoHandler, InfoKeys } from '@/utils/ErrorHandler';
// Import Icons
import IconBackup from '@/assets/interface-icons/config-backup.svg';
import IconRestore from '@/assets/interface-icons/config-restore.svg';
@@ -179,12 +179,12 @@ export default {
},
/* If the server returns a warning, then show to user and log it */
showErrorMsg(errorMsg) {
WarningInfoHandler(errorMsg, 'Cloud Backup');
WarningInfoHandler(errorMsg, InfoKeys.CLOUD_BACKUP);
this.$toasted.show(errorMsg, { className: 'toast-error' });
},
/* When server returns success message, then show to user and log it */
showSuccessMsg(msg) {
InfoHandler(msg, 'Cloud Backup');
InfoHandler(msg, InfoKeys.CLOUD_BACKUP);
this.$toasted.show(msg, { className: 'toast-success' });
},
/* Call to hash function, to hash the users chosen/ entered password */

View File

@@ -36,7 +36,7 @@ import StoreKeys from '@/utils/StoreMutations';
import { modalNames } from '@/utils/defaults';
import DownloadConfigIcon from '@/assets/interface-icons/config-download-file.svg';
import CopyConfigIcon from '@/assets/interface-icons/interactive-editor-copy-clipboard.svg';
import { InfoHandler } from '@/utils/ErrorHandler';
import { InfoHandler, InfoKeys } from '@/utils/ErrorHandler';
export default {
name: 'ExportConfigMenu',
@@ -70,13 +70,13 @@ export default {
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
InfoHandler('Config downloaded as YAML file', 'Interactive Editor');
InfoHandler('Config downloaded as YAML file', InfoKeys.EDITOR);
},
copyConfigToClipboard() {
const config = this.convertJsonToYaml();
navigator.clipboard.writeText(config);
this.$toasted.show(this.$t('config.data-copied-msg'));
InfoHandler('Config copied to clipboard', 'Interactive Editor');
InfoHandler('Config copied to clipboard', InfoKeys.EDITOR);
},
modalClosed() {
this.$store.commit(StoreKeys.SET_MODAL_OPEN, false);