@capillarytech/creatives-library 8.0.32 → 8.0.34-alpha.0

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.
Files changed (41) hide show
  1. package/containers/App/constants.js +1 -0
  2. package/package.json +1 -1
  3. package/reducers.js +10 -33
  4. package/utils/tagValidations.js +13 -1
  5. package/utils/tests/tagValidations.test.js +43 -1
  6. package/v2Components/FormBuilder/index.js +7 -2
  7. package/v2Containers/BeeEditor/index.js +2 -2
  8. package/v2Containers/CreativesContainer/index.js +1 -1
  9. package/v2Containers/MobilePush/Create/index.js +1 -1
  10. package/v2Containers/MobilePush/Edit/index.js +4 -5
  11. package/v2Containers/TagList/index.js +1 -1
  12. package/v2Containers/TagList/messages.js +3 -3
  13. package/v2Containers/TagList/tests/TagList.test.js +2 -2
  14. package/v2Containers/Templates/sagas.js +1 -1
  15. package/containers/Cap/tests/selectors.test.js +0 -28
  16. package/containers/TestPage/constants.js +0 -7
  17. package/containers/TestPage/index.js +0 -31
  18. package/containers/TestPage/messages.js +0 -13
  19. package/containers/TestPage/reducer.js +0 -21
  20. package/containers/TestPage/sagas.js +0 -11
  21. package/containers/Testv2/actions.js +0 -15
  22. package/containers/Testv2/constants.js +0 -7
  23. package/containers/Testv2/index.js +0 -47
  24. package/containers/Testv2/messages.js +0 -21
  25. package/containers/Testv2/reducer.js +0 -23
  26. package/containers/Testv2/sagas.js +0 -11
  27. package/containers/Testv2/selectors.js +0 -25
  28. package/store.js +0 -61
  29. package/utils/tests/asyncInjectors.test.js +0 -173
  30. package/v2Containers/TestPage/constants.js +0 -7
  31. package/v2Containers/TestPage/index.js +0 -31
  32. package/v2Containers/TestPage/messages.js +0 -13
  33. package/v2Containers/TestPage/reducer.js +0 -21
  34. package/v2Containers/TestPage/sagas.js +0 -11
  35. package/v2Containers/Testv2/actions.js +0 -15
  36. package/v2Containers/Testv2/constants.js +0 -7
  37. package/v2Containers/Testv2/index.js +0 -47
  38. package/v2Containers/Testv2/messages.js +0 -21
  39. package/v2Containers/Testv2/reducer.js +0 -23
  40. package/v2Containers/Testv2/sagas.js +0 -11
  41. package/v2Containers/Testv2/selectors.js +0 -25
@@ -110,3 +110,4 @@ export const BADGES_ISSUE = 'BADGES_ISSUE';
110
110
 
111
111
  export const CUSTOMER_BARCODE_TAG = "customer_barcode";
112
112
  export const COPY_OF = "Copy of";
113
+ export const ENTRY_TRIGGER_TAG_REGEX = /\bentryTrigger_\w+(_\w+)?(\(\w+\))?/g;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.32",
4
+ "version": "8.0.34-alpha.0",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
package/reducers.js CHANGED
@@ -4,8 +4,8 @@
4
4
  */
5
5
 
6
6
  import { combineReducers } from 'redux-immutable';
7
- import { fromJS } from 'immutable';
8
- import { LOCATION_CHANGE } from 'react-router-redux';
7
+ import { connectRouter } from 'connected-react-router/immutable';
8
+ // import { fromJS } from 'immutable';
9
9
 
10
10
  import languageProviderReducer from 'v2Containers/LanguageProvider/reducer';
11
11
  import beeEditorReducer from 'v2Containers/BeeEditor/reducer';
@@ -23,40 +23,12 @@ import ftpReducer from 'v2Containers/FTP/reducer';
23
23
  import galleryReducer from './v2Containers/Assets/Gallery/reducer';
24
24
  import { AIRA_REDUCER_DOMAIN, askAiraReducer } from '@capillarytech/cap-ui-library/CapAskAira';
25
25
  import CapCollapsibleLeftNavigationReducer from '@capillarytech/cap-ui-library/CapCollapsibleLeftNavigation/reducer';
26
- /*
27
- * routeReducer
28
- *
29
- * The reducer merges route location changes into our immutable state.
30
- * The change is necessitated by moving to react-router-redux@4
31
- *
32
- */
33
-
34
- // Initial routing state
35
- const routeInitialState = fromJS({
36
- locationBeforeTransitions: null,
37
- });
38
-
39
- /**
40
- * Merge route into the global application state
41
- */
42
- function routeReducer(state = routeInitialState, action) {
43
- switch (action.type) {
44
- /* istanbul ignore next */
45
- case LOCATION_CHANGE:
46
- return state.merge({
47
- locationBeforeTransitions: action.payload,
48
- });
49
- default:
50
- return state;
51
- }
52
- }
53
-
26
+ import history from './utils/history';
54
27
  /**
55
28
  * Creates the main reducer with the asynchronously loaded ones
56
29
  */
