Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
209f53a
fix image loading styles
Dec 16, 2019
662cb1d
update changelog
Dec 16, 2019
bd6a570
Merge branch 'hotfix/v1.10.6' into bugfix/ProductImageLoading
andrzejewsky Dec 26, 2019
1b5ba0e
Update CHANGELOG.md
andrzejewsky Dec 26, 2019
6d3b84d
Merge pull request #3906 from pspaczek/bugfix/ProductImageLoading
andrzejewsky Dec 26, 2019
de11e22
update url/router/beforeEach based on 1.11
Dec 30, 2019
d8130f6
update changelog
Dec 30, 2019
6105158
Merge pull request #3967 from gibkigonzo/bugfix/3956
andrzejewsky Dec 30, 2019
be83fc6
Fix hiding overlay for newsletter modal
Jan 7, 2020
225fc7a
Merge pull request #3973 from gibkigonzo/bugfix/3970
andrzejewsky Jan 7, 2020
e8fb5ca
create token only when its needed in offline and checkout
Jan 17, 2020
b9bc274
remove createing token when login, add updating payments methods in c…
Jan 17, 2020
fe5de3e
remove token creation after make order
Jan 17, 2020
755f3ef
revert sync cart
Jan 17, 2020
a301410
remove force create and use authorize
Jan 17, 2020
4519825
always clear cart after order
Jan 20, 2020
b25d9e8
update tests
Jan 23, 2020
1763996
3995 merge products quantity only when token is loaded/created
Jan 23, 2020
d3debc4
remove bypassCartLoaderForAuthorizedUsers
Jan 23, 2020
5a5bb2e
update changelog
Jan 24, 2020
eb397a1
Merge pull request #3994 from gibkigonzo/feature/add-lazy-creating-ca…
andrzejewsky Jan 24, 2020
525a884
revert adding filters with app init
Jan 2, 2020
1b97d87
remove storeView as dependency from filters
Jan 24, 2020
f234875
update filters in components
Jan 24, 2020
1ecffb5
update changelog
Jan 24, 2020
727f172
Merge pull request #4023 from gibkigonzo/backport/pr-3968
andrzejewsky Jan 25, 2020
145f50c
Merge branch 'hotfix/v1.10.6' into bugfix/3995-tkostuch
andrzejewsky Jan 25, 2020
56c8f84
Merge pull request #4017 from gibkigonzo/bugfix/3995-tkostuch
andrzejewsky Jan 25, 2020
ce327f9
fix radio button v-model
lukeromanowicz Jan 31, 2020
518b9ee
Merge branch 'hotfix/v1.10.6' into bugfix/radio-button-v-model
lukeromanowicz Jan 31, 2020
510b138
changelog update
lukeromanowicz Jan 31, 2020
e9ae0f8
Merge pull request #4043 from lukeromanowicz/bugfix/radio-button-v-model
andrzejewsky Feb 3, 2020
9000958
4062 update clear/cart mehtod
Feb 7, 2020
49159e5
4062 add comments
Feb 7, 2020
09e11e5
update changelog
Feb 7, 2020
d5fb285
4062 update tests
Feb 7, 2020
ed5d8a8
Merge pull request #4068 from gibkigonzo/bugfix/4062
andrzejewsky Feb 9, 2020
9647ff6
fix current token invalidation with refresh token
Feb 11, 2020
66e961e
update changelog
Feb 11, 2020
1683e6f
add helper getResponseCode
Feb 11, 2020
cc8d33a
Merge branch 'hotfix/v1.10.6' into bugfix/update-current-token-with-r…
Feb 11, 2020
6eae418
Merge pull request #4073 from gibkigonzo/bugfix/update-current-token-…
andrzejewsky Feb 11, 2020
e8ce3f5
Disable overriding route state in __INITIAL_STATE__
Feb 18, 2020
d2c1965
update changelog
Feb 18, 2020
0390ad6
Merge pull request #4095 from gibkigonzo/bugfix/disable-overriding-ro…
andrzejewsky Feb 19, 2020
1b03e6a
add server context to AsyncDataLoader
Feb 21, 2020
ca700f5
update changelog
Feb 21, 2020
e523b89
disable zoom image on hover in mobile
Feb 21, 2020
eeb11c4
update changelog
Feb 21, 2020
f4e4664
Merge pull request #4115 from gibkigonzo/bugfix/remove-image-hover-on…
andrzejewsky Feb 21, 2020
9d9a316
Merge branch 'hotfix/v1.10.6' into bugfix/add-server-context-toAsyncD…
andrzejewsky Feb 21, 2020
b3cb5ee
Merge pull request #4113 from gibkigonzo/bugfix/add-server-context-to…
andrzejewsky Feb 21, 2020
fd6912c
bump version
andrzejewsky Feb 21, 2020
d49c877
bump version
andrzejewsky Feb 21, 2020
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
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [1.10.6] - 21.02.2020

