From 4d012d13f5f6d7a0df17f482549d24609e1391e8 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Tue, 6 Aug 2024 11:41:15 +0530 Subject: [PATCH 1/4] Implemented: support for maarg login in ofbiz apps (preorder-293) --- .env.example | 3 ++- src/util/index.ts | 7 ++++++- src/views/Login.vue | 9 +++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index f212c93..33bcdbe 100644 --- a/.env.example +++ b/.env.example @@ -4,4 +4,5 @@ VUE_APP_I18N_FALLBACK_LOCALE=en VUE_APP_LOCALES={"en": "English", "ja": "日本語", "es": "Español"} VUE_APP_CURRENCY_FORMATS={"en": {"currency": {"style": "currency","currency": "USD"}}, "ja": {"currency": {"style": "currency", "currency": "JPY"}}, "es": {"currency": {"style": "currency","currency": "ESP"}}} VUE_APP_DEFAULT_ALIAS= -VUE_APP_MAARG_LOGIN=["atp", "company", "order-routing"] \ No newline at end of file +VUE_APP_MAARG_LOGIN=["atp", "company", "order-routing"] +VUE_APP_MAARG_LOGIN_REQUIRED=["preorder"] \ No newline at end of file diff --git a/src/util/index.ts b/src/util/index.ts index 945221d..c29240b 100644 --- a/src/util/index.ts +++ b/src/util/index.ts @@ -15,4 +15,9 @@ const isMaargLogin = (handle: string) => { return maargLoginApps.some((appName: string) => handle.includes(appName)) } -export { isMaargLogin, showToast } \ No newline at end of file +const isMaargLoginRequired = (handle: string) => { + const maargOmsRequiredApps = JSON.parse(process.env.VUE_APP_MAARG_LOGIN_REQUIRED ? process.env.VUE_APP_MAARG_LOGIN_REQUIRED : []) + return maargOmsRequiredApps.some((appName: string) => handle.includes(appName)) +} + +export { isMaargLogin, isMaargLoginRequired, showToast } \ No newline at end of file diff --git a/src/views/Login.vue b/src/views/Login.vue index 16c652d..c7520ec 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -73,7 +73,7 @@ import Logo from '@/components/Logo.vue'; import { arrowForwardOutline, gridOutline } from 'ionicons/icons' import { UserService } from "@/services/UserService"; import { translate } from "@/i18n"; -import { isMaargLogin, showToast } from "@/util"; +import { isMaargLogin, isMaargLoginRequired, showToast } from "@/util"; import { hasError } from "@hotwax/oms-api"; export default defineComponent({ @@ -293,6 +293,7 @@ export default defineComponent({ }, generateRedirectionLink() { let omsUrl = '' + let omsRedirectionUrl = '' if(isMaargLogin(this.authStore.getRedirectUrl)) { if(this.authStore.getMaargOms) omsUrl = this.authStore.getMaargOms else { @@ -302,8 +303,12 @@ export default defineComponent({ } } + if(isMaargLoginRequired(this.authStore.getRedirectUrl) && this.authStore.getMaargOms) { + omsRedirectionUrl = this.authStore.getMaargOms + } + omsUrl = omsUrl ? omsUrl : this.authStore.oms.startsWith('http') ? this.authStore.oms.includes('/api') ? this.authStore.oms : `${this.authStore.oms}/api/` : this.authStore.oms - window.location.href = `${this.authStore.getRedirectUrl}?oms=${omsUrl}&token=${this.authStore.token.value}&expirationTime=${this.authStore.token.expiration}${isMaargLogin(this.authStore.getRedirectUrl) ? '&omsRedirectionUrl=' + this.authStore.oms : ''}` + window.location.href = `${this.authStore.getRedirectUrl}?oms=${omsUrl}&token=${this.authStore.token.value}&expirationTime=${this.authStore.token.expiration}${omsRedirectionUrl ? '&omsRedirectionUrl=' + omsRedirectionUrl : ''}` } }, setup () { From d6265560edccaf0ab807d849cb1efd8b6dc009ec Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Wed, 7 Aug 2024 11:07:21 +0530 Subject: [PATCH 2/4] Improved: app generation link from home page (#293) --- src/views/Home.vue | 5 +++-- src/views/Login.vue | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/views/Home.vue b/src/views/Home.vue index cd2e76a..4360cb1 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -90,7 +90,7 @@ import { import { useAuthStore } from '@/store/auth'; import { useRouter } from "vue-router"; import { goToOms } from '@hotwax/dxp-components' -import { isMaargLogin } from '@/util'; +import { isMaargLogin, isMaargLoginRequired } from '@/util'; import { translate } from '@/i18n'; export default defineComponent({ @@ -135,7 +135,7 @@ export default defineComponent({ }, generateAppLink(app: any, appEnvironment = '') { const oms = isMaargLogin(app.handle) ? this.authStore.getMaargOms : this.authStore.getOMS; - window.location.href = this.scheme + app.handle + appEnvironment + this.domain + (this.authStore.isAuthenticated ? `/login?oms=${oms.startsWith('http') ? isMaargLogin(app.handle) ? oms : oms.includes('/api') ? oms : `${oms}/api/` : oms}&token=${this.authStore.token.value}&expirationTime=${this.authStore.token.expiration}${isMaargLogin(app.handle) ? '&omsRedirectionUrl=' + this.authStore.getOMS : ''}` : '') + window.location.href = this.scheme + app.handle + appEnvironment + this.domain + (this.authStore.isAuthenticated ? `/login?oms=${oms.startsWith('http') ? isMaargLogin(app.handle) ? oms : oms.includes('/api') ? oms : `${oms}/api/` : oms}&token=${this.authStore.token.value}&expirationTime=${this.authStore.token.expiration}${isMaargLogin(app.handle) ? '&omsRedirectionUrl=' + this.authStore.getOMS : isMaargLoginRequired(app.handle) ? '&omsRedirectionUrl=' + this.authStore.getMaargOms : ''}` : '') } }, setup() { @@ -232,6 +232,7 @@ export default defineComponent({ domain, goToOms, isMaargLogin, + isMaargLoginRequired, lockClosedOutline, hardwareChipOutline, openOutline, diff --git a/src/views/Login.vue b/src/views/Login.vue index c7520ec..4405fea 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -301,6 +301,7 @@ export default defineComponent({ this.router.push("/") return; } + omsRedirectionUrl = this.authStore.oms } if(isMaargLoginRequired(this.authStore.getRedirectUrl) && this.authStore.getMaargOms) { From a6747060f6fe47a39be61b2c1a2fe16457c90457 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Mon, 14 Oct 2024 12:03:54 +0530 Subject: [PATCH 3/4] Improved: variable name for the check for moquiInCaseOfOms (preorder-293) --- .env.example | 2 +- src/util/index.ts | 6 +++--- src/views/Home.vue | 6 +++--- src/views/Login.vue | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.env.example b/.env.example index fe4f382..fae3aa0 100644 --- a/.env.example +++ b/.env.example @@ -6,4 +6,4 @@ VUE_APP_CURRENCY_FORMATS={"en": {"currency": {"style": "currency","currency": "U VUE_APP_DEFAULT_ALIAS= VUE_APP_MAARG_LOGIN=["atp", "company", "order-routing", "inventorycount"] VUE_APP_USERS_LOGIN_URL="http://users.hotwax.io/login" -VUE_APP_MAARG_LOGIN_REQUIRED=["preorder"] +VUE_APP_OMS_WITH_MAARG=["preorder"] diff --git a/src/util/index.ts b/src/util/index.ts index b151711..13784dc 100644 --- a/src/util/index.ts +++ b/src/util/index.ts @@ -16,10 +16,10 @@ const isMaargLogin = (handle: string, environment = "") => { return maargLoginApps.some((appName: string) => appHandle.includes(appName)) } -const isMaargLoginRequired = (handle: string, environment = "") => { +const isOmsWithMaarg = (handle: string, environment = "") => { const appHandle = environment ? handle + environment : handle - const maargOmsRequiredApps = JSON.parse(process.env.VUE_APP_MAARG_LOGIN_REQUIRED ? process.env.VUE_APP_MAARG_LOGIN_REQUIRED : []) + const maargOmsRequiredApps = JSON.parse(process.env.VUE_APP_OMS_WITH_MAARG ? process.env.VUE_APP_OMS_WITH_MAARG : []) return maargOmsRequiredApps.some((appName: string) => appHandle.includes(appName)) } -export { isMaargLogin, isMaargLoginRequired, showToast } \ No newline at end of file +export { isMaargLogin, isOmsWithMaarg, showToast } \ No newline at end of file diff --git a/src/views/Home.vue b/src/views/Home.vue index c603af4..ccd1938 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -95,7 +95,7 @@ import { import { useAuthStore } from '@/store/auth'; import { useRouter } from "vue-router"; import { goToOms } from '@hotwax/dxp-components' -import { isMaargLogin, isMaargLoginRequired } from '@/util'; +import { isMaargLogin, isOmsWithMaarg } from '@/util'; import { translate } from '@/i18n'; import UserActionsPopover from '@/components/UserActionsPopover.vue' import Image from "@/components/Image.vue"; @@ -144,7 +144,7 @@ export default defineComponent({ }, generateAppLink(app: any, appEnvironment = '') { const oms = isMaargLogin(app.handle, appEnvironment) ? this.authStore.getMaargOms : this.authStore.getOMS; - window.location.href = this.scheme + app.handle + appEnvironment + this.domain + (this.authStore.isAuthenticated ? `/login?oms=${oms.startsWith('http') ? isMaargLogin(app.handle, appEnvironment) ? oms : oms.includes('/api') ? oms : `${oms}/api/` : oms}&token=${this.authStore.token.value}&expirationTime=${this.authStore.token.expiration}${isMaargLogin(app.handle, appEnvironment) ? '&omsRedirectionUrl=' + this.authStore.getOMS : isMaargLoginRequired(app.handle, appEnvironment) ? '&omsRedirectionUrl=' + this.authStore.getMaargOms : ''}` : '') + window.location.href = this.scheme + app.handle + appEnvironment + this.domain + (this.authStore.isAuthenticated ? `/login?oms=${oms.startsWith('http') ? isMaargLogin(app.handle, appEnvironment) ? oms : oms.includes('/api') ? oms : `${oms}/api/` : oms}&token=${this.authStore.token.value}&expirationTime=${this.authStore.token.expiration}${isMaargLogin(app.handle, appEnvironment) ? '&omsRedirectionUrl=' + this.authStore.getOMS : isOmsWithMaarg(app.handle, appEnvironment) ? '&omsRedirectionUrl=' + this.authStore.getMaargOms : ''}` : '') }, async openUserActionsPopover(event: any) { const userActionsPopover = await popoverController.create({ @@ -251,7 +251,7 @@ export default defineComponent({ domain, goToOms, isMaargLogin, - isMaargLoginRequired, + isOmsWithMaarg, lockClosedOutline, hardwareChipOutline, openOutline, diff --git a/src/views/Login.vue b/src/views/Login.vue index 871d343..c498423 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -76,7 +76,7 @@ import Logo from '@/components/Logo.vue'; import { arrowForwardOutline, gridOutline } from 'ionicons/icons' import { UserService } from "@/services/UserService"; import { translate } from "@/i18n"; -import { isMaargLogin, isMaargLoginRequired, showToast } from "@/util"; +import { isMaargLogin, isOmsWithMaarg, showToast } from "@/util"; import { hasError } from "@hotwax/oms-api"; export default defineComponent({ @@ -315,7 +315,7 @@ export default defineComponent({ omsRedirectionUrl = this.authStore.oms } - if(isMaargLoginRequired(this.authStore.getRedirectUrl) && this.authStore.getMaargOms) { + if(isOmsWithMaarg(this.authStore.getRedirectUrl) && this.authStore.getMaargOms) { omsRedirectionUrl = this.authStore.getMaargOms } From 9ec4e0e965ba2490df3d639ba73b3bbbc7fa7580 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Tue, 15 Oct 2024 15:49:46 +0530 Subject: [PATCH 4/4] Improved: variable name for list of apps for better user understandability (#293) --- src/util/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/index.ts b/src/util/index.ts index 13784dc..9869901 100644 --- a/src/util/index.ts +++ b/src/util/index.ts @@ -18,8 +18,8 @@ const isMaargLogin = (handle: string, environment = "") => { const isOmsWithMaarg = (handle: string, environment = "") => { const appHandle = environment ? handle + environment : handle - const maargOmsRequiredApps = JSON.parse(process.env.VUE_APP_OMS_WITH_MAARG ? process.env.VUE_APP_OMS_WITH_MAARG : []) - return maargOmsRequiredApps.some((appName: string) => appHandle.includes(appName)) + const appsWithMarg = JSON.parse(process.env.VUE_APP_OMS_WITH_MAARG ? process.env.VUE_APP_OMS_WITH_MAARG : []) + return appsWithMarg.some((appName: string) => appHandle.includes(appName)) } export { isMaargLogin, isOmsWithMaarg, showToast } \ No newline at end of file