57
- export default function createReducer(asyncReducers) {
58
- return combineReducers({
59
- route: routeReducer,
30
+ export default function createReducer(asyncReducers = {}) {
31
+ const rootReducer = combineReducers({
60
32
  language: languageProviderReducer,
61
33
  cap: capReducer,
62
34
  app: appReducer,
@@ -73,5 +45,10 @@ export default function createReducer(asyncReducers) {
73
45
  navigationConfig: CapCollapsibleLeftNavigationReducer,
74
46
  [AIRA_REDUCER_DOMAIN]: askAiraReducer,
75
47
  ...asyncReducers,
48
+ router: connectRouter(history),
76
49
  });
50
+
51
+ // Wrap the root reducer and return a new root reducer with router state
52
+ const mergeWithRouterState = connectRouter(history);
53
+ return mergeWithRouterState(rootReducer);
77
54
  }
@@ -8,6 +8,7 @@
8
8
 
9
9
  import lodashForEach from 'lodash/forEach';
10
10
  import lodashCloneDeep from 'lodash/cloneDeep';
11
+ import { ENTRY_TRIGGER_TAG_REGEX } from '../containers/App/constants';
11
12
 
12
13
  const DEFAULT = 'default';
13
14
  const SUBTAGS = 'subtags';
@@ -17,7 +18,7 @@ const SUBTAGS = 'subtags';
17
18
  * @param {Object} response - The response object to check.
18
19
  * @param {Object} tagObject - The tagLookupMap.
19
20
  */
20
- export const checkSupport = (response = {}, tagObject = {}, eventContextTags = []) => {
21
+ export const checkSupport = (response = {}, tagObject = {}, eventContextTags = [], isLiquidFlow = false) => {
21
22
  const supportedList = [];
22
23
  // Verifies the presence of the tag in the 'Add Labels' section.
23
24
  // Incase of journey event context the tags won't be available in the tagObject(tagLookupMap).
@@ -25,6 +26,13 @@ export const checkSupport = (response = {}, tagObject = {}, eventContextTags = [
25
26
 
26
27
  // Verify if childTag is a valid sub-tag of parentTag from the 'Add Labels' section or if it's unsupported.
27
28
  const checkSubtags = (parentTag, childName) => {
29
+ // For event context tags the parentTag will be the event context tag name and subtags will be the child attributes for leaderboards
30
+ if (checkNameInTagObjectOrEventContext(parentTag) && isLiquidFlow && eventContextTags?.length) {
31
+ const childNameAfterDot = childName?.split(".")?.[1];
32
+ if (eventContextTags?.some((tag) => tag?.subTags?.includes(childNameAfterDot))) {
33
+ supportedList.push(childName);
34
+ }
35
+ }
28
36
  if (!tagObject?.[parentTag]) return false;
29
37
  let updatedChildName = childName;
30
38
  if (childName?.includes(".")) {
@@ -195,6 +203,10 @@ const indexOfEnd = (targetString, string) => {
195
203
  }
196
204
 
197
205
  export const skipTags = (tag) => {
206
+ // If the tag contains the word "entryTrigger_", then it's an event context tag and should not be skipped.
207
+ if (tag?.match(ENTRY_TRIGGER_TAG_REGEX)) {
208
+ return false;
209
+ }
198
210
  const regexGroups = ["dynamic_expiry_date_after_\\d+_days.FORMAT_\\d", "unsubscribe\\(#[a-zA-Z\\d]{6}\\)","Link_to_[a-zA-z]","SURVEY.*.TOKEN", "^[A-Za-z].*\\([a-zA-Z\\d]*\\)"];
199
211
  let skipped = false;
200
212
  lodashForEach(regexGroups, (group) => {
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import '@testing-library/jest-dom';
3
- import { checkSupport, extractNames, getTagMapValue, preprocessHtml, validateIfTagClosed,validateTags} from '../tagValidations';
3
+ import { checkSupport, extractNames, getTagMapValue, preprocessHtml, validateIfTagClosed,validateTags, skipTags } from '../tagValidations';
4
4
  import { eventContextTags } from '../../v2Containers/TagList/tests/mockdata';
5
5
 
6
6
  describe("check if curly brackets are balanced", () => {
@@ -376,6 +376,34 @@ describe("checkSupport", () => {
376
376
  const result = checkSupport(response, {});
377
377
  expect(result).toEqual([]);
378
378
  });
379
+
380
+ it("should add childName to supportedList if it is a subtag of parentTag in eventContextTags", () => {
381
+ const response = { data: [{ name: "leaderboard", children: [{name: "person.userId"}]}]};
382
+ const tagObject = {};
383
+ const eventContextTags = [{ tagName: "leaderboard", subTags: ["userId"]}];
384
+ const isLiquidFlow = true;
385
+ const result = checkSupport(response, tagObject, eventContextTags, isLiquidFlow);
386
+ expect(result).toEqual( [ 'leaderboard', 'person.userId' ]);
387
+ });
388
+
389
+ it("should not add childName to supportedList which does not have dot in eventContextTags", () => {
390
+ // This case is unlikely to happen as we are not supporting tags without dot in eventContextTags
391
+ const response = { data: [{ name: "entryTrigger_lifetimePoints", children: [{name: "userId"}] }]};
392
+ const tagObject = {};
393
+ const eventContextTags = [{ tagName: "entryTrigger_lifetimePoints", children: [{name: "userId"}] }];
394
+ const isLiquidFlow = true;
395
+ const result = checkSupport(response, tagObject, eventContextTags, isLiquidFlow);
396
+ expect(result).toEqual( [ "entryTrigger_lifetimePoints" ]);
397
+ });
398
+
399
+ it("should add only parent tag to supportedList if isLiquidFlow false", () => {
400
+ const response = { data: [{ name: "leaderboard", children: [{name: "person.userId"}]}]};
401
+ const tagObject = {};
402
+ const eventContextTags = [{ tagName: "leaderboard", subTags: ["userId"]}];
403
+ const isLiquidFlow = false;
404
+ const result = checkSupport(response, tagObject, eventContextTags, isLiquidFlow);
405
+ expect(result).toEqual( [ 'leaderboard' ]);
406
+ });
379
407
  });
380
408
 
381
409
  describe('preprocessHtml', () => {
@@ -454,4 +482,18 @@ describe("getTagMapValue", () => {
454
482
  const result = getTagMapValue(object);
455
483
  expect(result).toEqual({ name: "233" });
456
484
  });
485
+ });
486
+
487
+ describe("skipTags", () => {
488
+ it("should return false for event context tags", () => {
489
+ const tag = "entryTrigger_uniqueTagPrefix(raindrops_match)";
490
+ const result = skipTags(tag);
491
+ expect(result).toEqual(false);
492
+ });
493
+
494
+ it("should return true for tags matching regex patterns", () => {
495
+ const tag = "voucher(12345)";
496
+ const result = skipTags(tag);
497
+ expect(result).toEqual(true);
498
+ });
457
499
  });
@@ -55,7 +55,7 @@ import { convert } from 'html-to-text';
55
55
  import { OUTBOUND } from './constants';
56
56
  import { GET_TRANSLATION_MAPPED } from '../../containers/TagList/constants';
57
57
  import moment from 'moment';
58
- import { CUSTOMER_BARCODE_TAG , COPY_OF} from '../../containers/App/constants';
58
+ import { CUSTOMER_BARCODE_TAG , COPY_OF, ENTRY_TRIGGER_TAG_REGEX} from '../../containers/App/constants';
59
59
  import { hasLiquidSupportFeature, isEmailUnsubscribeTagMandatory } from '../../utils/common';
60
60
  import { isUrl } from '../../v2Containers/Line/Container/Wrapper/utils';
61
61
  import { bindActionCreators } from 'redux';
@@ -1121,7 +1121,8 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1121
1121
  const supportedLiquidTags = checkSupport(
1122
1122
  result,
1123
1123
  this.props?.metaEntities?.tagLookupMap,
1124
- this.props?.eventContextTags
1124
+ this.props?.eventContextTags,
1125
+ this.liquidFlow,
1125
1126
  );
1126
1127
  const unsupportedLiquidTags = extractedLiquidTags?.filter(
1127
1128
  (tag) => !supportedLiquidTags?.includes(tag) && !this.skipTags(tag)
@@ -1197,6 +1198,10 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1197
1198
  };
1198
1199
 
1199
1200
  skipTags(tag) {
1201
+ // If the tag contains the word "entryTrigger_", then it's an event context tag and it should not be skipped.
1202
+ if (tag?.match(ENTRY_TRIGGER_TAG_REGEX)) {
1203
+ return false;
1204
+ }
1200
1205
  const regexGroups = ["dynamic_expiry_date_after_\\d+_days.FORMAT_\\d", "unsubscribe\\(#[a-zA-Z\\d]{6}\\)","Link_to_[a-zA-z]","SURVEY.*.TOKEN","^[A-Za-z].*\\([a-zA-Z\\d]*\\)"];
1201
1206
  //const regexGroups = [];
1202
1207
  let skipped = false;
@@ -25,14 +25,14 @@ import CapAskAira from '@capillarytech/cap-ui-library/CapAskAira';
25
25
  import { request,getAPICallObject } from '../../services/api';
26
26
  import messages from './messages';
27
27
  import * as beeActions from './actions';
28
+ import { selectCurrentOrgDetails } from '../Cap/selectors';
29
+ import { ENABLE_AI_SUGGESTIONS } from './constants';
28
30
  import injectSaga from '../../utils/injectSaga';
29
31
  import injectReducer from '../../utils/injectReducer';
30
32
  import { v2BeeEditionSagas } from './sagas';
31
33
  import v2BeeEditionReducer from './reducer';
32
34
  import { compose } from 'redux';
33
35
 
34
- import { selectCurrentOrgDetails } from '../Cap/selectors';
35
- import { ENABLE_AI_SUGGESTIONS } from './constants';
36
36
  function BeeEditor(props) {
37
37
  const {
38
38
  uid,
@@ -41,13 +41,13 @@ import { WHATSAPP_STATUSES, WHATSAPP_MEDIA_TYPES } from '../Whatsapp/constants';
41
41
 
42
42
  import { updateImagesInHtml } from '../../utils/cdnTransformation';
43
43
  import { IOS } from '../InApp/constants';
44
+ import { CAP_SPACE_28, CAP_SPACE_32, CAP_SPACE_56, CAP_SPACE_64, CAP_SPACE_72, CAP_SPACE_80 } from '@capillarytech/cap-ui-library/styled/variables';
44
45
  import injectReducer from '../../utils/injectReducer'
45
46
  import injectSaga from '../../utils/injectSaga';
46
47
  import creativesContainerReducer from './reducer';
47
48
  import { compose } from 'redux';
48
49
  import { capSagaForFetchSchemaForEntity } from '../Cap/sagas';
49
50
  import { v2TemplateSagaWatchGetDefaultBeeTemplates } from '../Templates/sagas';
50
- import { CAP_SPACE_28, CAP_SPACE_32, CAP_SPACE_56, CAP_SPACE_64, CAP_SPACE_72, CAP_SPACE_80 } from '@capillarytech/cap-ui-library/styled/variables';
51
51
 
52
52
  const classPrefix = 'add-creatives-section';
53
53
  const CREATIVES_CONTAINER = 'creativesContainer';
@@ -32,11 +32,11 @@ import { CREATE, TRACK_CREATE_MPUSH } from '../../App/constants';
32
32
  import { MOBILE_PUSH } from '../../CreativesContainer/constants';
33
33
  import { getContent } from '../commonMethods';
34
34
  import { getCdnUrl } from '../../../utils/cdnTransformation';
35
+ import { EXTERNAL_LINK_LOWERCASE } from './constants';
35
36
  import injectReducer from '../../../utils/injectReducer';
36
37
  import injectSaga from '../../../utils/injectSaga';
37
38
  import v2MobilePushCreateReducer from './reducer';
38
39
  import { v2MobilePushWatchDuplicateTemplateSaga } from './sagas';
39
- import { EXTERNAL_LINK_LOWERCASE } from './constants';
40
40
 
41
41
  const PrefixWrapper = styled.div`
42
42
  margin-right: 16px;
@@ -34,16 +34,15 @@ import { GA } from '@capillarytech/cap-ui-utils';
34
34
  import { EDIT, TRACK_EDIT_MPUSH } from '../../App/constants';
35
35
  import { MOBILE_PUSH } from '../../CreativesContainer/constants';
36
36
  import { getCdnUrl } from '../../../utils/cdnTransformation';
37
+ import { MAPP_SDK } from './constants';
38
+ import { isEmbeddedEditOrPreview } from '../../../utils/commonUtils';
39
+ import { EMBEDDED } from '../../Whatsapp/constants';
40
+ import { OUTBOUND } from '../../../v2Components/FormBuilder/constants';
37
41
  import injectSaga from '../../../utils/injectSaga';
38
42
  import injectReducer from '../../../utils/injectReducer';
39
43
  import { v2MobilePushEditSagas } from './sagas';
40
44
  import v2MobilePushEditReducer from './reducer';
41
45
  import * as globalActions from '../../Cap/actions';
42
- import { MAPP_SDK } from './constants';
43
- import { isEmbeddedEditOrPreview } from '../../../utils/commonUtils';
44
- import { EMBEDDED } from '../../Whatsapp/constants';
45
- import { OUTBOUND } from '../../../v2Components/FormBuilder/constants';
46
-
47
46
  const PrefixWrapper = styled.div`
48
47
  margin-right: 16px;
49
48
  `;
@@ -105,7 +105,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
105
105
  }
106
106
  }
107
107
  if (eventContextTags?.length) {
108
- const TAG_HEADER_MSG_LABEL = this.props.intl.formatMessage(messages.tagsBasedOnEntryTriggerEvent);
108
+ const TAG_HEADER_MSG_LABEL = this.props.intl.formatMessage(messages.entryEvent);
109
109
  eventContextTagsObj.EventContextTags = {
110
110
  name: TAG_HEADER_MSG_LABEL,
111
111
  desc: TAG_HEADER_MSG_LABEL,
@@ -11,8 +11,8 @@ export default defineMessages({
11
11
  id: `${scope}.header`,
12
12
  defaultMessage: 'This is TagList container !',
13
13
  },
14
- tagsBasedOnEntryTriggerEvent: {
15
- id: `${scope}.tagsBasedOnEntryTriggerEvent`,
16
- defaultMessage: 'Tags based on entry trigger event',
14
+ entryEvent: {
15
+ id: `${scope}.entryEvent`,
16
+ defaultMessage: 'Entry event',
17
17
  },
18
18
  });
@@ -8,8 +8,8 @@ import { TagList } from '../index';
8
8
  import { TagListData, eventContextTags } from './mockdata';
9
9
  import { Provider } from 'react-redux';
10
10
  import { screen, render } from '../../../utils/test-utils';
11
- import history from '../../../utils/history';
12
11
  const { getByText } = screen;
12
+ import history from '../../../utils/history';
13
13
 
14
14
 
15
15
  const initializeTagList = (props) => {
@@ -46,7 +46,7 @@ describe("TagList test : UNIT", () => {
46
46
  it('should render event context tags correctly from generateTags', () => {
47
47
  initializeTagList({eventContextTags});
48
48
  addLabelBtnAssertion();
49
- const EVENT_CONTEXT_TAG_HEADER = getByText('Tags based on entry trigger event');
49
+ const EVENT_CONTEXT_TAG_HEADER = getByText('Entry event');
50
50
  expect(EVENT_CONTEXT_TAG_HEADER).toBeInTheDocument();
51
51
  fireEvent.click(EVENT_CONTEXT_TAG_HEADER);
52
52
  expect(getByText('lifetimePurchases')).toBeInTheDocument();
@@ -1,5 +1,5 @@
1
- import { call, put, takeLatest, select, all } from 'redux-saga/effects';
2
1
  import get from 'lodash/get';
2
+ import { call, put, takeLatest, select, all } from 'redux-saga/effects';
3
3
  // import { schema, normalize } from 'normalizr';
4
4
  import * as Api from '../../services/api';
5
5
  import * as types from './constants';
@@ -1,28 +0,0 @@
1
- import { fromJS } from 'immutable';
2
-
3
- import { makeSelectLocationState } from 'containers/Cap/selectors';
4
-
5
- describe('makeSelectLocationState', () => {
6
- it('should select the route as a plain JS object', () => {
7
- const route = fromJS({
8
- locationBeforeTransitions: null,
9
- });
10
- const mockedState = fromJS({
11
- route,
12
- });
13
- expect(makeSelectLocationState()(mockedState)).toEqual(route.toJS());
14
- });
15
-
16
- it('should return cached js routeState for same concurrent calls', () => {
17
- const route = fromJS({
18
- locationBeforeTransitions: null,
19
- });
20
- const mockedState = fromJS({
21
- route,
22
- });
23
- const selectLocationState = makeSelectLocationState();
24
-
25
- const firstRouteStateJS = selectLocationState(mockedState);
26
- expect(selectLocationState(mockedState)).toBe(firstRouteStateJS);
27
- });
28
- });
@@ -1,7 +0,0 @@
1
- /*
2
- *
3
- * Dashboard constants
4
- *
5
- */
6
-
7
- export const DEFAULT_ACTION = 'app/containers/TestPage/DEFAULT_ACTION';
@@ -1,31 +0,0 @@
1
-
2
- import React from "react";
3
- import SmsTest from '../../components/SmsTest';
4
-
5
- export default class TestPage extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function
6
- render() {
7
- return (
8
- <SmsTest />
9
- );
10
- }
11
- }
12
-
13
- // const schema = {
14
- // title: "Todo",
15
- // type: "object",
16
- // required: ["title"],
17
- // properties: {
18
- // title: {type: "string", title: "Title", default: "A new task"},
19
- // done: {type: "boolean", title: "Done?", default: false},
20
- // },
21
- // };
22
-
23
- // const log = (type) => console.log.bind(console, type);
24
-
25
- // render((
26
- // <div>
27
- // <SmsTest
28
- // />
29
- // </div>
30
- // ), document.getElementById("app"));
31
- //export default TestPage;
@@ -1,13 +0,0 @@
1
- /*
2
- * NotFoundPage Messages
3
- *
4
- * This contains all the text for the NotFoundPage component.
5
- */
6
- import { defineMessages } from 'react-intl';
7
-
8
- export default defineMessages({
9
- header: {
10
- id: 'creatives.components.TestPage.header',
11
- defaultMessage: 'Looks like youas are lost!',
12
- },
13
- });
@@ -1,21 +0,0 @@
1
- /*
2
- *
3
- * Dashboard reducer
4
- *
5
- */
6
-
7
- import { fromJS } from 'immutable';
8
- import { DEFAULT_ACTION } from './constants';
9
-
10
- const initialState = fromJS({});
11
-
12
- function TestPageReducer(state = initialState, action) {
13
- switch (action.type) {
14
- case DEFAULT_ACTION:
15
- return state;
16
- default:
17
- return state;
18
- }
19
- }
20
-
21
- export default TestPageReducer;
@@ -1,11 +0,0 @@
1
- // import { take, call, put, select } from 'redux-saga/effects';
2
-
3
- // Individual exports for testing
4
- export function* defaultSaga() {
5
- // See example in containers/HomePage/sagas.js
6
- }
7
-
8
- // All sagas to be loaded
9
- export default [
10
- defaultSaga,
11
- ];
@@ -1,15 +0,0 @@
1
- /*
2
- *
3
- * Testv2 actions
4
- *
5
- */
6
-
7
- import {
8
- DEFAULT_ACTION,
9
- } from './constants';
10
-
11
- export function defaultAction() {
12
- return {
13
- type: DEFAULT_ACTION,
14
- };
15
- }
@@ -1,7 +0,0 @@
1
- /*
2
- *
3
- * Testv2 constants
4
- *
5
- */
6
-
7
- export const DEFAULT_ACTION = 'app/Testv2/DEFAULT_ACTION';
@@ -1,47 +0,0 @@
1
- /*
2
- *
3
- * Testv2
4
- *
5
- */
6
-
7
- import PropTypes from 'prop-types';
8
-
9
- import React from 'react';
10
- import { connect } from 'react-redux';
11
- import Helmet from 'react-helmet';
12
- import { FormattedMessage } from 'react-intl';
13
- import { createStructuredSelector } from 'reselect';
14
- import makeSelectTestv2 from './selectors';
15
- import messages from './messages';
16
-
17
- export class Testv2 extends React.Component { // eslint-disable-line react/prefer-stateless-function
18
- render() {
19
- return (
20
- <div>
21
- <Helmet
22
- title={<FormattedMessage {...messages.testv2} />}
23
- meta={[
24
- { name: 'description', content: <FormattedMessage {...messages.descriptionTestv2} /> },
25
- ]}
26
- />
27
- <FormattedMessage {...messages.header} />
28
- </div>
29
- );
30
- }
31
- }
32
-
33
- Testv2.propTypes = {
34
- dispatch: PropTypes.func.isRequired,
35
- };
36
-
37
- const mapStateToProps = createStructuredSelector({
38
- Testv2: makeSelectTestv2(),
39
- });
40
-
41
- function mapDispatchToProps(dispatch) {
42
- return {
43
- dispatch,
44
- };
45
- }
46
-
47
- export default connect(mapStateToProps, mapDispatchToProps)(Testv2);
@@ -1,21 +0,0 @@
1
- /*
2
- * Testv2 Messages
3
- *
4
- * This contains all the text for the Testv2 component.
5
- */
6
- import { defineMessages } from 'react-intl';
7
-
8
- export default defineMessages({
9
- header: {
10
- id: 'creatives.containers.Testv2.header',
11
- defaultMessage: 'This is Testv2 container !',
12
- },
13
- testv2: {
14
- id: 'creatives.containers.Testv2.testv2',
15
- defaultMessage: 'Testv2',
16
- },
17
- descriptionTestv2: {
18
- id: 'creatives.containers.Testv2.descriptionTestv2',
19
- defaultMessage: 'Description of Testv2',
20
- },
21
- });
@@ -1,23 +0,0 @@
1
- /*
2
- *
3
- * Testv2 reducer
4
- *
5
- */
6
-
7
- import { fromJS } from 'immutable';
8
- import {
9
- DEFAULT_ACTION,
10
- } from './constants';
11
-
12
- const initialState = fromJS({});
13
-
14
- function testv2Reducer(state = initialState, action) {
15
- switch (action.type) {
16
- case DEFAULT_ACTION:
17
- return state;
18
- default:
19
- return state;
20
- }
21
- }
22
-
23
- export default testv2Reducer;
@@ -1,11 +0,0 @@
1
- // import { take, call, put, select } from 'redux-saga/effects';
2
-
3
- // Individual exports for testing
4
- export function* defaultSaga() {
5
- // See example in containers/HomePage/sagas.js
6
- }
7
-
8
- // All sagas to be loaded
9
- export default [
10
- defaultSaga,
11
- ];
@@ -1,25 +0,0 @@
1
- import { createSelector } from 'reselect';
2
-
3
- /**
4
- * Direct selector to the testv2 state domain
5
- */
6
- const selectTestv2Domain = () => (state) => state.get('testv2');
7
-
8
- /**
9
- * Other specific selectors
10
- */
11
-
12
-
13
- /**
14
- * Default selector used by Testv2
15
- */
16
-
17
- const makeSelectTestv2 = () => createSelector(
18
- selectTestv2Domain(),
19
- (substate) => substate.toJS()
20
- );
21
-
22
- export default makeSelectTestv2;
23
- export {
24
- selectTestv2Domain,
25
- };
package/store.js DELETED
@@ -1,61 +0,0 @@
1
- /**
2
- * Create the store with asynchronously loaded reducers
3
- */
4
-
5
- import { createStore, applyMiddleware, compose } from 'redux';
6
- import { fromJS } from 'immutable';
7
- import { routerMiddleware } from 'react-router-redux';
8
- import createSagaMiddleware from 'redux-saga';
9
- // import { createMiddleware } from 'redux-beacon';
10
- // import { logger } from 'redux-beacon/extensions/logger';
11
- // import { GoogleTagManager } from 'redux-beacon/targets/google-tag-manager';
12
- import createReducer from './reducers';
13
- // import eventsMap from './gtm/eventDefinitionsMap';
14
-
15
- const sagaMiddleware = createSagaMiddleware();
16
- // const gtmMiddleware = createMiddleware(eventsMap, GoogleTagManager());
17
-
18
- export default function configureStore(initialState = {}, history) {
19
- const middlewares = [
20
- sagaMiddleware,
21
- routerMiddleware(history),
22
- ];
23
-
24
- const enhancers = [
25
- applyMiddleware(...middlewares),
26
- ];
27
-
28
- // If Redux DevTools Extension is installed use it, otherwise use Redux compose
29
- /* eslint-disable no-underscore-dangle */
30
- const composeEnhancers =
31
- process.env.NODE_ENV !== 'production' &&
32
- typeof window === 'object' &&
33
- window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
34
- window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : compose;
35
- /* eslint-enable */
36
-
37
- const store = createStore(
38
- createReducer(),
39
- fromJS(initialState),
40
- composeEnhancers(...enhancers)
41
- );
42
-
43
- // Extensions
44
- store.runSaga = sagaMiddleware.run;
45
- store.asyncReducers = {}; // Async reducer registry
46
-
47
- // Make reducers hot reloadable, see http://mxs.is/googmo
48
- /* istanbul ignore next */
49
- if (module.hot) {
50
- module.hot.accept('./reducers', () => {
51
- import('./reducers').then((reducerModule) => {
52
- const createReducers = reducerModule.default;
53
- const nextReducers = createReducers(store.asyncReducers);
54
-
55
- store.replaceReducer(nextReducers);
56
- });
57
- });
58
- }
59
-
60
- return store;
61
- }
@@ -1,173 +0,0 @@
1
- /**
2
- * Test async injectors
3
- */
4
-
5
- import { memoryHistory } from 'react-router';
6
- import { put } from 'redux-saga/effects';
7
- import { fromJS } from 'immutable';
8
-
9
- import configureStore from 'store';
10
-
11
- import {
12
- injectAsyncReducer,
13
- injectAsyncSagas,
14
- getAsyncInjectors,
15
- } from '../asyncInjectors';
16
-
17
- // Fixtures
18
-
19
- const initialState = fromJS({ reduced: 'soon' });
20
-
21
- const reducer = (state = initialState, action) => {
22
- switch (action.type) {
23
- case 'TEST':
24
- return state.set('reduced', action.payload);
25
- default:
26
- return state;
27
- }
28
- };
29
-
30
- function* testSaga() {
31
- yield put({ type: 'TEST', payload: 'yup' });
32
- }
33
-
34
- const sagas = [
35
- testSaga,
36
- ];
37
-
38
- describe('asyncInjectors', () => {
39
- let store;
40
-
41
- describe('getAsyncInjectors', () => {
42
- beforeAll(() => {
43
- store = configureStore({}, memoryHistory);
44
- });
45
-
46
- it('given a store, should return all async injectors', () => {
47
- const { injectReducer, injectSagas } = getAsyncInjectors(store);
48
-
49
- injectReducer('test', reducer);
50
- injectSagas(sagas);
51
-
52
- const actual = store.getState().get('test');
53
- const expected = initialState.merge({ reduced: 'yup' });
54
-
55
- expect(actual.toJS()).toEqual(expected.toJS());
56
- });
57
-
58
- it('should throw if passed invalid store shape', () => {
59
- let result = false;
60
-
61
- Reflect.deleteProperty(store, 'dispatch');
62
-
63
- try {
64
- getAsyncInjectors(store);
65
- } catch (err) {
66
- result = err.name === 'Invariant Violation';
67
- }
68
-
69
- expect(result).toEqual(true);
70
- });
71
- });
72
-
73
- describe('helpers', () => {
74
- beforeAll(() => {
75
- store = configureStore({}, memoryHistory);
76
- });
77
-
78
- describe('injectAsyncReducer', () => {
79
- it('given a store, it should provide a function to inject a reducer', () => {
80
- const injectReducer = injectAsyncReducer(store);
81
-
82
- injectReducer('test', reducer);
83
-
84
- const actual = store.getState().get('test');
85
- const expected = initialState;
86
-
87
- expect(actual.toJS()).toEqual(expected.toJS());
88
- });
89
-
90
- it('should not assign reducer if already existing', () => {
91
- const injectReducer = injectAsyncReducer(store);
92
-
93
- injectReducer('test', reducer);
94
- injectReducer('test', () => {});
95
-
96
- expect(store.asyncReducers.test.toString()).toEqual(reducer.toString());
97
- });
98
-
99
- it('should throw if passed invalid name', () => {
100
- let result = false;
101
-
102
- const injectReducer = injectAsyncReducer(store);
103
-
104
- try {
105
- injectReducer('', reducer);
106
- } catch (err) {
107
- result = err.name === 'Invariant Violation';
108
- }
109
-
110
- try {
111
- injectReducer(999, reducer);
112
- } catch (err) {
113
- result = err.name === 'Invariant Violation';
114
- }
115
-
116
- expect(result).toEqual(true);
117
- });
118
-
119
- it('should throw if passed invalid reducer', () => {
120
- let result = false;
121
-
122
- const injectReducer = injectAsyncReducer(store);
123
-
124
- try {
125
- injectReducer('bad', 'nope');
126
- } catch (err) {
127
- result = err.name === 'Invariant Violation';
128
- }
129
-
130
- try {
131
- injectReducer('coolio', 12345);
132
- } catch (err) {
133
- result = err.name === 'Invariant Violation';
134
- }
135
-
136
- expect(result).toEqual(true);
137
- });
138
- });
139
-
140
- describe('injectAsyncSagas', () => {
141
- it('given a store, it should provide a function to inject a saga', () => {
142
- const injectSagas = injectAsyncSagas(store);
143
-
144
- injectSagas(sagas);
145
-
146
- const actual = store.getState().get('test');
147
- const expected = initialState.merge({ reduced: 'yup' });
148
-
149
- expect(actual.toJS()).toEqual(expected.toJS());
150
- });
151
-
152
- it('should throw if passed invalid saga', () => {
153
- let result = false;
154
-
155
- const injectSagas = injectAsyncSagas(store);
156
-
157
- try {
158
- injectSagas({ testSaga });
159
- } catch (err) {
160
- result = err.name === 'Invariant Violation';
161
- }
162
-
163
- try {
164
- injectSagas(testSaga);
165
- } catch (err) {
166
- result = err.name === 'Invariant Violation';
167
- }
168
-
169
- expect(result).toEqual(true);
170
- });
171
- });
172
- });
173
- });
@@ -1,7 +0,0 @@
1
- /*
2
- *
3
- * Dashboard constants
4
- *
5
- */
6
-
7
- export const DEFAULT_ACTION = 'app/v2Containers/TestPage/DEFAULT_ACTION';
@@ -1,31 +0,0 @@
1
-
2
- import React from "react";
3
- import SmsTest from '../../v2Components/SmsTest';
4
-
5
- export default class TestPage extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function
6
- render() {
7
- return (
8
- <SmsTest />
9
- );
10
- }
11
- }
12
-
13
- // const schema = {
14
- // title: "Todo",
15
- // type: "object",
16
- // required: ["title"],
17
- // properties: {
18
- // title: {type: "string", title: "Title", default: "A new task"},
19
- // done: {type: "boolean", title: "Done?", default: false},
20
- // },
21
- // };
22
-
23
- // const log = (type) => console.log.bind(console, type);
24
-
25
- // render((
26
- // <div>
27
- // <SmsTest
28
- // />
29
- // </div>
30
- // ), document.getElementById("app"));
31
- //export default TestPage;
@@ -1,13 +0,0 @@
1
- /*
2
- * NotFoundPage Messages
3
- *
4
- * This contains all the text for the NotFoundPage component.
5
- */
6
- import { defineMessages } from 'react-intl';
7
-
8
- export default defineMessages({
9
- header: {
10
- id: 'creatives.containersV2.TestPage.header',
11
- defaultMessage: 'Looks like youas are lost!',
12
- },
13
- });
@@ -1,21 +0,0 @@
1
- /*
2
- *
3
- * Dashboard reducer
4
- *
5
- */
6
-
7
- import { fromJS } from 'immutable';
8
- import { DEFAULT_ACTION } from './constants';
9
-
10
- const initialState = fromJS({});
11
-
12
- function TestPageReducer(state = initialState, action) {
13
- switch (action.type) {
14
- case DEFAULT_ACTION:
15
- return state;
16
- default:
17
- return state;
18
- }
19
- }
20
-
21
- export default TestPageReducer;
@@ -1,11 +0,0 @@
1
- // import { take, call, put, select } from 'redux-saga/effects';
2
-
3
- // Individual exports for testing
4
- export function* defaultSaga() {
5
- // See example in v2Containers/HomePage/sagas.js
6
- }
7
-
8
- // All sagas to be loaded
9
- export default [
10
- defaultSaga,
11
- ];
@@ -1,15 +0,0 @@
1
- /*
2
- *
3
- * Testv2 actions
4
- *
5
- */
6
-
7
- import {
8
- DEFAULT_ACTION,
9
- } from './constants';
10
-
11
- export function defaultAction() {
12
- return {
13
- type: DEFAULT_ACTION,
14
- };
15
- }
@@ -1,7 +0,0 @@
1
- /*
2
- *
3
- * Testv2 constants
4
- *
5
- */
6
-
7
- export const DEFAULT_ACTION = 'app/Testv2/DEFAULT_ACTION';
@@ -1,47 +0,0 @@
1
- /*
2
- *
3
- * Testv2
4
- *
5
- */
6
-
7
- import PropTypes from 'prop-types';
8
-
9
- import React from 'react';
10
- import { connect } from 'react-redux';
11
- import Helmet from 'react-helmet';
12
- import { FormattedMessage } from 'react-intl';
13
- import { createStructuredSelector } from 'reselect';
14
- import makeSelectTestv2 from './selectors';
15
- import messages from './messages';
16
-
17
- export class Testv2 extends React.Component { // eslint-disable-line react/prefer-stateless-function
18
- render() {
19
- return (
20
- <div>
21
- <Helmet
22
- title={<FormattedMessage {...messages.testv2} />}
23
- meta={[
24
- { name: 'description', content: <FormattedMessage {...messages.descriptionTestv2} /> },
25
- ]}
26
- />
27
- <FormattedMessage {...messages.header} />
28
- </div>
29
- );
30
- }
31
- }
32
-
33
- Testv2.propTypes = {
34
- dispatch: PropTypes.func.isRequired,
35
- };
36
-
37
- const mapStateToProps = createStructuredSelector({
38
- Testv2: makeSelectTestv2(),
39
- });
40
-
41
- function mapDispatchToProps(dispatch) {
42
- return {
43
- dispatch,
44
- };
45
- }
46
-
47
- export default connect(mapStateToProps, mapDispatchToProps)(Testv2);
@@ -1,21 +0,0 @@
1
- /*
2
- * Testv2 Messages
3
- *
4
- * This contains all the text for the Testv2 component.
5
- */
6
- import { defineMessages } from 'react-intl';
7
-
8
- export default defineMessages({
9
- header: {
10
- id: 'creatives.containersV2.Testv2.header',
11
- defaultMessage: 'This is Testv2 container !',
12
- },
13
- testv2: {
14
- id: 'creatives.containersV2.Testv2.testv2',
15
- defaultMessage: 'Testv2',
16
- },
17
- descriptionTestv2: {
18
- id: 'creatives.containersV2.Testv2.descriptionTestv2',
19
- defaultMessage: 'Description of Testv2',
20
- },
21
- });
@@ -1,23 +0,0 @@
1
- /*
2
- *
3
- * Testv2 reducer
4
- *
5
- */
6
-
7
- import { fromJS } from 'immutable';
8
- import {
9
- DEFAULT_ACTION,
10
- } from './constants';
11
-
12
- const initialState = fromJS({});
13
-
14
- function testv2Reducer(state = initialState, action) {
15
- switch (action.type) {
16
- case DEFAULT_ACTION:
17
- return state;
18
- default:
19
- return state;
20
- }
21
- }
22
-
23
- export default testv2Reducer;
@@ -1,11 +0,0 @@
1
- // import { take, call, put, select } from 'redux-saga/effects';
2
-
3
- // Individual exports for testing
4
- export function* defaultSaga() {
5
- // See example in v2Containers/HomePage/sagas.js
6
- }
7
-
8
- // All sagas to be loaded
9
- export default [
10
- defaultSaga,
11
- ];
@@ -1,25 +0,0 @@
1
- import { createSelector } from 'reselect';
2
-
3
- /**
4
- * Direct selector to the testv2 state domain
5
- */
6
- const selectTestv2Domain = () => (state) => state.get('testv2');
7
-
8
- /**
9
- * Other specific selectors
10
- */
11
-
12
-
13
- /**
14
- * Default selector used by Testv2
15
- */
16
-
17
- const makeSelectTestv2 = () => createSelector(
18
- selectTestv2Domain(),
19
- (substate) => substate.toJS()
20
- );
21
-
22
- export default makeSelectTestv2;
23
- export {
24
- selectTestv2Domain,
25
- };