Skip to content
Merged
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
10 changes: 5 additions & 5 deletions .github/workflows/deploy-vue-storefront-cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@ jobs:
uses: ./.github/workflows/deployment-template.yml
needs: build
if: github.ref == 'refs/heads/main'
with:
with:
github_environment_name: production
environment_code: demo-magento2
target_url: https://demo-magento2.europe-west1.gcp.storefrontcloud.io
secrets:
cloud_username: ${{ secrets.CLOUD_USERNAME }}
cloud_password: ${{ secrets.CLOUD_PASSWORD }}

deploy-develop:
uses: ./.github/workflows/deployment-template.yml
needs: build
if: github.ref == 'refs/heads/develop'
with:
with:
github_environment_name: dev
environment_code: demo-magento2-dev
target_url: https://demo-magento2-dev.europe-west1.gcp.storefrontcloud.io
Expand All @@ -77,7 +77,7 @@ jobs:
uses: ./.github/workflows/deployment-template.yml
needs: build
if: startsWith(github.ref, 'refs/heads/release')
with:
with:
github_environment_name: canary
environment_code: demo-magento2-canary
target_url: https://demo-magento2-canary.europe-west1.gcp.storefrontcloud.io
Expand All @@ -89,7 +89,7 @@ jobs:
uses: ./.github/workflows/deployment-template.yml
needs: build
if: github.ref == 'refs/heads/enterprise'
with:
with:
github_environment_name: enterprise
environment_code: demo-magento2-enterprise
target_url: https://demo-magento2-enterprise.europe-west1.gcp.storefrontcloud.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
<a
href="/"
:class="selectedCurrency === currency ? 'container__currency--selected-label' : ''"
@click.prevent="handleChanges({
callback: () => changeCurrency({id: currency}),
redirect: false,
refresh: true
})"
@click.prevent="changeCurrency({id: currency})"
>
<SfCharacteristic class="currency">
<template #title>
Expand All @@ -42,7 +38,6 @@ import {
import {
useCurrency,
} from '~/composables';
import { useHandleChanges } from '~/helpers/magentoConfig/handleChanges';

export default defineComponent({
name: 'CurrenciesModal',
Expand All @@ -63,8 +58,6 @@ export default defineComponent({
load: loadCurrencies,
} = useCurrency();

const { handleChanges } = useHandleChanges();

const availableCurrencies = computed(() => currencies.value?.available_currency_codes || []);

onMounted(() => {
Expand All @@ -74,7 +67,6 @@ export default defineComponent({

return {
changeCurrency,
handleChanges,
availableCurrencies,
};
},
Expand Down
12 changes: 1 addition & 11 deletions packages/theme/components/StoreSwitcher/StoresModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@
? 'container__store--selected'
: ''
"
@click="
handleChanges({
callback: () => changeStore(store),
redirect: false,
windowRefresh: true,
})
"
@click.prevent="changeStore(store)"
>
<SfCharacteristic class="language">
<template #title>
Expand Down Expand Up @@ -57,7 +51,6 @@ import {
} from '@storefront-ui/vue';
import { useStore } from '~/composables';
import { storeGetters, storeConfigGetters } from '~/getters';
import { useHandleChanges } from '~/helpers/magentoConfig/handleChanges';

export default defineComponent({
name: 'StoresModal',
Expand All @@ -73,8 +66,6 @@ export default defineComponent({
},
emits: ['closeModal'],
setup() {
const { handleChanges } = useHandleChanges();

const {
stores,
change: changeStore,
Expand All @@ -91,7 +82,6 @@ export default defineComponent({
return {
storeGetters,
storeConfigGetters,
handleChanges,
availableStores,
changeStore,
};
Expand Down
1 change: 1 addition & 0 deletions packages/theme/composables/useCurrency/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const useCurrency = (): UseCurrency => {

try {
app.$vsf.$magento.config.state.setCurrency(params.id);
window.location.reload();
} catch (err) {
Logger.debug('[ERROR] useCurrency/change', err);
error.value.change = err;
Expand Down
2 changes: 2 additions & 0 deletions packages/theme/composables/useStore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const useStore: UseStore = (): UseStoreInterface => {
app.$vsf.$magento.config.state.setStore(storeConfigGetters.getCode(store));
app.$vsf.$magento.config.state.setCurrency(storeConfigGetters.getCurrency(store));
app.$vsf.$magento.config.state.setLocale(storeConfigGetters.getCode(store));
const newStoreUrl = app.switchLocalePath(storeConfigGetters.getCode(store));
window.location.replace(newStoreUrl);
} catch (err) {
error.value.change = err;
}
Expand Down
39 changes: 0 additions & 39 deletions packages/theme/helpers/magentoConfig/handleChanges.ts

This file was deleted.

25 changes: 1 addition & 24 deletions packages/theme/modules/magento/index.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,8 @@
/* eslint-disable unicorn/prefer-module */
const path = require('path');

const mapI18nSettings = (i18n) => ({
locales: i18n.locales.map(({ label, code }) => ({ name: code, label })),
});

const isNuxtI18nUsed = (moduleOptions) => moduleOptions.i18n && moduleOptions.i18n.useNuxtI18nConfig;

const getMissingFields = (options) => [
'locales',
].filter((o) => options[o] === undefined);

// eslint-disable-next-line func-names
export default function (moduleOptions) {
const options = isNuxtI18nUsed(moduleOptions)
? {
...moduleOptions,
...mapI18nSettings(this.options.i18n),
}
: moduleOptions;

const missingFields = getMissingFields(options);

if (missingFields.length > 0) {
throw new Error(`Please provide missing i18n fields: (${missingFields.join(', ')})`);
}

export default function (options) {
this.extendBuild((config) => {
// eslint-disable-next-line no-param-reassign
config.resolve.alias['@vue-storefront/magento-api$'] = require.resolve('@vue-storefront/magento-api');
Expand Down
27 changes: 8 additions & 19 deletions packages/theme/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,21 @@ export default () => {
'@nuxtjs/style-resources',
'@nuxtjs/device',
['@vue-storefront/nuxt', {
// @core-development-only-start
coreDevelopment: true,
// @core-development-only-end
useRawSource: {
dev: [
'@vue-storefront/core',
],
prod: [
'@vue-storefront/core',
],
},
// selectively disabling certain @vue-storefront/core plugins for migration
context: false,
logger: false,
ssr: false,
sfui: false,
i18nExtension: false,
e2e: true,
performance: {
httpPush: false,
purgeCSS: {
enabled: false,
},
},
}],
['~/modules/magento', {
i18n: {
useNuxtI18nConfig: true,
},
cookies,
externalCheckout,
defaultStore,
Expand Down Expand Up @@ -149,11 +143,6 @@ export default () => {
},
],
defaultLocale: 'default',
autoChangeCookie: {
currency: false,
locale: false,
country: false,
},
lazy: true,
seo: true,
langDir: 'lang/',
Expand Down
3 changes: 1 addition & 2 deletions packages/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@
"@pinia/nuxt": "^0.1.8",
"@storefront-ui/vue": "^0.13.0",
"@vue-storefront/cache": "~2.5.6",
"@vue-storefront/core": "~2.5.6",
"@vue-storefront/middleware": "~2.5.6",
"@vue-storefront/magento-api": "~1.0.0-rc.6",
"@vue-storefront/middleware": "~2.5.6",
"@vue-storefront/nuxt": "~2.5.6",
"@vue-storefront/redis-cache": "^1.0.1",
"axios": "^0.26.1",
Expand Down
3 changes: 0 additions & 3 deletions packages/theme/plugins/__tests__/i18n.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,5 @@ describe('i18n plugin', () => {
expect(testCaseAppMock.$vsf.$magento.config.state.setLocale).toHaveBeenCalledWith('de_DE');
expect(testCaseAppMock.$vsf.$magento.config.state.setStore).toHaveBeenCalledWith('de_DE');
expect(testCaseAppMock.$vsf.$magento.config.state.setCurrency).toHaveBeenCalledWith('EUR');
expect(callbackRequest.headers.cookie).toMatchInlineSnapshot(
'"vsf-store=de_DE; vsf-locale=de_DE; vsf-currency=EUR; vsf-country=PL; vsf-customer=12fg45; vsf-cart=123 "',
);
});
});
31 changes: 0 additions & 31 deletions packages/theme/plugins/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,34 +60,6 @@ const setDefaultLocale = async (i18n) => {
await i18n.setLocale(i18n.defaultLocale);
};

/**
* Prepare new cookie string based on app state.
*
* @param apiState {ConfigState}
* @param newStoreCode {string}
* @param currency {string}
* @returns {string}
*/
const prepareNewCookieString = (apiState: ConfigState, newStoreCode: string, currency: string) => {
const customerTokenCookie = apiState.getCustomerToken();
const cartIdCookie = apiState.getCartId();

let cookie = `vsf-store=${newStoreCode}; `;
cookie += `vsf-locale=${newStoreCode}; `;
cookie += `vsf-currency=${currency}; `;
cookie += `vsf-country=${apiState.getCountry()}; `;

if (customerTokenCookie) {
cookie += `vsf-customer=${customerTokenCookie}; `;
}

if (cartIdCookie) {
cookie += `vsf-cart=${cartIdCookie} `;
}

return cookie;
};

export default async ({ app, route }: Context) => {
await app.$vsf.$magento.client.interceptors.request.use(async (request) => {
const { i18n } = app;
Expand All @@ -110,9 +82,6 @@ export default async ({ app, route }: Context) => {
apiState.setStore(i18nCurrentLocaleCode);
apiState.setLocale(i18nCurrentLocaleCode);
apiState.setCurrency(currency);

// eslint-disable-next-line no-param-reassign
request.headers.cookie = prepareNewCookieString(apiState, i18nCurrentLocaleCode, currency);
}

return request;
Expand Down