diff --git a/.env.example b/.env.example index 66ccb28dd..84958bf80 100644 --- a/.env.example +++ b/.env.example @@ -17,3 +17,4 @@ VUE_APP_NOTIF_ENUM_TYPE_ID=NOTIF_BOPIS VUE_APP_FIREBASE_CONFIG={"apiKey": "","authDomain": "","databaseURL": "","projectId": "","storageBucket": "","messagingSenderId": "","appId": ""} VUE_APP_FIREBASE_VAPID_KEY="" VUE_APP_PRODUCT_STORE_SETTING_ENUMS={"ENABLE_TRACKING": {"enumId": "ENABLE_TRACKING","enumName": "Enable tracking","enumTypeId": "PROD_STR_STNG","description": "Enable tracking in BOPIS app"}, "PRINT_PACKING_SLIPS": {"enumId": "PRINT_PACKING_SLIPS","enumName": "Generate packing slips","enumTypeId": "PROD_STR_STNG","description": "Generate packing slips in BOPIS app"}, "PRINT_PICKLISTS": {"enumId": "PRINT_PICKLISTS","enumName": "Print picklists","enumTypeId": "PROD_STR_STNG","description": "Print picklists in BOPIS app"}, "SHOW_SHIPPING_ORDERS": {"enumId": "SHOW_SHIPPING_ORDERS","enumName": "Show shipping orders","enumTypeId": "PROD_STR_STNG","description": "Show shipping orders in BOPIS app"}} +VUE_APP_BUILD="" diff --git a/src/router/index.ts b/src/router/index.ts index 811bae5ee..ed47335da 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -124,12 +124,25 @@ const routes: Array = [ }, ] +const appVersion = window.location.pathname.split('/').slice(0, 2)[1]; +console.log('App Version: ', appVersion) + const router = createRouter({ - history: createWebHistory(process.env.BASE_URL), + // TODO: check if we need this condition to check for VUE_APP_BUILD value and compare it with appVersion + history: createWebHistory(appVersion == process.env.VUE_APP_BUILD ? appVersion : process.env.BASE_URL), routes }) router.beforeEach((to, from) => { + console.log('store.state.user.appVersion', store.state.user.appVersion) + if(store.state.user.appVersion && store.state.user.appVersion !== appVersion) { + console.log('replacing app version') + window.location.replace(window.location.pathname.replace(appVersion, store.state.user.appVersion)) + } else if(appVersion) { + console.log('updated versions', appVersion) + store.dispatch("user/updateAppVersion", appVersion) + } + if (to.meta.permissionId && !hasPermission(to.meta.permissionId)) { let redirectToPath = from.path; // If the user has navigated from Login page or if it is page load, redirect user to settings page without showing any toast diff --git a/src/store/modules/user/UserState.ts b/src/store/modules/user/UserState.ts index b4837d60c..9a50c9a2a 100644 --- a/src/store/modules/user/UserState.ts +++ b/src/store/modules/user/UserState.ts @@ -12,4 +12,5 @@ export default interface UserState { allNotificationPrefs: any; bopisProductStoreSettings: any; omsRedirectionUrl: string; + appVersion: string; } \ No newline at end of file diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index d448c051d..8a795371a 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -172,6 +172,7 @@ const actions: ActionTree = { this.dispatch("util/clearStoresInformation", {}) commit(types.USER_END_SESSION) dispatch("setOmsRedirectionUrl", "") + dispatch("updateAppVersion", "") resetPermissions(); resetConfig(); @@ -504,6 +505,10 @@ const actions: ActionTree = { clearPartialOrderRejectionConfig ({ commit }) { commit(types.USER_PARTIAL_ORDER_REJECTION_CONFIG_UPDATED, {}) + }, + + updateAppVersion ({ commit }, version) { + commit(types.USER_APP_VERSION_UPDATED, version) } } export default actions; \ No newline at end of file diff --git a/src/store/modules/user/getters.ts b/src/store/modules/user/getters.ts index 48072d3e7..d73233c35 100644 --- a/src/store/modules/user/getters.ts +++ b/src/store/modules/user/getters.ts @@ -62,6 +62,8 @@ const getters: GetterTree = { getBopisProductStoreSettings: (state) => (enumId: string) => { return state.bopisProductStoreSettings[enumId] }, - + getAppVersion: (state) => { + return state.appVersion + }, } export default getters; \ No newline at end of file diff --git a/src/store/modules/user/index.ts b/src/store/modules/user/index.ts index c25f0d8ce..c8edeb1ad 100644 --- a/src/store/modules/user/index.ts +++ b/src/store/modules/user/index.ts @@ -20,7 +20,8 @@ const userModule: Module = { hasUnreadNotifications: true, allNotificationPrefs: [], bopisProductStoreSettings: {}, - omsRedirectionUrl: "" + omsRedirectionUrl: "", + appVersion: "" }, getters, actions, diff --git a/src/store/modules/user/mutation-types.ts b/src/store/modules/user/mutation-types.ts index 5f6210f6b..4efcc4ce0 100644 --- a/src/store/modules/user/mutation-types.ts +++ b/src/store/modules/user/mutation-types.ts @@ -12,4 +12,5 @@ export const USER_ALL_NOTIFICATION_PREFS_UPDATED = SN_USER + '/ALL_NOTIFICATION_ export const USER_FIREBASE_DEVICEID_UPDATED = SN_USER + '/FIREBASE_DEVICEID_UPDATED' export const USER_UNREAD_NOTIFICATIONS_STATUS_UPDATED = SN_USER + '/UNREAD_NOTIFICATIONS_STATUS_UPDATED' export const USER_BOPIS_PRODUCT_STORE_SETTINGS_UPDATED = SN_USER + '/BOPIS_PRODUCT_STORE_SETTINGS_UPDATED' -export const USER_OMS_REDIRECTION_URL_UPDATED = SN_USER + "/OMS_REDIRECTION_INFO_UPDATED" \ No newline at end of file +export const USER_OMS_REDIRECTION_URL_UPDATED = SN_USER + "/OMS_REDIRECTION_INFO_UPDATED" +export const USER_APP_VERSION_UPDATED = SN_USER + "/APP_VERSION_UPDATED" diff --git a/src/store/modules/user/mutations.ts b/src/store/modules/user/mutations.ts index 49219e5c2..cc48241f4 100644 --- a/src/store/modules/user/mutations.ts +++ b/src/store/modules/user/mutations.ts @@ -47,8 +47,10 @@ const mutations: MutationTree = { state.bopisProductStoreSettings = payload }, [types.USER_OMS_REDIRECTION_URL_UPDATED](state, payload) { - state.omsRedirectionUrl = payload; + state.omsRedirectionUrl = payload; + }, + [types.USER_APP_VERSION_UPDATED](state, payload) { + state.appVersion = payload; } - } export default mutations; \ No newline at end of file diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 61d8a5e6c..7f2706283 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -291,7 +291,8 @@ export default defineComponent({ }) }, mounted() { - this.appVersion = this.appInfo.branch ? (this.appInfo.branch + "-" + this.appInfo.revision) : this.appInfo.tag; + this.appVersion = process.env.VUE_APP_BUILD ? process.env.VUE_APP_BUILD : this.appInfo.branch ? (this.appInfo.branch + "-" + this.appInfo.revision) : this.appInfo.tag; + console.log('this.appVersion', this.appVersion, process.env.VUE_APP_BUILD) }, async ionViewWillEnter() { // Clearing the current order as to correctly display the selected segment when moving to list page diff --git a/vue.config.js b/vue.config.js index e1d231d37..7d4403078 100644 --- a/vue.config.js +++ b/vue.config.js @@ -2,13 +2,6 @@ require("@hotwax/app-version-info") const path = require('path') module.exports = { - configureWebpack: { - resolve: { - alias: { - vue: path.resolve('./node_modules/vue') - } - } - }, configureWebpack: { resolve: { alias: { @@ -17,5 +10,7 @@ module.exports = { } }, runtimeCompiler: true, - transpileDependencies: ['@hotwax/dxp-components'] + transpileDependencies: ['@hotwax/dxp-components'], + outputDir: `dist/${process.env.VUE_APP_BUILD}`, + publicPath: process.env.NODE_ENV === "production" ? `./${process.env.VUE_APP_BUILD}` : "/" }