Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
15 changes: 14 additions & 1 deletion src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,25 @@ const routes: Array<RouteRecordRaw> = [
},
]

const appVersion = window.location.pathname.split('/').slice(0, 2)[1];
console.log('App Version: ', appVersion)
Comment thread
ymaheshwari1 marked this conversation as resolved.

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),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The logic to determine the history's base path is complex, and the TODO comment indicates it's not finalized. The check appVersion == process.env.VUE_APP_BUILD seems to prevent using older versions of the app, as it would cause the router to use an incorrect base path. The redirection logic in router.beforeEach should be sufficient to handle incorrect versions.

A simpler and more correct approach would be to use appVersion as the base path if it exists. This also depends on the publicPath setting in vue.config.js. If publicPath is correctly set to an absolute path, you can likely just use createWebHistory(process.env.BASE_URL).

Suggested change
history: createWebHistory(appVersion == process.env.VUE_APP_BUILD ? appVersion : process.env.BASE_URL),
history: createWebHistory(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)
}
Comment thread
ymaheshwari1 marked this conversation as resolved.

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
Expand Down
1 change: 1 addition & 0 deletions src/store/modules/user/UserState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export default interface UserState {
allNotificationPrefs: any;
bopisProductStoreSettings: any;
omsRedirectionUrl: string;
appVersion: string;
}
5 changes: 5 additions & 0 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ const actions: ActionTree<UserState, RootState> = {
this.dispatch("util/clearStoresInformation", {})
commit(types.USER_END_SESSION)
dispatch("setOmsRedirectionUrl", "")
dispatch("updateAppVersion", "")
resetPermissions();
resetConfig();

Expand Down Expand Up @@ -504,6 +505,10 @@ const actions: ActionTree<UserState, RootState> = {

clearPartialOrderRejectionConfig ({ commit }) {
commit(types.USER_PARTIAL_ORDER_REJECTION_CONFIG_UPDATED, {})
},

updateAppVersion ({ commit }, version) {
commit(types.USER_APP_VERSION_UPDATED, version)
}
}
export default actions;
4 changes: 3 additions & 1 deletion src/store/modules/user/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ const getters: GetterTree <UserState, RootState> = {
getBopisProductStoreSettings: (state) => (enumId: string) => {
return state.bopisProductStoreSettings[enumId]
},

getAppVersion: (state) => {
return state.appVersion
},
}
export default getters;
3 changes: 2 additions & 1 deletion src/store/modules/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const userModule: Module<UserState, RootState> = {
hasUnreadNotifications: true,
allNotificationPrefs: [],
bopisProductStoreSettings: {},
omsRedirectionUrl: ""
omsRedirectionUrl: "",
appVersion: ""
},
getters,
actions,
Expand Down
3 changes: 2 additions & 1 deletion src/store/modules/user/mutation-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
export const USER_OMS_REDIRECTION_URL_UPDATED = SN_USER + "/OMS_REDIRECTION_INFO_UPDATED"
export const USER_APP_VERSION_UPDATED = SN_USER + "/APP_VERSION_UPDATED"
6 changes: 4 additions & 2 deletions src/store/modules/user/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ const mutations: MutationTree <UserState> = {
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;
3 changes: 2 additions & 1 deletion src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment thread
ymaheshwari1 marked this conversation as resolved.
},
async ionViewWillEnter() {
// Clearing the current order as to correctly display the selected segment when moving to list page
Expand Down
11 changes: 3 additions & 8 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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}` : "/"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using a relative publicPath (starting with ./) is not recommended when using HTML5 history mode for client-side routing. It can cause problems with nested routes and requires specific server configuration to work correctly. It's safer to use an absolute path to avoid ambiguity and ensure routing works as expected.

Suggested change
publicPath: process.env.NODE_ENV === "production" ? `./${process.env.VUE_APP_BUILD}` : "/"
publicPath: process.env.NODE_ENV === "production" ? `/${process.env.VUE_APP_BUILD}/` : "/"

}