@shopgate/pwa-common 7.30.0-alpha.7 → 7.30.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App.js +48 -6
- package/action-creators/app/index.js +75 -12
- package/action-creators/app/spec.js +96 -1
- package/action-creators/client/index.js +27 -5
- package/action-creators/client/spec.js +44 -1
- package/action-creators/error/index.js +15 -3
- package/action-creators/index.js +9 -1
- package/action-creators/menu/index.js +23 -4
- package/action-creators/menu/spec.js +37 -1
- package/action-creators/modal/index.js +15 -3
- package/action-creators/modal/spec.js +26 -1
- package/action-creators/page/index.js +24 -4
- package/action-creators/page/spec.js +38 -1
- package/action-creators/router/index.js +48 -7
- package/action-creators/url/index.js +24 -4
- package/action-creators/url/spec.js +45 -1
- package/action-creators/user/index.js +90 -13
- package/action-creators/user/spec.js +186 -2
- package/actions/app/handleDeepLink.js +11 -2
- package/actions/app/handleLink.js +62 -6
- package/actions/app/handlePushNotification.js +32 -4
- package/actions/app/handleUniversalLink.js +11 -2
- package/actions/app/registerLinkEvents.js +24 -3
- package/actions/client/fetchClientInformation.js +26 -2
- package/actions/menu/fetchMenu.js +23 -2
- package/actions/modal/closeModal.js +18 -2
- package/actions/modal/promiseMap.js +3 -1
- package/actions/modal/showModal.js +54 -8
- package/actions/page/fetchPageConfig.js +69 -2
- package/actions/page/getPageConfig.js +6 -2
- package/actions/page/index.js +1 -1
- package/actions/router/historyPop.js +12 -2
- package/actions/router/historyPopToRoute.js +27 -2
- package/actions/router/historyPush.js +12 -2
- package/actions/router/historyRedirect.js +21 -2
- package/actions/router/historyReplace.js +20 -3
- package/actions/router/historyReset.js +11 -2
- package/actions/router/historyResetTo.js +12 -2
- package/actions/router/index.js +17 -1
- package/actions/router/routeDidPop.js +11 -2
- package/actions/router/routeDidPush.js +13 -2
- package/actions/router/routeDidReplace.js +11 -2
- package/actions/router/routeDidReset.js +11 -2
- package/actions/router/routeDidUpdate.js +10 -2
- package/actions/router/routeWillPop.js +11 -2
- package/actions/router/routeWillPush.js +13 -2
- package/actions/router/routeWillReplace.js +11 -2
- package/actions/router/routeWillReset.js +11 -2
- package/actions/router/windowOpenOverride.js +10 -2
- package/actions/user/fetchRegisterUrl.js +36 -2
- package/actions/user/fetchUser.js +29 -3
- package/actions/user/getUser.js +6 -2
- package/actions/user/index.js +1 -1
- package/actions/user/login.js +76 -9
- package/actions/user/logout.js +30 -2
- package/collections/AuthRoutes.js +73 -14
- package/collections/Configuration.js +54 -7
- package/collections/EmbeddedMedia.js +84 -11
- package/collections/PersistedReducers.js +41 -6
- package/collections/Redirects.js +103 -17
- package/collections/index.js +5 -1
- package/collections/media-providers/MediaProvider.js +151 -26
- package/collections/media-providers/Vimeo.js +113 -19
- package/collections/media-providers/YouTube.js +74 -14
- package/collections/media-providers/index.js +3 -1
- package/collections/media-providers/style.js +52 -2
- package/components/Backdrop/index.js +95 -6
- package/components/Backdrop/spec.js +23 -1
- package/components/Backdrop/style.js +11 -2
- package/components/Button/index.js +47 -5
- package/components/Button/spec.js +36 -1
- package/components/Button/style.js +6 -1
- package/components/Checkbox/index.js +126 -32
- package/components/Checkbox/spec.js +94 -3
- package/components/Consume/helpers/buildParams.js +13 -2
- package/components/Consume/index.js +14 -2
- package/components/CountdownTimer/index.js +115 -17
- package/components/CountdownTimer/spec.js +126 -12
- package/components/Drawer/index.js +131 -16
- package/components/Drawer/spec.js +76 -1
- package/components/Drawer/style.js +37 -1
- package/components/Dropdown/index.js +65 -6
- package/components/Dropdown/style.js +4 -1
- package/components/Dropdown/transitions.js +34 -1
- package/components/Ellipsis/index.js +16 -2
- package/components/Ellipsis/spec.js +13 -1
- package/components/EmbeddedMedia/index.js +56 -6
- package/components/EmbeddedMedia/spec.js +52 -3
- package/components/ErrorBoundary/connector.js +9 -2
- package/components/ErrorBoundary/index.js +43 -7
- package/components/Grid/components/Item/index.js +40 -4
- package/components/Grid/components/Item/spec.js +23 -1
- package/components/Grid/components/Item/style.js +17 -3
- package/components/Grid/index.js +36 -4
- package/components/Grid/spec.js +23 -1
- package/components/Grid/style.js +11 -2
- package/components/HtmlSanitizer/connector.js +24 -3
- package/components/HtmlSanitizer/index.js +104 -12
- package/components/HtmlSanitizer/spec.js +214 -7
- package/components/I18n/components/FormatDate/index.js +26 -2
- package/components/I18n/components/FormatDate/spec.js +46 -1
- package/components/I18n/components/FormatNumber/index.js +34 -2
- package/components/I18n/components/FormatNumber/spec.js +41 -2
- package/components/I18n/components/FormatPrice/index.js +32 -2
- package/components/I18n/components/FormatPrice/spec.js +46 -1
- package/components/I18n/components/FormatTime/index.js +26 -2
- package/components/I18n/components/FormatTime/spec.js +43 -2
- package/components/I18n/components/I18nProvider/index.js +52 -9
- package/components/I18n/components/I18nProvider/spec.js +39 -1
- package/components/I18n/components/Placeholder/index.js +8 -2
- package/components/I18n/components/Placeholder/spec.js +30 -1
- package/components/I18n/components/Translate/index.js +68 -7
- package/components/I18n/components/Translate/spec.js +30 -1
- package/components/I18n/index.js +16 -1
- package/components/Icon/index.js +25 -2
- package/components/Icon/style.js +6 -1
- package/components/Image/Image.js +176 -19
- package/components/Image/ImageInner.js +48 -2
- package/components/Image/index.js +1 -1
- package/components/Image/style.js +29 -2
- package/components/InfiniteContainer/index.js +381 -49
- package/components/InfiniteContainer/spec.js +199 -10
- package/components/Input/components/DateInput.js +262 -6
- package/components/Input/components/MultiLineInput.js +98 -12
- package/components/Input/components/SimpleInput.js +207 -31
- package/components/Input/index.js +32 -3
- package/components/Input/spec.js +122 -1
- package/components/KeyboardConsumer/index.js +48 -7
- package/components/Link/connector.js +7 -1
- package/components/Link/index.js +96 -11
- package/components/Link/spec.js +56 -1
- package/components/Link/style.js +10 -1
- package/components/List/components/Item/index.js +35 -3
- package/components/List/components/Item/style.js +16 -1
- package/components/List/index.js +20 -2
- package/components/List/spec.js +31 -1
- package/components/Loading/index.js +6 -2
- package/components/Modal/index.js +38 -3
- package/components/Modal/style.js +36 -1
- package/components/ModalContainer/connector.js +17 -3
- package/components/ModalContainer/index.js +36 -3
- package/components/ModalContainer/spec.js +105 -5
- package/components/Picker/components/Button/index.js +34 -2
- package/components/Picker/components/Button/style.js +19 -1
- package/components/Picker/components/List/index.js +33 -2
- package/components/Picker/components/List/style.js +17 -1
- package/components/Picker/components/Modal/index.js +60 -7
- package/components/Picker/components/Modal/style.js +78 -1
- package/components/Picker/index.js +167 -21
- package/components/Picker/spec.js +83 -2
- package/components/Portal/index.js +130 -19
- package/components/ProductCharacteristics/connector.js +33 -4
- package/components/ProductCharacteristics/context.js +2 -1
- package/components/ProductCharacteristics/helpers/index.js +135 -21
- package/components/ProductCharacteristics/index.js +266 -31
- package/components/RangeSlider/components/Handle/index.js +25 -2
- package/components/RangeSlider/components/Handle/style.js +14 -1
- package/components/RangeSlider/helper.js +43 -8
- package/components/RangeSlider/index.js +228 -38
- package/components/RangeSlider/style.js +14 -1
- package/components/Route/RouteNotFound.js +46 -3
- package/components/Route/index.js +78 -10
- package/components/Router/connector.js +9 -2
- package/components/Router/index.js +237 -31
- package/components/ScannerContainer/connector.js +9 -2
- package/components/ScannerContainer/index.js +42 -6
- package/components/Select/components/Item/index.js +20 -4
- package/components/Select/components/Item/style.js +4 -1
- package/components/Select/index.js +149 -28
- package/components/Select/spec.js +86 -2
- package/components/Select/style.js +17 -1
- package/components/SelectBox/components/Item/index.js +47 -5
- package/components/SelectBox/components/Item/style.js +7 -1
- package/components/SelectBox/index.js +173 -17
- package/components/SelectBox/spec.js +59 -3
- package/components/SelectBox/style.js +18 -1
- package/components/Slider/index.js +6 -2
- package/components/SurroundPortals/index.js +26 -2
- package/components/Swiper/components/SwiperItem/index.js +28 -4
- package/components/Swiper/components/SwiperItem/spec.js +21 -1
- package/components/Swiper/components/SwiperItem/styles.js +5 -1
- package/components/Swiper/index.js +210 -18
- package/components/Swiper/styles.js +75 -7
- package/components/Toaster/index.js +10 -2
- package/components/Transition/index.js +89 -13
- package/components/Widgets/components/Widget/index.js +52 -4
- package/components/Widgets/components/Widget/spec.js +68 -3
- package/components/Widgets/components/Widget/style.js +21 -3
- package/components/Widgets/components/WidgetGrid/index.js +52 -7
- package/components/Widgets/components/WidgetGrid/spec.js +46 -2
- package/components/Widgets/components/WidgetGrid/style.js +8 -1
- package/components/Widgets/helpers/shouldShowWidget.js +44 -7
- package/components/Widgets/index.js +127 -15
- package/components/Widgets/spec.js +228 -6
- package/components/index.js +9 -1
- package/constants/ActionTypes.js +97 -19
- package/constants/Configuration.js +12 -2
- package/constants/Device.js +29 -2
- package/constants/DisplayOptions.js +8 -1
- package/constants/MenuIDs.js +2 -1
- package/constants/ModalTypes.js +1 -1
- package/constants/PageIDs.js +1 -1
- package/constants/Pipelines.js +7 -1
- package/constants/Portals.js +136 -3
- package/constants/Registration.js +3 -1
- package/constants/RoutePaths.js +13 -2
- package/constants/Tracking.js +3 -1
- package/constants/client.js +6 -1
- package/constants/ui.js +2 -1
- package/constants/user.js +6 -2
- package/context/index.js +33 -3
- package/helpers/config/index.js +139 -21
- package/helpers/config/mock.js +200 -8
- package/helpers/config/theme.js +50 -4
- package/helpers/data/index.js +204 -29
- package/helpers/data/spec.js +187 -7
- package/helpers/date/index.js +58 -6
- package/helpers/date/spec.js +92 -1
- package/helpers/dom/index.js +48 -11
- package/helpers/environment/index.js +14 -2
- package/helpers/html/decodeHTML.js +7 -1
- package/helpers/html/handleDOM.js +172 -21
- package/helpers/html/parseHTML.js +67 -12
- package/helpers/i18n/getDateFormatter.js +23 -4
- package/helpers/i18n/getNumberFormatter.js +32 -4
- package/helpers/i18n/getPriceFormatter.js +38 -4
- package/helpers/i18n/getTimeFormatter.js +23 -4
- package/helpers/i18n/getTranslator.js +62 -8
- package/helpers/i18n/index.js +5 -1
- package/helpers/i18n/mergeTranslations.js +36 -9
- package/helpers/i18n/messageCache.js +3 -1
- package/helpers/legacy/index.js +47 -9
- package/helpers/modal/withShowModal.js +13 -2
- package/helpers/portals/portalCollection.js +28 -6
- package/helpers/portals/routePortals.js +12 -1
- package/helpers/redux/compareObjects.js +7 -2
- package/helpers/redux/generateResultHash.js +36 -3
- package/helpers/redux/generateSortedHash.js +7 -2
- package/helpers/redux/hasExpired.js +10 -2
- package/helpers/redux/index.js +7 -1
- package/helpers/redux/mutable.js +143 -24
- package/helpers/redux/shouldFetchData.js +46 -10
- package/helpers/redux/shouldFetchFilters.js +17 -4
- package/helpers/router/index.js +49 -5
- package/helpers/style/index.js +43 -4
- package/helpers/style/spec.js +108 -2
- package/helpers/tracking/index.js +52 -9
- package/helpers/validation/index.js +39 -12
- package/helpers/validation/spec.js +10 -1
- package/package.json +3 -4
- package/providers/index.js +4 -1
- package/providers/loading/context.js +2 -1
- package/providers/loading/index.js +137 -22
- package/providers/toast/context.js +2 -1
- package/providers/toast/index.js +105 -11
- package/reducers/client/connectivity.js +22 -2
- package/reducers/client/index.js +7 -1
- package/reducers/client/info.js +27 -2
- package/reducers/index.js +23 -4
- package/reducers/menu/index.js +5 -1
- package/reducers/menu/menusById.js +41 -2
- package/reducers/modal/index.js +14 -2
- package/reducers/page/index.js +68 -5
- package/reducers/router/index.js +48 -2
- package/reducers/url/index.js +42 -3
- package/reducers/user/data.js +27 -2
- package/reducers/user/index.js +7 -1
- package/reducers/user/login.js +65 -2
- package/selectors/client.js +138 -21
- package/selectors/history.js +49 -11
- package/selectors/menu.js +34 -6
- package/selectors/modal.js +15 -4
- package/selectors/page.js +25 -4
- package/selectors/router.js +154 -30
- package/selectors/url.js +25 -4
- package/selectors/user.js +90 -13
- package/store/index.js +60 -6
- package/store/middelwares/logger.js +7 -1
- package/store/middelwares/streams.js +19 -2
- package/streams/app.js +60 -8
- package/streams/client.js +8 -2
- package/streams/error.js +14 -3
- package/streams/index.js +6 -1
- package/streams/interval.js +6 -2
- package/streams/main.js +27 -2
- package/streams/router.js +45 -8
- package/streams/user.js +89 -15
- package/streams/view.js +97 -25
- package/styles/reset/form.js +57 -5
- package/styles/reset/index.js +6 -1
- package/styles/reset/media.js +22 -1
- package/styles/reset/root.js +33 -1
- package/styles/reset/table.js +10 -1
- package/styles/reset/typography.js +26 -1
- package/subscriptions/app.js +148 -17
- package/subscriptions/error.js +292 -13
- package/subscriptions/helpers/buildRegisterUrl.js +25 -6
- package/subscriptions/helpers/clearUpInAppBrowser.js +14 -3
- package/subscriptions/helpers/handleLinks.js +267 -25
- package/subscriptions/helpers/pipeline.js +12 -1
- package/subscriptions/history.js +34 -6
- package/subscriptions/index.js +25 -4
- package/subscriptions/menu.js +22 -5
- package/subscriptions/mock.js +39 -7
- package/subscriptions/router.js +336 -23
- package/subscriptions/user.js +93 -3
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import{openUniversalLink}from"../../action-creators/app";
|
|
1
|
+
import { openUniversalLink } from "../../action-creators/app";
|
|
2
|
+
import handleLink from "./handleLink";
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* Opens an universal link.
|
|
3
6
|
* @param {Object} [payload={}] The universal link event payload.
|
|
4
7
|
* @return {Function} A redux thunk.
|
|
5
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
export default function handleUniversalLink(payload) {
|
|
10
|
+
return dispatch => {
|
|
11
|
+
dispatch(openUniversalLink(payload));
|
|
12
|
+
dispatch(handleLink(payload));
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -1,5 +1,26 @@
|
|
|
1
|
-
import{event,registerEvents}from'@shopgate/pwa-core';
|
|
1
|
+
import { event, registerEvents } from '@shopgate/pwa-core';
|
|
2
|
+
import { willRegisterLinkEvents, didRegisterLinkEvents } from "../../action-creators/app";
|
|
3
|
+
import handlePushNotification from "./handlePushNotification";
|
|
4
|
+
import handleDeepLink from "./handleDeepLink";
|
|
5
|
+
import handleUniversalLink from "./handleUniversalLink";
|
|
6
|
+
|
|
7
|
+
/**
|
|
2
8
|
* Registers all link events.
|
|
3
9
|
* @return {Function} A redux thunk.
|
|
4
|
-
*/
|
|
5
|
-
|
|
10
|
+
*/
|
|
11
|
+
export default function registerLinkEvents() {
|
|
12
|
+
return dispatch => {
|
|
13
|
+
dispatch(willRegisterLinkEvents());
|
|
14
|
+
registerEvents(['openPushNotification', 'openDeepLink', 'openUniversalLink']);
|
|
15
|
+
event.addCallback('openPushNotification', payload => dispatch(handlePushNotification(payload)));
|
|
16
|
+
event.addCallback('openDeepLink', payload => {
|
|
17
|
+
// Payment links are handled using the new app event system.
|
|
18
|
+
if (payload?.link.indexOf('//payment') !== -1) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
dispatch(handleDeepLink(payload));
|
|
22
|
+
});
|
|
23
|
+
event.addCallback('openUniversalLink', payload => dispatch(handleUniversalLink(payload)));
|
|
24
|
+
dispatch(didRegisterLinkEvents());
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -1,4 +1,28 @@
|
|
|
1
|
-
import{mutable}from'@shopgate/engage/core/helpers';
|
|
1
|
+
import { mutable } from '@shopgate/engage/core/helpers';
|
|
2
|
+
import { hasSGJavaScriptBridge, defaultClientInformation, getWebStorageEntry } from '@shopgate/pwa-core';
|
|
3
|
+
import { requestClientInformation, receiveClientInformation, errorClientInformation } from "../../action-creators/client";
|
|
4
|
+
|
|
5
|
+
/**
|
|
2
6
|
* Requests the client information from the web storage.
|
|
3
7
|
* @return {Function} A redux thunk.
|
|
4
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
function fetchClientInformation() {
|
|
10
|
+
return dispatch => {
|
|
11
|
+
dispatch(requestClientInformation());
|
|
12
|
+
if (!hasSGJavaScriptBridge()) {
|
|
13
|
+
dispatch(receiveClientInformation(defaultClientInformation));
|
|
14
|
+
return Promise.resolve({
|
|
15
|
+
aga: 0,
|
|
16
|
+
value: defaultClientInformation
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
const request = getWebStorageEntry({
|
|
20
|
+
name: 'clientInformation'
|
|
21
|
+
});
|
|
22
|
+
request.then(response => dispatch(receiveClientInformation(response.value))).catch(() => {
|
|
23
|
+
dispatch(errorClientInformation());
|
|
24
|
+
});
|
|
25
|
+
return request;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export default mutable(fetchClientInformation);
|
|
@@ -1,5 +1,26 @@
|
|
|
1
|
-
import{PipelineRequest}from'@shopgate/pwa-core';
|
|
1
|
+
import { PipelineRequest } from '@shopgate/pwa-core';
|
|
2
|
+
import { SHOPGATE_CMS_GET_MENU } from "../../constants/Pipelines";
|
|
3
|
+
import { requestMenu, receiveMenu, errorMenu } from "../../action-creators/menu";
|
|
4
|
+
|
|
5
|
+
/**
|
|
2
6
|
* Get the custom service menu entries.
|
|
3
7
|
* @param {string} id The menu id.
|
|
4
8
|
* @return {Function} A redux thunk.
|
|
5
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
function fetchMenu(id) {
|
|
11
|
+
return dispatch => {
|
|
12
|
+
dispatch(requestMenu(id));
|
|
13
|
+
const request = new PipelineRequest(SHOPGATE_CMS_GET_MENU).setInput({
|
|
14
|
+
id
|
|
15
|
+
}).dispatch();
|
|
16
|
+
request.then(({
|
|
17
|
+
entries
|
|
18
|
+
}) => {
|
|
19
|
+
dispatch(receiveMenu(id, entries));
|
|
20
|
+
}).catch(() => {
|
|
21
|
+
dispatch(errorMenu(id));
|
|
22
|
+
});
|
|
23
|
+
return request;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export default fetchMenu;
|
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
import{mutable}from"../../helpers/redux";
|
|
1
|
+
import { mutable } from "../../helpers/redux";
|
|
2
|
+
import { removeModal } from "../../action-creators/modal";
|
|
3
|
+
import promiseMap from "./promiseMap";
|
|
4
|
+
|
|
5
|
+
/**
|
|
2
6
|
* Closes an open modal and resolves the mapped promise.
|
|
3
7
|
* @param {number} id A modal id.
|
|
4
8
|
* @param {boolean} confirmed A flag whether the modal was confirmed or not.
|
|
5
9
|
* @returns {Function} A redux thunk.
|
|
6
|
-
*/
|
|
10
|
+
*/
|
|
11
|
+
function closeModal(id, confirmed = false) {
|
|
12
|
+
return dispatch => {
|
|
13
|
+
const promise = promiseMap.get(id);
|
|
14
|
+
if (promise) {
|
|
15
|
+
promise.resolve(confirmed);
|
|
16
|
+
}
|
|
17
|
+
dispatch(removeModal(id));
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** @mixes {MutableFunction} */
|
|
22
|
+
export default mutable(closeModal);
|
|
@@ -1,21 +1,67 @@
|
|
|
1
|
-
|
|
1
|
+
import CryptoJs from 'crypto-js';
|
|
2
|
+
import { logger } from '@shopgate/pwa-core';
|
|
3
|
+
import { createModal } from "../../action-creators/modal";
|
|
4
|
+
import { mutable } from "../../helpers/redux";
|
|
5
|
+
import { getModalById } from "../../selectors/modal";
|
|
6
|
+
import promiseMap from "./promiseMap";
|
|
7
|
+
|
|
8
|
+
/**
|
|
2
9
|
* Creates a runtime unique modal id.
|
|
3
10
|
* @param {Object} options The modal options.
|
|
4
11
|
* @returns {number}
|
|
5
|
-
*/
|
|
12
|
+
*/
|
|
13
|
+
export const getModalId = options => CryptoJs.MD5(JSON.stringify(options)).toString();
|
|
14
|
+
|
|
15
|
+
/**
|
|
6
16
|
* The modal defaults.
|
|
7
17
|
* @type {Object}
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
|
|
18
|
+
*/
|
|
19
|
+
const defaultModalOptions = {
|
|
20
|
+
id: null,
|
|
21
|
+
type: null,
|
|
22
|
+
// In this case the template should display a fallback dialog type.
|
|
23
|
+
title: '',
|
|
24
|
+
confirm: 'modal.confirm',
|
|
25
|
+
dismiss: 'modal.dismiss',
|
|
26
|
+
params: {} // Any parameters for special modal types go here.
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
11
30
|
* Dispatches the createModal action creator and returns
|
|
12
31
|
* a promise that will be resolved when the modal closes.
|
|
13
32
|
* @param {Object} options The modal options.
|
|
14
33
|
* @return {Function} A Redux thunk.
|
|
15
|
-
*/
|
|
16
|
-
|
|
34
|
+
*/
|
|
35
|
+
function showModal(options) {
|
|
36
|
+
return (dispatch, getState) => {
|
|
37
|
+
const id = getModalId(options);
|
|
38
|
+
|
|
39
|
+
// Check if there is already a modal with the same id on the modal stack.
|
|
40
|
+
const modal = getModalById(getState(), id);
|
|
41
|
+
if (modal) {
|
|
42
|
+
/**
|
|
17
43
|
* To prevent bugging the user with duplicate modal, those are not added to the modal stack.
|
|
18
44
|
* Usually the promise which is returned by showModal resolves with a boolean value
|
|
19
45
|
* when the user interacts with its buttons. Since promise handling is optional for the
|
|
20
46
|
* action, the promise can't be rejected, but resolves with null.
|
|
21
|
-
*/
|
|
47
|
+
*/
|
|
48
|
+
logger.warn('Modal creation aborted since an identical one was already added to the modal stack', options);
|
|
49
|
+
return Promise.resolve(null);
|
|
50
|
+
}
|
|
51
|
+
const enrichedOptions = {
|
|
52
|
+
...defaultModalOptions,
|
|
53
|
+
...options,
|
|
54
|
+
id
|
|
55
|
+
};
|
|
56
|
+
dispatch(createModal(enrichedOptions));
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
promiseMap.set(id, {
|
|
59
|
+
resolve,
|
|
60
|
+
reject
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** @mixes {MutableFunction} */
|
|
67
|
+
export default mutable(showModal);
|
|
@@ -1,5 +1,72 @@
|
|
|
1
|
-
|
|
1
|
+
import { PipelineRequest } from '@shopgate/pwa-core';
|
|
2
|
+
import { getDeviceTypeForCms } from '@shopgate/engage/core';
|
|
3
|
+
import { makeGetPage, getIsCms2Enabled } from '@shopgate/engage/page/selectors';
|
|
4
|
+
import { requestPageConfigV2, receivePageConfigV2, errorPageConfigV2 } from '@shopgate/engage/page/action-creators';
|
|
5
|
+
import { hasNewServices } from '@shopgate/engage/core/helpers';
|
|
6
|
+
import { ERROR_HANDLE_SUPPRESS, ERROR_HANDLE_DEFAULT } from '@shopgate/engage/core/constants';
|
|
7
|
+
import { SHOPGATE_CMS_GET_PAGE_CONFIG } from "../../constants/Pipelines";
|
|
8
|
+
import { requestPageConfig, receivePageConfig, errorPageConfig } from "../../action-creators/page";
|
|
9
|
+
import { shouldFetchData, mutable } from "../../helpers/redux";
|
|
10
|
+
import { getPageConfigById } from "../../selectors/page";
|
|
11
|
+
|
|
12
|
+
/**
|
|
2
13
|
* Retrieves the config for a page.
|
|
3
14
|
* @param {string} pageId The ID of the page to request.
|
|
4
15
|
* @return {Function} The dispatched action.
|
|
5
|
-
*/
|
|
16
|
+
*/
|
|
17
|
+
function fetchPageConfig(pageId) {
|
|
18
|
+
return (dispatch, getState) => {
|
|
19
|
+
const state = getState();
|
|
20
|
+
const cmsV2Enabled = getIsCms2Enabled(state);
|
|
21
|
+
let pageConfig;
|
|
22
|
+
if (cmsV2Enabled) {
|
|
23
|
+
pageConfig = makeGetPage({
|
|
24
|
+
slug: pageId
|
|
25
|
+
})(state);
|
|
26
|
+
} else {
|
|
27
|
+
pageConfig = getPageConfigById(state, {
|
|
28
|
+
pageId
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (!shouldFetchData(pageConfig)) {
|
|
32
|
+
return Promise.resolve(null);
|
|
33
|
+
}
|
|
34
|
+
const deviceTypeOfCmsPage = getDeviceTypeForCms();
|
|
35
|
+
if (cmsV2Enabled) {
|
|
36
|
+
dispatch(requestPageConfigV2({
|
|
37
|
+
slug: pageId
|
|
38
|
+
}));
|
|
39
|
+
} else {
|
|
40
|
+
dispatch(requestPageConfig(pageId));
|
|
41
|
+
}
|
|
42
|
+
const request = new PipelineRequest(SHOPGATE_CMS_GET_PAGE_CONFIG).setVersion(cmsV2Enabled ? 2 : 1).setHandleErrors(cmsV2Enabled ? ERROR_HANDLE_SUPPRESS : ERROR_HANDLE_DEFAULT).setInput({
|
|
43
|
+
pageId,
|
|
44
|
+
...(hasNewServices() && !cmsV2Enabled ? {
|
|
45
|
+
deviceType: deviceTypeOfCmsPage
|
|
46
|
+
} : null)
|
|
47
|
+
}).dispatch();
|
|
48
|
+
request.then(result => {
|
|
49
|
+
if (cmsV2Enabled) {
|
|
50
|
+
dispatch(receivePageConfigV2({
|
|
51
|
+
slug: pageId,
|
|
52
|
+
data: result.page
|
|
53
|
+
}));
|
|
54
|
+
} else {
|
|
55
|
+
dispatch(receivePageConfig(pageId, result));
|
|
56
|
+
}
|
|
57
|
+
}).catch(error => {
|
|
58
|
+
if (cmsV2Enabled) {
|
|
59
|
+
dispatch(errorPageConfigV2({
|
|
60
|
+
slug: pageId,
|
|
61
|
+
code: error.code
|
|
62
|
+
}));
|
|
63
|
+
} else {
|
|
64
|
+
dispatch(errorPageConfig(pageId, error.code));
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return request;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** @mixes {MutableFunction} */
|
|
72
|
+
export default mutable(fetchPageConfig);
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import fetchPageConfig from"./fetchPageConfig"
|
|
1
|
+
import fetchPageConfig from "./fetchPageConfig";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Retrieves the config for a page.
|
|
3
5
|
* @param {string} pageId The ID of the page to request.
|
|
4
6
|
* @param {boolean} [force=true] When true, the request will go out without being checked.
|
|
5
7
|
* @return {Function} The dispatched action.
|
|
6
8
|
* @deprecated
|
|
7
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
const getPageConfig = fetchPageConfig;
|
|
11
|
+
export default getPageConfig;
|
package/actions/page/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{default as fetchPageConfig}from"./fetchPageConfig";
|
|
1
|
+
export { default as fetchPageConfig } from "./fetchPageConfig";
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import { ACTION_POP } from '@virtuous/conductor';
|
|
2
|
+
import { navigate } from "../../action-creators/router";
|
|
3
|
+
import { mutable } from "../../helpers/redux";
|
|
4
|
+
|
|
5
|
+
/**
|
|
2
6
|
* @mixes {MutableFunction}
|
|
3
7
|
* @param {Object} [params={}] The history params.
|
|
4
8
|
* @return {Function} The dispatched action.
|
|
5
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
export const historyPop = mutable((params = {}) => dispatch => {
|
|
11
|
+
dispatch(navigate({
|
|
12
|
+
...params,
|
|
13
|
+
action: ACTION_POP
|
|
14
|
+
}));
|
|
15
|
+
});
|
|
@@ -1,5 +1,30 @@
|
|
|
1
|
-
import{historyPop}from"./historyPop";
|
|
1
|
+
import { historyPop } from "./historyPop";
|
|
2
|
+
import { mutable } from "../../helpers/redux";
|
|
3
|
+
import { getRouterStackIndex, makeGetPrevRouteIndexByPattern } from "../../selectors/router";
|
|
4
|
+
|
|
5
|
+
/**
|
|
2
6
|
* @mixes {MutableFunction}
|
|
3
7
|
* @param {Object} [params={}] The history params.
|
|
4
8
|
* @return {Function} The dispatched action.
|
|
5
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
export const historyPopToRoute = mutable(({
|
|
11
|
+
pattern,
|
|
12
|
+
routeId
|
|
13
|
+
}) => (dispatch, getState) => {
|
|
14
|
+
const state = getState();
|
|
15
|
+
const getPrevRouteIndexByPatternCart = makeGetPrevRouteIndexByPattern(pattern);
|
|
16
|
+
const nextRouteIndex = getPrevRouteIndexByPatternCart(state, {
|
|
17
|
+
routeId
|
|
18
|
+
});
|
|
19
|
+
const currentRouteIndex = getRouterStackIndex(state, {
|
|
20
|
+
routeId
|
|
21
|
+
});
|
|
22
|
+
if (currentRouteIndex === null || nextRouteIndex === null || nextRouteIndex === -1) {
|
|
23
|
+
dispatch(historyPop());
|
|
24
|
+
} else {
|
|
25
|
+
const steps = currentRouteIndex - nextRouteIndex;
|
|
26
|
+
dispatch(historyPop({
|
|
27
|
+
steps
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
});
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import { ACTION_PUSH } from '@virtuous/conductor';
|
|
2
|
+
import { navigate } from "../../action-creators/router";
|
|
3
|
+
import { mutable } from "../../helpers/redux";
|
|
4
|
+
|
|
5
|
+
/**
|
|
2
6
|
* @mixes {MutableFunction}
|
|
3
7
|
* @param {Object} params The history params.
|
|
4
8
|
* @return {Function} The dispatched action.
|
|
5
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
export const historyPush = mutable(params => dispatch => {
|
|
11
|
+
dispatch(navigate({
|
|
12
|
+
...params,
|
|
13
|
+
action: ACTION_PUSH
|
|
14
|
+
}));
|
|
15
|
+
});
|
|
@@ -1,6 +1,25 @@
|
|
|
1
|
-
import{historyPop}from"./historyPop";
|
|
1
|
+
import { historyPop } from "./historyPop";
|
|
2
|
+
import { historyReplace } from "./historyReplace";
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* Performs a redirect. When the action params contain a location, the current history entry
|
|
3
6
|
* will be replaced with it. Otherwise the current history entry will be popped.
|
|
4
7
|
* @param {Object} params The redirect params.
|
|
5
8
|
* @return {Function} A redux thunk.
|
|
6
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
export function historyRedirect(params = {}) {
|
|
11
|
+
return dispatch => {
|
|
12
|
+
const {
|
|
13
|
+
location,
|
|
14
|
+
state
|
|
15
|
+
} = params;
|
|
16
|
+
if (!location) {
|
|
17
|
+
dispatch(historyPop());
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
dispatch(historyReplace({
|
|
21
|
+
pathname: location,
|
|
22
|
+
state
|
|
23
|
+
}));
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -1,15 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
import { ACTION_REPLACE } from '@virtuous/conductor';
|
|
2
|
+
import { navigate } from "../../action-creators/router";
|
|
3
|
+
import { mutable } from "../../helpers/redux";
|
|
4
|
+
|
|
5
|
+
/**
|
|
2
6
|
* @mixes {MutableFunction}
|
|
3
7
|
* @param {Object} params The history params.
|
|
4
8
|
* @param {Object} [options={}] Additional options for the action
|
|
5
9
|
* @param {boolean} [options.remountRoute=true] When set to "true", the target route will be forced
|
|
6
10
|
* to remount.
|
|
7
11
|
* @return {Function} The dispatched action.
|
|
8
|
-
*/
|
|
12
|
+
*/
|
|
13
|
+
export const historyReplace = mutable((params, options = {}) => dispatch => {
|
|
14
|
+
dispatch(navigate({
|
|
15
|
+
...params,
|
|
16
|
+
...(options?.remountRoute !== false && {
|
|
17
|
+
state: {
|
|
18
|
+
...params.state,
|
|
19
|
+
/**
|
|
9
20
|
* When a route is "replaced" the router doesn't assign a new route id to the old route
|
|
10
21
|
* stack entry. This can cause issues when a route is replaced by itself, since the content
|
|
11
22
|
* will not remount out of the box.
|
|
12
23
|
*
|
|
13
24
|
* When the "replaceRouteId" state prop is injected, the Route component performs logic
|
|
14
25
|
* to enforce re-remounting routes which where replaced by itself.
|
|
15
|
-
*/
|
|
26
|
+
*/
|
|
27
|
+
replaceRouteId: Math.random().toString(36).substring(2, 7)
|
|
28
|
+
}
|
|
29
|
+
}),
|
|
30
|
+
action: ACTION_REPLACE
|
|
31
|
+
}));
|
|
32
|
+
});
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import{ACTION_RESET}from'@virtuous/conductor';
|
|
1
|
+
import { ACTION_RESET } from '@virtuous/conductor';
|
|
2
|
+
import { navigate } from "../../action-creators/router";
|
|
3
|
+
import { mutable } from "../../helpers/redux";
|
|
4
|
+
|
|
5
|
+
/**
|
|
2
6
|
* @mixes {MutableFunction}
|
|
3
7
|
* @return {Function} The dispatched action.
|
|
4
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
export const historyReset = mutable(() => dispatch => {
|
|
10
|
+
dispatch(navigate({
|
|
11
|
+
action: ACTION_RESET
|
|
12
|
+
}));
|
|
13
|
+
});
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
import{HISTORY_RESET_TO}from"../../constants/ActionTypes";
|
|
1
|
+
import { HISTORY_RESET_TO } from "../../constants/ActionTypes";
|
|
2
|
+
import { navigate } from "../../action-creators/router";
|
|
3
|
+
import { mutable } from "../../helpers/redux";
|
|
4
|
+
|
|
5
|
+
/**
|
|
2
6
|
* @mixes {MutableFunction}
|
|
3
7
|
* @param {Object} pathname The pathname to reset to
|
|
4
8
|
* @return {Function} The dispatched action.
|
|
5
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
export const historyResetTo = mutable(pathname => dispatch => {
|
|
11
|
+
dispatch(navigate({
|
|
12
|
+
pathname,
|
|
13
|
+
action: HISTORY_RESET_TO
|
|
14
|
+
}));
|
|
15
|
+
});
|
package/actions/router/index.js
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
export*from"./historyPush";
|
|
1
|
+
export * from "./historyPush";
|
|
2
|
+
export * from "./historyPop";
|
|
3
|
+
export * from "./historyPopToRoute";
|
|
4
|
+
export * from "./historyReplace";
|
|
5
|
+
export * from "./historyReset";
|
|
6
|
+
export * from "./historyResetTo";
|
|
7
|
+
export * from "./historyRedirect";
|
|
8
|
+
export * from "./routeDidPop";
|
|
9
|
+
export * from "./routeDidPush";
|
|
10
|
+
export * from "./routeDidReplace";
|
|
11
|
+
export * from "./routeDidReset";
|
|
12
|
+
export * from "./routeDidUpdate";
|
|
13
|
+
export * from "./routeWillPop";
|
|
14
|
+
export * from "./routeWillPush";
|
|
15
|
+
export * from "./routeWillReplace";
|
|
16
|
+
export * from "./routeWillReset";
|
|
17
|
+
export * from "./windowOpenOverride";
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import{ACTION_POP}from'@virtuous/conductor';
|
|
1
|
+
import { ACTION_POP } from '@virtuous/conductor';
|
|
2
|
+
import * as actions from "../../action-creators/router";
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* @param {Route} prev The previous route.
|
|
3
6
|
* @param {Route} next The next route.
|
|
4
7
|
* @returns {Function}
|
|
5
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
export function routeDidPop(prev, next) {
|
|
10
|
+
return dispatch => {
|
|
11
|
+
dispatch(actions.routeDidLeave(prev, ACTION_POP));
|
|
12
|
+
dispatch(actions.routeDidEnter(next, ACTION_POP));
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import{ACTION_PUSH}from'@virtuous/conductor';
|
|
1
|
+
import { ACTION_PUSH } from '@virtuous/conductor';
|
|
2
|
+
import * as actions from "../../action-creators/router";
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* @param {Route} prev The previous route.
|
|
3
6
|
* @param {Route} next The next route.
|
|
4
7
|
* @returns {Function}
|
|
5
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
export function routeDidPush(prev, next) {
|
|
10
|
+
return dispatch => {
|
|
11
|
+
if (prev) {
|
|
12
|
+
dispatch(actions.routeDidLeave(prev, ACTION_PUSH));
|
|
13
|
+
}
|
|
14
|
+
dispatch(actions.routeDidEnter(next, ACTION_PUSH));
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import{ACTION_REPLACE}from'@virtuous/conductor';
|
|
1
|
+
import { ACTION_REPLACE } from '@virtuous/conductor';
|
|
2
|
+
import * as actions from "../../action-creators/router";
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* @param {Route} prev The previous route.
|
|
3
6
|
* @param {Route} next The next route.
|
|
4
7
|
* @returns {Function}
|
|
5
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
export function routeDidReplace(prev, next) {
|
|
10
|
+
return dispatch => {
|
|
11
|
+
dispatch(actions.routeDidLeave(prev, ACTION_REPLACE));
|
|
12
|
+
dispatch(actions.routeDidEnter(next, ACTION_REPLACE));
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import{ACTION_RESET}from'@virtuous/conductor';
|
|
1
|
+
import { ACTION_RESET } from '@virtuous/conductor';
|
|
2
|
+
import * as actions from "../../action-creators/router";
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* @param {Route} prev The previous route.
|
|
3
6
|
* @param {Route} next The next route.
|
|
4
7
|
* @returns {Function}
|
|
5
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
export function routeDidReset(prev, next) {
|
|
10
|
+
return dispatch => {
|
|
11
|
+
dispatch(actions.routeDidLeave(prev, ACTION_RESET));
|
|
12
|
+
dispatch(actions.routeDidEnter(next, ACTION_RESET));
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import{ACTION_UPDATE}from'@virtuous/conductor';
|
|
1
|
+
import { ACTION_UPDATE } from '@virtuous/conductor';
|
|
2
|
+
import * as actions from "../../action-creators/router";
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* @param {Route} route The updated route.
|
|
3
6
|
* @returns {Function}
|
|
4
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
export function routeDidUpdate(route) {
|
|
9
|
+
return dispatch => {
|
|
10
|
+
dispatch(actions.routeDidUpdate(route, ACTION_UPDATE));
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import{ACTION_POP}from'@virtuous/conductor';
|
|
1
|
+
import { ACTION_POP } from '@virtuous/conductor';
|
|
2
|
+
import * as actions from "../../action-creators/router";
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* @param {Route} prev The previous route.
|
|
3
6
|
* @param {Route} next The next route.
|
|
4
7
|
* @returns {Function}
|
|
5
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
export function routeWillPop(prev, next) {
|
|
10
|
+
return dispatch => {
|
|
11
|
+
dispatch(actions.routeWillLeave(prev, ACTION_POP));
|
|
12
|
+
dispatch(actions.routeWillEnter(next, ACTION_POP));
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import{ACTION_PUSH}from'@virtuous/conductor';
|
|
1
|
+
import { ACTION_PUSH } from '@virtuous/conductor';
|
|
2
|
+
import * as actions from "../../action-creators/router";
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* @param {Route} prev The previous route.
|
|
3
6
|
* @param {Route} next The next route.
|
|
4
7
|
* @returns {Function}
|
|
5
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
export function routeWillPush(prev, next) {
|
|
10
|
+
return dispatch => {
|
|
11
|
+
if (prev) {
|
|
12
|
+
dispatch(actions.routeWillLeave(prev, ACTION_PUSH));
|
|
13
|
+
}
|
|
14
|
+
dispatch(actions.routeWillEnter(next, ACTION_PUSH));
|
|
15
|
+
};
|
|
16
|
+
}
|