i18n, vue-router and vuex upgrade

1. Configuration of i18n legacy as false.
2. Translation function t is called using the useI18n.
3. Used the i18n.global.t() function from i18n instead of this.$t()
4. Event bus error that occurred during logout.
5. Implemented vue-router 4.4.0 and vuex upgrade to 4.1.0

Change-Id: I9464d82c76dcc1445ce271983ea3ab9d7b03d265
Signed-off-by: Surya Venkatesan <suryav@ami.com>
diff --git a/src/components/AppHeader/AppHeader.vue b/src/components/AppHeader/AppHeader.vue
index 9d06680..6b19ac0 100644
--- a/src/components/AppHeader/AppHeader.vue
+++ b/src/components/AppHeader/AppHeader.vue
@@ -116,6 +116,7 @@
 import IconRenew from '@carbon/icons-vue/es/renew/20';
 import StatusIcon from '@/components/Global/StatusIcon';
 import LoadingBar from '@/components/Global/LoadingBar';
+import { useI18n } from 'vue-i18n';
 import { mapState } from 'vuex';
 
 export default {
@@ -137,6 +138,7 @@
   },
   data() {
     return {
+      $t: useI18n().t,
       isNavigationOpen: false,
       altLogo: process.env.VUE_APP_COMPANY_NAME || 'Built on OpenBMC',
     };
@@ -198,7 +200,7 @@
   },
   watch: {
     consoleWindow() {
-      if (this.consoleWindow === false) this.$eventBus.$consoleWindow.close();
+      if (this.consoleWindow === false) this.$eventBus.$consoleWindow?.close();
     },
     isAuthorized(value) {
       if (value === false) {
diff --git a/src/components/AppNavigation/AppNavigation.vue b/src/components/AppNavigation/AppNavigation.vue
index 4c93be5..eb8c2c6 100644
--- a/src/components/AppNavigation/AppNavigation.vue
+++ b/src/components/AppNavigation/AppNavigation.vue
@@ -60,12 +60,14 @@
 //Exact match alias set to support
 //dotenv customizations.
 import AppNavigationMixin from './AppNavigationMixin';
+import { useI18n } from 'vue-i18n';
 
 export default {
   name: 'AppNavigation',
   mixins: [AppNavigationMixin],
   data() {
     return {
+      $t: useI18n().t,
       isNavigationOpen: false,
       currentUserRole: null,
     };
diff --git a/src/components/AppNavigation/AppNavigationMixin.js b/src/components/AppNavigation/AppNavigationMixin.js
index b33b24b..c00e984 100644
--- a/src/components/AppNavigation/AppNavigationMixin.js
+++ b/src/components/AppNavigation/AppNavigationMixin.js
@@ -6,6 +6,7 @@
 import IconSecurity from '@carbon/icons-vue/es/security/16';
 import IconChevronUp from '@carbon/icons-vue/es/chevron--up/16';
 import IconDataBase from '@carbon/icons-vue/es/data--base--alt/16';
+import i18n from '@/i18n';
 const roles = {
   administrator: 'Administrator',
   operator: 'Operator',
@@ -29,88 +30,88 @@
       navigationItems: [
         {
           id: 'overview',
-          label: this.$t('appNavigation.overview'),
+          label: i18n.global.t('appNavigation.overview'),
           route: '/',
           icon: 'iconOverview',
         },
         {
           id: 'logs',
-          label: this.$t('appNavigation.logs'),
+          label: i18n.global.t('appNavigation.logs'),
           icon: 'iconLogs',
           children: [
             {
               id: 'event-logs',
-              label: this.$t('appNavigation.eventLogs'),
+              label: i18n.global.t('appNavigation.eventLogs'),
               route: '/logs/event-logs',
             },
             {
               id: 'post-code-logs',
-              label: this.$t('appNavigation.postCodeLogs'),
+              label: i18n.global.t('appNavigation.postCodeLogs'),
               route: '/logs/post-code-logs',
             },
           ],
         },
         {
           id: 'hardware-status',
-          label: this.$t('appNavigation.hardwareStatus'),
+          label: i18n.global.t('appNavigation.hardwareStatus'),
           icon: 'iconHealth',
           children: [
             {
               id: 'inventory',
-              label: this.$t('appNavigation.inventory'),
+              label: i18n.global.t('appNavigation.inventory'),
               route: '/hardware-status/inventory',
             },
             {
               id: 'sensors',
-              label: this.$t('appNavigation.sensors'),
+              label: i18n.global.t('appNavigation.sensors'),
               route: '/hardware-status/sensors',
             },
           ],
         },
         {
           id: 'operations',
-          label: this.$t('appNavigation.operations'),
+          label: i18n.global.t('appNavigation.operations'),
           icon: 'iconControl',
           children: [
             {
               id: 'factory-reset',
-              label: this.$t('appNavigation.factoryReset'),
+              label: i18n.global.t('appNavigation.factoryReset'),
               route: '/operations/factory-reset',
             },
             {
               id: 'kvm',
-              label: this.$t('appNavigation.kvm'),
+              label: i18n.global.t('appNavigation.kvm'),
               route: '/operations/kvm',
             },
             {
               id: 'key-clear',
-              label: this.$t('appNavigation.keyClear'),
+              label: i18n.global.t('appNavigation.keyClear'),
               route: '/operations/key-clear',
             },
             {
               id: 'firmware',
-              label: this.$t('appNavigation.firmware'),
+              label: i18n.global.t('appNavigation.firmware'),
               route: '/operations/firmware',
             },
             {
               id: 'reboot-bmc',
-              label: this.$t('appNavigation.rebootBmc'),
+              label: i18n.global.t('appNavigation.rebootBmc'),
               route: '/operations/reboot-bmc',
             },
             {
               id: 'serial-over-lan',
-              label: this.$t('appNavigation.serialOverLan'),
+              label: i18n.global.t('appNavigation.serialOverLan'),
               route: '/operations/serial-over-lan',
               exclusiveToRoles: [roles.administrator],
             },
             {
               id: 'server-power-operations',
-              label: this.$t('appNavigation.serverPowerOperations'),
+              label: i18n.global.t('appNavigation.serverPowerOperations'),
               route: '/operations/server-power-operations',
             },
             {
               id: 'virtual-media',
-              label: this.$t('appNavigation.virtualMedia'),
+              label: i18n.global.t('appNavigation.virtualMedia'),
               route: '/operations/virtual-media',
               exclusiveToRoles: [roles.administrator],
             },
@@ -118,71 +119,71 @@
         },
         {
           id: 'settings',
-          label: this.$t('appNavigation.settings'),
+          label: i18n.global.t('appNavigation.settings'),
           icon: 'iconSettings',
           children: [
             {
               id: 'date-time',
-              label: this.$t('appNavigation.dateTime'),
+              label: i18n.global.t('appNavigation.dateTime'),
               route: '/settings/date-time',
             },
             {
               id: 'network',
-              label: this.$t('appNavigation.network'),
+              label: i18n.global.t('appNavigation.network'),
               route: '/settings/network',
             },
             {
               id: 'power-restore-policy',
-              label: this.$t('appNavigation.powerRestorePolicy'),
+              label: i18n.global.t('appNavigation.powerRestorePolicy'),
               route: '/settings/power-restore-policy',
             },
             {
               id: 'snmp-alerts',
-              label: this.$t('appNavigation.snmpAlerts'),
+              label: i18n.global.t('appNavigation.snmpAlerts'),
               route: '/settings/snmp-alerts',
             },
           ],
         },
         {
           id: 'security-and-access',
-          label: this.$t('appNavigation.securityAndAccess'),
+          label: i18n.global.t('appNavigation.securityAndAccess'),
           icon: 'iconSecurityAndAccess',
           children: [
             {
               id: 'sessions',
-              label: this.$t('appNavigation.sessions'),
+              label: i18n.global.t('appNavigation.sessions'),
               route: '/security-and-access/sessions',
             },
             {
               id: 'ldap',
-              label: this.$t('appNavigation.ldap'),
+              label: i18n.global.t('appNavigation.ldap'),
               route: '/security-and-access/ldap',
             },
             {
               id: 'user-management',
-              label: this.$t('appNavigation.userManagement'),
+              label: i18n.global.t('appNavigation.userManagement'),
               route: '/security-and-access/user-management',
             },
             {
               id: 'policies',
-              label: this.$t('appNavigation.policies'),
+              label: i18n.global.t('appNavigation.policies'),
               route: '/security-and-access/policies',
             },
             {
               id: 'certificates',
-              label: this.$t('appNavigation.certificates'),
+              label: i18n.global.t('appNavigation.certificates'),
               route: '/security-and-access/certificates',
             },
           ],
         },
         {
           id: 'resource-management',
-          label: this.$t('appNavigation.resourceManagement'),
+          label: i18n.global.t('appNavigation.resourceManagement'),
           icon: 'iconResourceManagement',
           children: [
             {
               id: 'power',
-              label: this.$t('appNavigation.power'),
+              label: i18n.global.t('appNavigation.power'),
               route: '/resource-management/power',
             },
           ],
diff --git a/src/components/Global/ButtonBackToTop.vue b/src/components/Global/ButtonBackToTop.vue
index 3ceb691..f8d8b88 100644
--- a/src/components/Global/ButtonBackToTop.vue
+++ b/src/components/Global/ButtonBackToTop.vue
@@ -16,12 +16,14 @@
 import UpToTop24 from '@carbon/icons-vue/es/up-to-top/24';
 
 import { debounce } from 'lodash';
+import { useI18n } from 'vue-i18n';
 
 export default {
   name: 'BackToTop',
   components: { IconUpToTop: UpToTop24 },
   data() {
     return {
+      $t: useI18n().t,
       showButton: false,
     };
   },
diff --git a/src/components/Global/InputPasswordToggle.vue b/src/components/Global/InputPasswordToggle.vue
index cd86920..fadb99a 100644
--- a/src/components/Global/InputPasswordToggle.vue
+++ b/src/components/Global/InputPasswordToggle.vue
@@ -18,6 +18,7 @@
 <script>
 import IconView from '@carbon/icons-vue/es/view/20';
 import IconViewOff from '@carbon/icons-vue/es/view--off/20';
+import i18n from '@/i18n';
 
 export default {
   name: 'InputPasswordToggle',
@@ -25,7 +26,7 @@
   data() {
     return {
       isVisible: false,
-      togglePasswordLabel: this.$t('global.ariaLabel.showPassword'),
+      togglePasswordLabel: i18n.global.t('global.ariaLabel.showPassword'),
     };
   },
   methods: {
@@ -40,8 +41,12 @@
       }
 
       this.isVisible
-        ? (this.togglePasswordLabel = this.$t('global.ariaLabel.hidePassword'))
-        : (this.togglePasswordLabel = this.$t('global.ariaLabel.showPassword'));
+        ? (this.togglePasswordLabel = i18n.global.t(
+            'global.ariaLabel.hidePassword',
+          ))
+        : (this.togglePasswordLabel = i18n.global.t(
+            'global.ariaLabel.showPassword',
+          ));
     },
   },
 };
diff --git a/src/components/Global/LoadingBar.vue b/src/components/Global/LoadingBar.vue
index 337aaf0..49f2611 100644
--- a/src/components/Global/LoadingBar.vue
+++ b/src/components/Global/LoadingBar.vue
@@ -12,9 +12,11 @@
 </template>
 
 <script>
+import { useI18n } from 'vue-i18n';
 export default {
   data() {
     return {
+      $t: useI18n().t,
       loadingIndicatorValue: 0,
       isLoadingComplete: false,
       loadingIntervalId: null,
diff --git a/src/components/Global/Search.vue b/src/components/Global/Search.vue
index d53315b..5c51678 100644
--- a/src/components/Global/Search.vue
+++ b/src/components/Global/Search.vue
@@ -39,6 +39,8 @@
 <script>
 import IconSearch from '@carbon/icons-vue/es/search/16';
 import IconClose from '@carbon/icons-vue/es/close/20';
+import { useI18n } from 'vue-i18n';
+import i18n from '@/i18n';
 
 export default {
   name: 'Search',
@@ -47,12 +49,13 @@
     placeholder: {
       type: String,
       default: function () {
-        return this.$t('global.form.search');
+        return i18n.global.t('global.form.search');
       },
     },
   },
   data() {
     return {
+      $t: useI18n().t,
       filter: null,
     };
   },
diff --git a/src/components/Global/TableCellCount.vue b/src/components/Global/TableCellCount.vue
index acb4d44..25730a3 100644
--- a/src/components/Global/TableCellCount.vue
+++ b/src/components/Global/TableCellCount.vue
@@ -15,6 +15,7 @@
 </template>
 
 <script>
+import { useI18n } from 'vue-i18n';
 export default {
   props: {
     filteredItemsCount: {
@@ -26,6 +27,11 @@
       required: true,
     },
   },
+  data() {
+    return {
+      $t: useI18n().t,
+    };
+  },
   computed: {
     filterActive() {
       return this.filteredItemsCount !== this.totalNumberOfCells;
diff --git a/src/components/Global/TableDateFilter.vue b/src/components/Global/TableDateFilter.vue
index 4e8c5b9..921268c 100644
--- a/src/components/Global/TableDateFilter.vue
+++ b/src/components/Global/TableDateFilter.vue
@@ -11,15 +11,15 @@
             id="input-from-date"
             v-model="fromDate"
             placeholder="YYYY-MM-DD"
-            :state="getValidationState($v.fromDate)"
+            :state="getValidationState(v$.fromDate)"
             class="form-control-with-button mb-3 mb-md-0"
-            @blur="$v.fromDate.$touch()"
+            @blur="v$.fromDate.$touch()"
           />
           <b-form-invalid-feedback role="alert">
-            <template v-if="!$v.fromDate.pattern">
+            <template v-if="!v$.fromDate.pattern">
               {{ $t('global.form.invalidFormat') }}
             </template>
-            <template v-if="!$v.fromDate.maxDate">
+            <template v-if="!v$.fromDate.maxDate">
               {{ $t('global.form.dateMustBeBefore', { date: toDate }) }}
             </template>
           </b-form-invalid-feedback>
@@ -57,15 +57,15 @@
             id="input-to-date"
             v-model="toDate"
             placeholder="YYYY-MM-DD"
-            :state="getValidationState($v.toDate)"
+            :state="getValidationState(v$.toDate)"
             class="form-control-with-button"
-            @blur="$v.toDate.$touch()"
+            @blur="v$.toDate.$touch()"
           />
           <b-form-invalid-feedback role="alert">
-            <template v-if="!$v.toDate.pattern">
+            <template v-if="!v$.toDate.pattern">
               {{ $t('global.form.invalidFormat') }}
             </template>
-            <template v-if="!$v.toDate.minDate">
+            <template v-if="!v$.toDate.minDate">
               {{ $t('global.form.dateMustBeAfter', { date: fromDate }) }}
             </template>
           </b-form-invalid-feedback>
@@ -102,6 +102,7 @@
 import { helpers } from '@vuelidate/validators';
 import VuelidateMixin from '@/components/Mixins/VuelidateMixin.js';
 import { useVuelidate } from '@vuelidate/core';
+import { useI18n } from 'vue-i18n';
 
 const isoDateRegex = /([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/;
 
@@ -115,6 +116,7 @@
   },
   data() {
     return {
+      $t: useI18n().t,
       fromDate: '',
       toDate: '',
       offsetToDate: '',
@@ -158,8 +160,8 @@
   },
   methods: {
     emitChange() {
-      if (this.$v.$invalid) return;
-      this.$v.$reset(); //reset to re-validate on blur
+      if (this.v$.$invalid) return;
+      this.v$.$reset(); //reset to re-validate on blur
       this.$emit('change', {
         fromDate: this.fromDate ? new Date(this.fromDate) : null,
         toDate: this.toDate ? new Date(this.offsetToDate) : null,
diff --git a/src/components/Global/TableFilter.vue b/src/components/Global/TableFilter.vue
index 8c4f509..2ed88bf 100644
--- a/src/components/Global/TableFilter.vue
+++ b/src/components/Global/TableFilter.vue
@@ -55,6 +55,7 @@
 
 <script>
 import IconFilter from '@carbon/icons-vue/es/settings--adjust/20';
+import { useI18n } from 'vue-i18n';
 
 export default {
   name: 'TableFilter',
@@ -73,6 +74,7 @@
   },
   data() {
     return {
+      $t: useI18n().t,
       dropdownVisible: false,
       tags: [],
     };
diff --git a/src/components/Global/TableRowAction.vue b/src/components/Global/TableRowAction.vue
index 549f1b5..2129713 100644
--- a/src/components/Global/TableRowAction.vue
+++ b/src/components/Global/TableRowAction.vue
@@ -56,6 +56,7 @@
 
 <script>
 import { omit } from 'lodash';
+import { useI18n } from 'vue-i18n';
 
 export default {
   name: 'TableRowAction',
@@ -97,6 +98,11 @@
       default: true,
     },
   },
+  data() {
+    return {
+      $t: useI18n().t,
+    };
+  },
   computed: {
     dataForExport() {
       return JSON.stringify(omit(this.rowData, 'actions'));
diff --git a/src/components/Global/TableToolbar.vue b/src/components/Global/TableToolbar.vue
index 7c0f490..85d7c9c 100644
--- a/src/components/Global/TableToolbar.vue
+++ b/src/components/Global/TableToolbar.vue
@@ -31,6 +31,7 @@
 </template>
 
 <script>
+import { useI18n } from 'vue-i18n';
 export default {
   name: 'TableToolbar',
   props: {
@@ -53,6 +54,7 @@
   },
   data() {
     return {
+      $t: useI18n().t,
       isToolbarActive: false,
     };
   },
diff --git a/src/components/Global/TableToolbarExport.vue b/src/components/Global/TableToolbarExport.vue
index 69646ea..c678555 100644
--- a/src/components/Global/TableToolbarExport.vue
+++ b/src/components/Global/TableToolbarExport.vue
@@ -10,6 +10,7 @@
 </template>
 
 <script>
+import { useI18n } from 'vue-i18n';
 export default {
   props: {
     data: {
@@ -21,6 +22,11 @@
       default: 'data',
     },
   },
+  data() {
+    return {
+      $t: useI18n().t,
+    };
+  },
   computed: {
     dataForExport() {
       return JSON.stringify(this.data);