@shopgate/pwa-common 7.30.0-alpha.7 → 7.30.0-alpha.8
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 +207 -6
- 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 +17 -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 +213 -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 -3
- 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
package/App.js
CHANGED
|
@@ -1,14 +1,56 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Provider } from 'react-redux';
|
|
4
|
+
import { CookiesProvider } from 'react-cookie';
|
|
5
|
+
import { loadCustomStyles } from '@shopgate/engage/styles';
|
|
6
|
+
import ErrorBoundary from "./components/ErrorBoundary";
|
|
7
|
+
import { appDidStart } from "./action-creators/app";
|
|
8
|
+
import I18n from "./components/I18n";
|
|
9
|
+
import { getIsSessionExpired } from "./selectors/user";
|
|
10
|
+
import logout from "./actions/user/logout";
|
|
11
|
+
|
|
12
|
+
/**
|
|
2
13
|
* The application component.
|
|
3
14
|
* It sets up the store and the react router. The router's children (routes) come from
|
|
4
15
|
* the theme's Main.jsx file which uses this component as the root element.
|
|
5
16
|
* @returns {JSX}
|
|
6
|
-
*/
|
|
17
|
+
*/
|
|
18
|
+
class App extends Component {
|
|
19
|
+
/**
|
|
7
20
|
* Registers the component for the native events and fires the onload AppCommand.
|
|
8
|
-
*/
|
|
21
|
+
*/
|
|
22
|
+
componentDidMount() {
|
|
23
|
+
/**
|
|
9
24
|
* Async helper function that performs optional steps before appDidStart action is dispatched
|
|
10
|
-
*/
|
|
11
|
-
|
|
25
|
+
*/
|
|
26
|
+
const performAppStart = async () => {
|
|
27
|
+
if (getIsSessionExpired(this.props.store.getState())) {
|
|
28
|
+
// Logout the user before appDidStart when session is expired
|
|
29
|
+
try {
|
|
30
|
+
await this.props.store.dispatch(logout(undefined, true));
|
|
31
|
+
} catch (e) {
|
|
32
|
+
// Noting to do here
|
|
33
|
+
console.error('AppStartLogout failed', e);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
this.props.store.dispatch(appDidStart(`${window.location.pathname}${window.location.search}`));
|
|
37
|
+
};
|
|
38
|
+
performAppStart();
|
|
39
|
+
loadCustomStyles();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
12
43
|
* Renders the component.
|
|
13
44
|
* @returns {JSX}
|
|
14
|
-
*/
|
|
45
|
+
*/
|
|
46
|
+
render() {
|
|
47
|
+
return /*#__PURE__*/React.createElement(CookiesProvider, null, /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
48
|
+
key: "error.root",
|
|
49
|
+
store: this.props.store,
|
|
50
|
+
isRoot: true
|
|
51
|
+
}, /*#__PURE__*/React.createElement(Provider, {
|
|
52
|
+
store: this.props.store
|
|
53
|
+
}, /*#__PURE__*/React.createElement(I18n.Provider, null, /*#__PURE__*/React.createElement("div", null, this.props.children)))));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export default App;
|
|
@@ -1,42 +1,105 @@
|
|
|
1
|
-
import{APP_WILL_INIT,APP_WILL_START,APP_DID_START,PWA_DID_APPEAR,PWA_DID_DISAPPEAR,RESET_APP,WILL_REGISTER_LINK_EVENTS,DID_REGISTER_LINK_EVENTS,OPEN_DEEP_LINK,OPEN_PUSH_NOTIFICATION,OPEN_UNIVERSAL_LINK}from"../../constants/ActionTypes"
|
|
1
|
+
import { APP_WILL_INIT, APP_WILL_START, APP_DID_START, PWA_DID_APPEAR, PWA_DID_DISAPPEAR, RESET_APP, WILL_REGISTER_LINK_EVENTS, DID_REGISTER_LINK_EVENTS, OPEN_DEEP_LINK, OPEN_PUSH_NOTIFICATION, OPEN_UNIVERSAL_LINK } from "../../constants/ActionTypes";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched APP_WILL_INIT action object.
|
|
3
5
|
* @param {Object} location The initial history entry location.
|
|
4
6
|
* @return {Object} The dispatched action object.
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
export const appWillInit = location => ({
|
|
9
|
+
type: APP_WILL_INIT,
|
|
10
|
+
location
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
/**
|
|
6
14
|
* Creates the dispatched APP_WILL_START action object.
|
|
7
15
|
* @param {Object} location The initial history entry location.
|
|
8
16
|
* @return {Object} The dispatched action object.
|
|
9
|
-
*/
|
|
17
|
+
*/
|
|
18
|
+
export const appWillStart = location => ({
|
|
19
|
+
type: APP_WILL_START,
|
|
20
|
+
location
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
/**
|
|
10
24
|
* Creates the dispatched APP_DID_START action object.
|
|
11
25
|
* @param {Object} location The initial history entry location.
|
|
12
26
|
* @return {Object} The dispatched action object.
|
|
13
|
-
*/
|
|
27
|
+
*/
|
|
28
|
+
export const appDidStart = location => ({
|
|
29
|
+
type: APP_DID_START,
|
|
30
|
+
location
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/**
|
|
14
34
|
* Creates the dispatched RESET_APP action object.
|
|
15
35
|
* @param {string[]} [reducers=undefined] The list of reducers to reset.
|
|
16
36
|
* @return {Object} The dispatched action object.
|
|
17
|
-
*/
|
|
37
|
+
*/
|
|
38
|
+
export const resetApp = reducers => ({
|
|
39
|
+
type: RESET_APP,
|
|
40
|
+
reducers
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
/**
|
|
18
44
|
* Creates the dispatched PWA_DID_APPEAR action object.
|
|
19
45
|
* @return {Object} The dispatched action object.
|
|
20
|
-
*/
|
|
46
|
+
*/
|
|
47
|
+
export const pwaDidAppear = () => ({
|
|
48
|
+
type: PWA_DID_APPEAR
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/**
|
|
21
52
|
* Creates the dispatched PWA_DID_DISAPPEAR action
|
|
22
53
|
* @return {Object} The dispatched action object.
|
|
23
|
-
*/
|
|
54
|
+
*/
|
|
55
|
+
export const pwaDidDisappear = () => ({
|
|
56
|
+
type: PWA_DID_DISAPPEAR
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
/**
|
|
24
60
|
* Creates the dispatched WILL_REGISTER_LINK_EVENTS action object.
|
|
25
61
|
* @return {Object} The dispatched action object.
|
|
26
|
-
*/
|
|
62
|
+
*/
|
|
63
|
+
export const willRegisterLinkEvents = () => ({
|
|
64
|
+
type: WILL_REGISTER_LINK_EVENTS
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
/**
|
|
27
68
|
* Creates the dispatched DID_REGISTER_LINK_EVENTS action object.
|
|
28
69
|
* @return {Object} The dispatched action object.
|
|
29
|
-
*/
|
|
70
|
+
*/
|
|
71
|
+
export const didRegisterLinkEvents = () => ({
|
|
72
|
+
type: DID_REGISTER_LINK_EVENTS
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
/**
|
|
30
76
|
* Creates the dispatched OPEN_DEEP_LINK action object.
|
|
31
77
|
* @param {Object} payload The payload of the deeplink
|
|
32
78
|
* @return {Object} The dispatched action object.
|
|
33
|
-
*/
|
|
79
|
+
*/
|
|
80
|
+
export const openDeepLink = payload => ({
|
|
81
|
+
type: OPEN_DEEP_LINK,
|
|
82
|
+
payload
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
/**
|
|
34
86
|
* Creates the dispatched OPEN_PUSH_NOTIFICATION action object.
|
|
35
87
|
* @param {string} notificationId The notification ID.
|
|
36
88
|
* @param {string} [link] The link of the notification.
|
|
37
89
|
* @return {Object} The dispatched action object.
|
|
38
|
-
*/
|
|
90
|
+
*/
|
|
91
|
+
export const openPushNotification = (notificationId, link = '') => ({
|
|
92
|
+
type: OPEN_PUSH_NOTIFICATION,
|
|
93
|
+
notificationId,
|
|
94
|
+
link
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
/**
|
|
39
98
|
* Creates the dispatched OPEN_UNIVERSAL_LINK action object.
|
|
40
99
|
* @param {Object} payload The payload of the universal link.
|
|
41
100
|
* @return {Object} The dispatched action object.
|
|
42
|
-
*/
|
|
101
|
+
*/
|
|
102
|
+
export const openUniversalLink = payload => ({
|
|
103
|
+
type: OPEN_UNIVERSAL_LINK,
|
|
104
|
+
payload
|
|
105
|
+
});
|
|
@@ -1 +1,96 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { APP_WILL_START, APP_DID_START, PWA_DID_APPEAR, PWA_DID_DISAPPEAR, WILL_REGISTER_LINK_EVENTS, DID_REGISTER_LINK_EVENTS, OPEN_DEEP_LINK, OPEN_PUSH_NOTIFICATION, OPEN_UNIVERSAL_LINK } from "../../constants/ActionTypes";
|
|
2
|
+
import { appWillStart, appDidStart, pwaDidAppear, pwaDidDisappear, willRegisterLinkEvents, didRegisterLinkEvents, openDeepLink, openPushNotification, openUniversalLink } from "./index";
|
|
3
|
+
const dataMock = {
|
|
4
|
+
some: 'data'
|
|
5
|
+
};
|
|
6
|
+
describe('Action Creators: app', () => {
|
|
7
|
+
describe('appWillStart()', () => {
|
|
8
|
+
it('should work as expected', () => {
|
|
9
|
+
const expected = {
|
|
10
|
+
type: APP_WILL_START,
|
|
11
|
+
location: dataMock
|
|
12
|
+
};
|
|
13
|
+
expect(appWillStart(dataMock)).toEqual(expected);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
describe('appDidStart()', () => {
|
|
17
|
+
it('should work as expected', () => {
|
|
18
|
+
const expected = {
|
|
19
|
+
type: APP_DID_START
|
|
20
|
+
};
|
|
21
|
+
expect(appDidStart()).toEqual(expected);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
describe('pwaDidAppear()', () => {
|
|
25
|
+
it('should work as expected', () => {
|
|
26
|
+
const expected = {
|
|
27
|
+
type: PWA_DID_APPEAR
|
|
28
|
+
};
|
|
29
|
+
expect(pwaDidAppear()).toEqual(expected);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe('pwaDidDisappear()', () => {
|
|
33
|
+
it('should work as expected', () => {
|
|
34
|
+
const expected = {
|
|
35
|
+
type: PWA_DID_DISAPPEAR
|
|
36
|
+
};
|
|
37
|
+
expect(pwaDidDisappear()).toEqual(expected);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
describe('willRegisterLinkEvents()', () => {
|
|
41
|
+
it('should work as expected', () => {
|
|
42
|
+
const expected = {
|
|
43
|
+
type: WILL_REGISTER_LINK_EVENTS
|
|
44
|
+
};
|
|
45
|
+
expect(willRegisterLinkEvents()).toEqual(expected);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
describe('didRegisterLinkEvents()', () => {
|
|
49
|
+
it('should work as expected', () => {
|
|
50
|
+
const expected = {
|
|
51
|
+
type: DID_REGISTER_LINK_EVENTS
|
|
52
|
+
};
|
|
53
|
+
expect(didRegisterLinkEvents()).toEqual(expected);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
describe('openDeepLink()', () => {
|
|
57
|
+
it('should work as expected', () => {
|
|
58
|
+
const expected = {
|
|
59
|
+
type: OPEN_DEEP_LINK,
|
|
60
|
+
payload: dataMock
|
|
61
|
+
};
|
|
62
|
+
expect(openDeepLink(dataMock)).toEqual(expected);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
describe('openPushNotification()', () => {
|
|
66
|
+
const notificationId = 'abc123';
|
|
67
|
+
const link = '/link/to/somewhere';
|
|
68
|
+
it('should work as expected', () => {
|
|
69
|
+
const expected = {
|
|
70
|
+
type: OPEN_PUSH_NOTIFICATION,
|
|
71
|
+
notificationId,
|
|
72
|
+
link
|
|
73
|
+
};
|
|
74
|
+
expect(openPushNotification(notificationId, link)).toEqual(expected);
|
|
75
|
+
});
|
|
76
|
+
it('should work as expected when the link is empty', () => {
|
|
77
|
+
const expected = {
|
|
78
|
+
type: OPEN_PUSH_NOTIFICATION,
|
|
79
|
+
notificationId,
|
|
80
|
+
link: ''
|
|
81
|
+
};
|
|
82
|
+
expect(openPushNotification(notificationId)).toEqual(expected);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
describe('openUniversalLink()', () => {
|
|
86
|
+
const expected = {
|
|
87
|
+
type: OPEN_UNIVERSAL_LINK,
|
|
88
|
+
payload: {
|
|
89
|
+
link: 'https://testshop.shopgate.com/item/313131313132',
|
|
90
|
+
wasOpenedFromSearchIndex: true,
|
|
91
|
+
linkSerial: 1003
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
expect(openUniversalLink(expected.payload)).toEqual(expected);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -1,15 +1,37 @@
|
|
|
1
|
-
import{REQUEST_CLIENT_INFORMATION,RECEIVE_CLIENT_INFORMATION,ERROR_CLIENT_INFORMATION,RECEIVE_CLIENT_CONNECTIVITY}from"../../constants/ActionTypes"
|
|
1
|
+
import { REQUEST_CLIENT_INFORMATION, RECEIVE_CLIENT_INFORMATION, ERROR_CLIENT_INFORMATION, RECEIVE_CLIENT_CONNECTIVITY } from "../../constants/ActionTypes";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched REQUEST_CLIENT_INFORMATION action object.
|
|
3
5
|
* @returns {Object} The dispatched action object.
|
|
4
|
-
*/
|
|
6
|
+
*/
|
|
7
|
+
export const requestClientInformation = () => ({
|
|
8
|
+
type: REQUEST_CLIENT_INFORMATION
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
/**
|
|
5
12
|
* Creates the dispatched RECEIVE_CLIENT_INFORMATION action object.
|
|
6
13
|
* @param {Object} data The received client information data.
|
|
7
14
|
* @returns {Object} The dispatched action object.
|
|
8
|
-
*/
|
|
15
|
+
*/
|
|
16
|
+
export const receiveClientInformation = data => ({
|
|
17
|
+
type: RECEIVE_CLIENT_INFORMATION,
|
|
18
|
+
data
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
/**
|
|
9
22
|
* Creates the dispatched ERROR_CLIENT_INFORMATION action object.
|
|
10
23
|
* @returns {Object} The dispatched action object.
|
|
11
|
-
*/
|
|
24
|
+
*/
|
|
25
|
+
export const errorClientInformation = () => ({
|
|
26
|
+
type: ERROR_CLIENT_INFORMATION
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
/**
|
|
12
30
|
* Creates the dispatched RECEIVE_CLIENT_CONNECTIVITY action object.
|
|
13
31
|
* @param {Object} data The received client connectivity data.
|
|
14
32
|
* @returns {Object} The dispatched action object.
|
|
15
|
-
*/
|
|
33
|
+
*/
|
|
34
|
+
export const receiveClientConnectivity = data => ({
|
|
35
|
+
type: RECEIVE_CLIENT_CONNECTIVITY,
|
|
36
|
+
data
|
|
37
|
+
});
|
|
@@ -1 +1,44 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { requestClientInformation, receiveClientInformation, errorClientInformation, receiveClientConnectivity } from "./index";
|
|
2
|
+
import { REQUEST_CLIENT_INFORMATION, RECEIVE_CLIENT_INFORMATION, ERROR_CLIENT_INFORMATION, RECEIVE_CLIENT_CONNECTIVITY } from "../../constants/ActionTypes";
|
|
3
|
+
describe('Action Creators: client', () => {
|
|
4
|
+
describe('requestClientInformation()', () => {
|
|
5
|
+
it('should work as expected', () => {
|
|
6
|
+
const expected = {
|
|
7
|
+
type: REQUEST_CLIENT_INFORMATION
|
|
8
|
+
};
|
|
9
|
+
expect(requestClientInformation()).toEqual(expected);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
describe('receiveClientInformation()', () => {
|
|
13
|
+
it('should work as expected', () => {
|
|
14
|
+
const data = {
|
|
15
|
+
some: 'data'
|
|
16
|
+
};
|
|
17
|
+
const expected = {
|
|
18
|
+
type: RECEIVE_CLIENT_INFORMATION,
|
|
19
|
+
data
|
|
20
|
+
};
|
|
21
|
+
expect(receiveClientInformation(data)).toEqual(expected);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
describe('errorClientInformation()', () => {
|
|
25
|
+
it('should work as expected', () => {
|
|
26
|
+
const expected = {
|
|
27
|
+
type: ERROR_CLIENT_INFORMATION
|
|
28
|
+
};
|
|
29
|
+
expect(errorClientInformation()).toEqual(expected);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe('receiveClientConnectivity()', () => {
|
|
33
|
+
it('should work as expected', () => {
|
|
34
|
+
const data = {
|
|
35
|
+
some: 'data'
|
|
36
|
+
};
|
|
37
|
+
const expected = {
|
|
38
|
+
type: RECEIVE_CLIENT_CONNECTIVITY,
|
|
39
|
+
data
|
|
40
|
+
};
|
|
41
|
+
expect(receiveClientConnectivity(data)).toEqual(expected);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -1,9 +1,21 @@
|
|
|
1
|
-
import{APP_ERROR,PIPELINE_ERROR}from"../../constants/ActionTypes"
|
|
1
|
+
import { APP_ERROR, PIPELINE_ERROR } from "../../constants/ActionTypes";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched APP_ERROR action object.
|
|
3
5
|
* @param {Object} error The error object.
|
|
4
6
|
* @return {Object} The dispatched action object.
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
export const appError = error => ({
|
|
9
|
+
type: APP_ERROR,
|
|
10
|
+
error
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
/**
|
|
6
14
|
* Creates the dispatched PIPELINE_ERROR action object.
|
|
7
15
|
* @param {Object} error The error object.
|
|
8
16
|
* @return {Object} The dispatched action object.
|
|
9
|
-
*/
|
|
17
|
+
*/
|
|
18
|
+
export const pipelineError = error => ({
|
|
19
|
+
type: PIPELINE_ERROR,
|
|
20
|
+
error
|
|
21
|
+
});
|
package/action-creators/index.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
export*from"./app";
|
|
1
|
+
export * from "./app";
|
|
2
|
+
export * from "./client";
|
|
3
|
+
export * from "./error";
|
|
4
|
+
export * from "./menu";
|
|
5
|
+
export * from "./modal";
|
|
6
|
+
export * from "./page";
|
|
7
|
+
export * from "./router";
|
|
8
|
+
export * from "./url";
|
|
9
|
+
export * from "./user";
|
|
@@ -1,14 +1,33 @@
|
|
|
1
|
-
import{REQUEST_MENU,RECEIVE_MENU,ERROR_MENU}from"../../constants/ActionTypes"
|
|
1
|
+
import { REQUEST_MENU, RECEIVE_MENU, ERROR_MENU } from "../../constants/ActionTypes";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched REQUEST_MENU action object.
|
|
3
5
|
* @param {string} id The menu id.
|
|
4
6
|
* @return {Object} The dispatched action object.
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
export const requestMenu = id => ({
|
|
9
|
+
type: REQUEST_MENU,
|
|
10
|
+
id
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
/**
|
|
6
14
|
* Creates the dispatched RECEIVE_MENU action object
|
|
7
15
|
* @param {string} id The menu id.
|
|
8
16
|
* @param {Array} entries The menu entries.
|
|
9
17
|
* @return {Object} The dispatched action object.
|
|
10
|
-
*/
|
|
18
|
+
*/
|
|
19
|
+
export const receiveMenu = (id, entries) => ({
|
|
20
|
+
type: RECEIVE_MENU,
|
|
21
|
+
id,
|
|
22
|
+
entries
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
/**
|
|
11
26
|
* Creates the dispatched ERROR_MENU action object.
|
|
12
27
|
* @param {string} id The menu id.
|
|
13
28
|
* @return {Object} The dispatched action object.
|
|
14
|
-
*/
|
|
29
|
+
*/
|
|
30
|
+
export const errorMenu = id => ({
|
|
31
|
+
type: ERROR_MENU,
|
|
32
|
+
id
|
|
33
|
+
});
|
|
@@ -1 +1,37 @@
|
|
|
1
|
-
import{REQUEST_MENU,RECEIVE_MENU,ERROR_MENU}from"../../constants/ActionTypes";
|
|
1
|
+
import { REQUEST_MENU, RECEIVE_MENU, ERROR_MENU } from "../../constants/ActionTypes";
|
|
2
|
+
import { requestMenu, receiveMenu, errorMenu } from "./index";
|
|
3
|
+
const entries = [{
|
|
4
|
+
url: '/',
|
|
5
|
+
label: 'Page Label'
|
|
6
|
+
}];
|
|
7
|
+
const id = 'quicklinks';
|
|
8
|
+
describe('Action Creators: menu', () => {
|
|
9
|
+
describe('requestMenu()', () => {
|
|
10
|
+
it('should work as expected', () => {
|
|
11
|
+
const expected = {
|
|
12
|
+
type: REQUEST_MENU,
|
|
13
|
+
id
|
|
14
|
+
};
|
|
15
|
+
expect(requestMenu(id)).toEqual(expected);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
describe('receiveMenu()', () => {
|
|
19
|
+
it('should work as expected', () => {
|
|
20
|
+
const expected = {
|
|
21
|
+
type: RECEIVE_MENU,
|
|
22
|
+
id,
|
|
23
|
+
entries
|
|
24
|
+
};
|
|
25
|
+
expect(receiveMenu(id, entries)).toEqual(expected);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
describe('errorMenu()', () => {
|
|
29
|
+
it('should work as expected', () => {
|
|
30
|
+
const expected = {
|
|
31
|
+
type: ERROR_MENU,
|
|
32
|
+
id
|
|
33
|
+
};
|
|
34
|
+
expect(errorMenu(id)).toEqual(expected);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -1,9 +1,21 @@
|
|
|
1
|
-
import{CREATE_MODAL,REMOVE_MODAL}from"../../constants/ActionTypes"
|
|
1
|
+
import { CREATE_MODAL, REMOVE_MODAL } from "../../constants/ActionTypes";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched CREATE_MODAL action object.
|
|
3
5
|
* @param {Object} options The modal options.
|
|
4
6
|
* @return {Object} The dispatched action object.
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
export const createModal = options => ({
|
|
9
|
+
type: CREATE_MODAL,
|
|
10
|
+
options
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
/**
|
|
6
14
|
* Creates the dispatched REMOVE_MODAL action object.
|
|
7
15
|
* @param {string} id The modal id to remove.
|
|
8
16
|
* @return {Object} The dispatched action object.
|
|
9
|
-
*/
|
|
17
|
+
*/
|
|
18
|
+
export const removeModal = id => ({
|
|
19
|
+
type: REMOVE_MODAL,
|
|
20
|
+
id
|
|
21
|
+
});
|
|
@@ -1 +1,26 @@
|
|
|
1
|
-
import{CREATE_MODAL,REMOVE_MODAL}from"../../constants/ActionTypes";
|
|
1
|
+
import { CREATE_MODAL, REMOVE_MODAL } from "../../constants/ActionTypes";
|
|
2
|
+
import { createModal, removeModal } from "./index";
|
|
3
|
+
const options = {
|
|
4
|
+
some: 'data'
|
|
5
|
+
};
|
|
6
|
+
const id = 'modalId';
|
|
7
|
+
describe('Action Creators: modal', () => {
|
|
8
|
+
describe('createModal()', () => {
|
|
9
|
+
it('should work as expected', () => {
|
|
10
|
+
const expected = {
|
|
11
|
+
type: CREATE_MODAL,
|
|
12
|
+
options
|
|
13
|
+
};
|
|
14
|
+
expect(createModal(options)).toEqual(expected);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
describe('removeModal()', () => {
|
|
18
|
+
it('should work as expected', () => {
|
|
19
|
+
const expected = {
|
|
20
|
+
type: REMOVE_MODAL,
|
|
21
|
+
id
|
|
22
|
+
};
|
|
23
|
+
expect(removeModal(id)).toEqual(expected);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -1,15 +1,35 @@
|
|
|
1
|
-
import{REQUEST_PAGE_CONFIG,RECEIVE_PAGE_CONFIG,ERROR_PAGE_CONFIG}from"../../constants/ActionTypes"
|
|
1
|
+
import { REQUEST_PAGE_CONFIG, RECEIVE_PAGE_CONFIG, ERROR_PAGE_CONFIG } from "../../constants/ActionTypes";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched REQUEST_PAGE_CONFIG action object.
|
|
3
5
|
* @param {Object} pageId The page to get the widgets for.
|
|
4
6
|
* @returns {Object} The dispatched action object.
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
export const requestPageConfig = pageId => ({
|
|
9
|
+
type: REQUEST_PAGE_CONFIG,
|
|
10
|
+
pageId
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
/**
|
|
6
14
|
* Creates the dispatched RECEIVE_PAGE_CONFIG action object.
|
|
7
15
|
* @param {Object} pageId The page id.
|
|
8
16
|
* @param {Object} config The page configuration.
|
|
9
17
|
* @returns {Object} The dispatched action object.
|
|
10
|
-
*/
|
|
18
|
+
*/
|
|
19
|
+
export const receivePageConfig = (pageId, config) => ({
|
|
20
|
+
type: RECEIVE_PAGE_CONFIG,
|
|
21
|
+
pageId,
|
|
22
|
+
config
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
/**
|
|
11
26
|
* Creates the dispatched ERROR_PAGE_CONFIG action object.
|
|
12
27
|
* @param {Object} pageId The page id.
|
|
13
28
|
* @param {string} errorCode The error code.
|
|
14
29
|
* @returns {Object} The dispatched action object.
|
|
15
|
-
*/
|
|
30
|
+
*/
|
|
31
|
+
export const errorPageConfig = (pageId, errorCode) => ({
|
|
32
|
+
type: ERROR_PAGE_CONFIG,
|
|
33
|
+
pageId,
|
|
34
|
+
errorCode
|
|
35
|
+
});
|
|
@@ -1 +1,38 @@
|
|
|
1
|
-
import{REQUEST_PAGE_CONFIG,RECEIVE_PAGE_CONFIG,ERROR_PAGE_CONFIG}from"../../constants/ActionTypes";
|
|
1
|
+
import { REQUEST_PAGE_CONFIG, RECEIVE_PAGE_CONFIG, ERROR_PAGE_CONFIG } from "../../constants/ActionTypes";
|
|
2
|
+
import { requestPageConfig, receivePageConfig, errorPageConfig } from "./index";
|
|
3
|
+
const pageId = 'index';
|
|
4
|
+
const config = {
|
|
5
|
+
some: 'data'
|
|
6
|
+
};
|
|
7
|
+
describe('Action Creators: page', () => {
|
|
8
|
+
describe('requestPageConfig()', () => {
|
|
9
|
+
it('should work as expected', () => {
|
|
10
|
+
const expected = {
|
|
11
|
+
type: REQUEST_PAGE_CONFIG,
|
|
12
|
+
pageId
|
|
13
|
+
};
|
|
14
|
+
expect(requestPageConfig(pageId)).toEqual(expected);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
describe('receivePageConfig()', () => {
|
|
18
|
+
it('should work as expected', () => {
|
|
19
|
+
const expected = {
|
|
20
|
+
type: RECEIVE_PAGE_CONFIG,
|
|
21
|
+
pageId,
|
|
22
|
+
config
|
|
23
|
+
};
|
|
24
|
+
expect(receivePageConfig(pageId, config)).toEqual(expected);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe('errorPageConfig()', () => {
|
|
28
|
+
it('should work as expected', () => {
|
|
29
|
+
const errorCode = 'error';
|
|
30
|
+
const expected = {
|
|
31
|
+
type: ERROR_PAGE_CONFIG,
|
|
32
|
+
errorCode,
|
|
33
|
+
pageId
|
|
34
|
+
};
|
|
35
|
+
expect(errorPageConfig(pageId, errorCode)).toEqual(expected);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
});
|