## Added
- Add lazy create cart token - @gibkigonzo (#3994)
- Add server context to async data loader - @gibkigonzo (pr#4113)

### Fixed
- Fix low-quality images styles - @przspa (#3906)
- Fix page-not-found redirect in dispatcher - @gibkigonzo (#3956)
- Fix hiding overlay for newsletter modal - @gibkigonzo (#3970)
- Fix problem with storeView as dependency in filters - @gibkigonzo (#3968)
- Fix v-model not working in BaseRadioButton - @lukeromanowicz (#4035)
- add disconnect and sync options for clear/cart - @gibkigonzo (#4062)
- Fix current token invalidation with refresh token - @gibkigonzo (#3928, #3620, #3626)
- Disable overriding `route`, `config`, `storeView`, `version` state in __INITIAL_STATE__ - @gibkigonzo (pr#4095)
- Disable zoom image on hover in mobile - @gibkigonzo (pr#4115)

## [1.10.5] - 28.11.2019

### Fixed
Expand Down
1 change: 0 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@
"width": 150,
"height": 150
},
"bypassCartLoaderForAuthorizedUsers": true,
"serverMergeByDefault": true,
"serverSyncCanRemoveLocalItems": false,
"serverSyncCanModifyLocalItems": false,
Expand Down
4 changes: 3 additions & 1 deletion core/client-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { AsyncDataLoader } from './lib/async-data-loader'
import { Logger } from '@vue-storefront/core/lib/logger'
import globalConfig from 'config'
import { RouterManager } from './lib/router-manager';
import omit from 'lodash-es/omit'
declare var window: any

const invokeClientEntry = async () => {
Expand All @@ -22,7 +23,8 @@ const invokeClientEntry = async () => {
const { app, router, store } = await createApp(null, dynamicRuntimeConfig, storeCode)

if (window.__INITIAL_STATE__) {
store.replaceState(Object.assign({}, store.state, window.__INITIAL_STATE__, { config: globalConfig }))
const initialState = omit(window.__INITIAL_STATE__, ['storeView', 'config', 'version', 'route'])
store.replaceState(Object.assign({}, store.state, initialState, { config: globalConfig }))
}

await store.dispatch('url/registerDynamicRoutes')
Expand Down
7 changes: 4 additions & 3 deletions core/filters/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ once('__VUE_EXTEND_DAYJS_LOCALIZED_FORMAT__', () => {
* @param {String} date
* @param {String} format
*/
export function date (date, format) {
const displayFormat = format || currentStoreView().i18n.dateFormat
let storeLocale = currentStoreView().i18n.defaultLocale.toLocaleLowerCase()
export function date (date, format, storeView) {
const _storeView = storeView || currentStoreView()
const displayFormat = format || _storeView.i18n.dateFormat
let storeLocale = _storeView.i18n.defaultLocale.toLocaleLowerCase()
const separatorIndex = storeLocale.indexOf('-')
const languageCode = separatorIndex ? storeLocale.substr(0, separatorIndex) : storeLocale

Expand Down
12 changes: 6 additions & 6 deletions core/filters/price.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ import { currentStoreView } from '@vue-storefront/core/lib/multistore'
* Converts number to price string
* @param {Number} value
*/
export function price (value) {
export function price (value, storeView) {
if (isNaN(value)) {
return value
}
let formattedVal = Math.abs(parseFloat(value)).toFixed(2)
const storeView = currentStoreView()
if (!storeView.i18n) {
const _storeView = storeView || currentStoreView();
if (!_storeView.i18n) {
return value;
}
const prependCurrency = (price) => {
return storeView.i18n.currencySign + price
return _storeView.i18n.currencySign + price
}

const appendCurrency = (price) => {
return price + storeView.i18n.currencySign
return price + _storeView.i18n.currencySign
}

if (storeView.i18n.currencySignPlacement === 'append') {
if (_storeView.i18n.currencySignPlacement === 'append') {
formattedVal = appendCurrency(formattedVal)
} else {
formattedVal = prependCurrency(formattedVal)
Expand Down
2 changes: 1 addition & 1 deletion core/i18n/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue-storefront/i18n",
"version": "1.10.5",
"version": "1.10.6",
"description": "Vue Storefront i18n",
"license": "MIT",
"main": "index.ts",
Expand Down
35 changes: 26 additions & 9 deletions core/lib/multistore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,32 @@ import VueRouter, { RouteConfig, RawLocation } from 'vue-router'
import config from 'config'
import { LocalizedRoute, StoreView } from './types'
import storeCodeFromRoute from './storeCodeFromRoute'
import cloneDeep from 'lodash-es/cloneDeep'
import get from 'lodash-es/get'
import { isServer } from '@vue-storefront/core/helpers'

/**
* Returns base storeView object that can be created without storeCode
*/
function buildBaseStoreView (): StoreView {
return cloneDeep({
tax: config.tax,
i18n: config.i18n,
elasticsearch: config.elasticsearch,
storeCode: null,
storeId: config.defaultStoreCode && config.defaultStoreCode !== '' ? config.storeViews[config.defaultStoreCode].storeId : 1,
seo: config.seo
})
}

export function currentStoreView (): StoreView {
// TODO: Change to getter all along our code
return rootStore.state.storeView
const serverStoreView = get(global, 'process.storeView', undefined)
const clientStoreView = get(rootStore, 'state.storeView', undefined)
return (isServer ? serverStoreView : clientStoreView) || buildBaseStoreView()
}

export async function prepareStoreView (storeCode: string): Promise<StoreView> {
let storeView = { // current, default store
tax: Object.assign({}, config.tax),
i18n: Object.assign({}, config.i18n),
elasticsearch: Object.assign({}, config.elasticsearch),
storeCode: '',
storeId: config.defaultStoreCode && config.defaultStoreCode !== '' ? config.storeViews[config.defaultStoreCode].storeId : 1
}
let storeView: StoreView = buildBaseStoreView() // current, default store
const storeViewHasChanged = !rootStore.state.storeView || rootStore.state.storeView.storeCode !== storeCode
if (storeCode) { // current store code
const currentStoreView = config.storeViews[storeCode]
Expand All @@ -38,6 +50,11 @@ export async function prepareStoreView (storeCode: string): Promise<StoreView> {
}
if (storeViewHasChanged) {
rootStore.state.storeView = storeView

if (global && isServer) {
(global.process as any).storeView = storeView
}

await loadLanguageAsync(storeView.i18n.defaultLocale)
}
if (storeViewHasChanged || Vue.prototype.$db.currentStoreCode !== storeCode) {
Expand Down
31 changes: 31 additions & 0 deletions core/lib/sync/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export const hasResponseError = (jsonResponse): boolean => {
if (typeof jsonResponse.result === 'string') {
return true
}

const hasMessage = jsonResponse.result.result || jsonResponse.result.message

return Boolean(hasMessage) && jsonResponse.result.code !== 'ENOTFOUND'
}

export const getResponseMessage = (jsonResponse): string => {
if (typeof jsonResponse.result === 'string') {
return jsonResponse.result
}

if (typeof jsonResponse.result.result === 'string') {
return jsonResponse.result.result
}

return jsonResponse.result.message
}

export const getResponseCode = (jsonResponse): number => {
let responseCode = null
if (jsonResponse.result && jsonResponse.result.code) {
responseCode = parseInt(jsonResponse.result.code)
} else {
responseCode = parseInt(jsonResponse.code)
}
return responseCode
}
16 changes: 7 additions & 9 deletions core/lib/sync/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Vue from 'vue'
import i18n from '@vue-storefront/i18n'
import isNaN from 'lodash-es/isNaN'
import isUndefined from 'lodash-es/isUndefined'
import toString from 'lodash-es/toString'
import fetch from 'isomorphic-fetch'
import * as localForage from 'localforage'
import rootStore from '@vue-storefront/core/store'
Expand All @@ -16,6 +15,7 @@ import { processURLAddress } from '@vue-storefront/core/helpers'
import { serial } from '@vue-storefront/core/helpers'
import config from 'config'
import { onlineHelper } from '@vue-storefront/core/helpers'
import { hasResponseError, getResponseMessage, getResponseCode } from '@vue-storefront/core/lib/sync/helpers'

const AUTO_REFRESH_MAX_ATTEMPTS = 20

Expand All @@ -33,7 +33,7 @@ function _sleep (time) {
}

function _internalExecute (resolve, reject, task: Task, currentToken, currentCartId) {
if (currentToken !== null && rootStore.state.userTokenInvalidateLock > 0) { // invalidate lock set
if (currentToken && rootStore.state.userTokenInvalidateLock > 0) { // invalidate lock set
Logger.log('Waiting for rootStore.state.userTokenInvalidateLock to release for ' + task.url, 'sync')()
_sleep(1000).then(() => {
Logger.log('Another try for rootStore.state.userTokenInvalidateLock for ' + task.url, 'sync')()
Expand All @@ -42,7 +42,7 @@ function _internalExecute (resolve, reject, task: Task, currentToken, currentCar
return // return but not resolve
} else if (rootStore.state.userTokenInvalidateLock < 0) {
Logger.error('Aborting the network task' + task.url + rootStore.state.userTokenInvalidateLock, 'sync')()
resolve({ code: 401, message: i18n.t('Error refreshing user token. User is not authorized to access the resource') })()
resolve({ code: 401, result: i18n.t('Error refreshing user token. User is not authorized to access the resource') })()
return
} else {
if (rootStore.state.userTokenInvalidated) {
Expand Down Expand Up @@ -73,9 +73,9 @@ function _internalExecute (resolve, reject, task: Task, currentToken, currentCar
}
}).then((jsonResponse) => {
if (jsonResponse) {
const responseCode = parseInt(jsonResponse.code)
const responseCode = getResponseCode(jsonResponse)
if (responseCode !== 200) {
if (responseCode === 401 /** unauthorized */ && currentToken !== null) { // the token is no longer valid, try to invalidate it
if (responseCode === 401 /** unauthorized */ && currentToken) { // the token is no longer valid, try to invalidate it
Logger.error('Invalid token - need to be revalidated' + currentToken + task.url + rootStore.state.userTokenInvalidateLock, 'sync')()
if (isNaN(rootStore.state.userTokenInvalidateAttemptsCount) || isUndefined(rootStore.state.userTokenInvalidateAttemptsCount)) rootStore.state.userTokenInvalidateAttemptsCount = 0
if (isNaN(rootStore.state.userTokenInvalidateLock) || isUndefined(rootStore.state.userTokenInvalidateLock)) rootStore.state.userTokenInvalidateLock = 0
Expand Down Expand Up @@ -128,12 +128,10 @@ function _internalExecute (resolve, reject, task: Task, currentToken, currentCar
}
}

if (!task.silent && jsonResponse.result && (typeof jsonResponse.result === 'string' || (((jsonResponse.result.result || jsonResponse.result.message) && jsonResponse.result.code !== 'ENOTFOUND') && !silentMode))) {
const message = typeof jsonResponse.result === 'string' ? jsonResponse.result : typeof jsonResponse.result.result === 'string' ? jsonResponse.result.result : jsonResponse.result.message

if (!task.silent && jsonResponse.result && hasResponseError(jsonResponse) && !silentMode) {
rootStore.dispatch('notification/spawnNotification', {
type: 'error',
message: i18n.t(message),
message: i18n.t(getResponseMessage(jsonResponse)),
action1: { label: i18n.t('OK') }
})
}
Expand Down
16 changes: 2 additions & 14 deletions core/mixins/multistore.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@ export const multistore = {
* @param {Int} height
*/
localizedRoute (routeObj) {
let storeView

if (isServer) {
storeView = this.$ssrContext.helpers.currentStoreView()
} else {
storeView = currentStoreView()
}
const storeView = currentStoreView()

return localizedRouteHelper(routeObj, storeView.storeCode)
},
Expand All @@ -27,13 +21,7 @@ export const multistore = {
* @param {Int} height
*/
localizedDispatcherRoute (routeObj) {
let storeView

if (isServer) {
storeView = this.$ssrContext.helpers.currentStoreView()
} else {
storeView = currentStoreView()
}
const storeView = currentStoreView()

return localizedDispatcherRouteHelper(routeObj, storeView.storeCode)
}
Expand Down
Loading