@capillarytech/creatives-library 8.0.43-alpha.1 → 8.0.45
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/containers/Cap/sagas.js +15 -10
- package/containers/Cap/tests/saga.test.js +13 -10
- package/hoc/withCreatives.js +2 -3
- package/package.json +1 -1
- package/v2Components/Ckeditor/index.js +1 -0
- package/v2Components/NavigationBar/index.js +5 -7
- package/v2Containers/Cap/index.js +7 -0
- package/v2Containers/Cap/sagas.js +4 -2
- package/v2Containers/CreativesContainer/index.js +154 -110
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +5 -5
- package/v2Containers/Facebook/index.js +1 -1
- package/v2Containers/Line/Container/index.js +3 -10
- package/v2Containers/MobilePush/Create/index.js +1 -1
- package/v2Containers/MobilePush/Edit/sagas.js +12 -25
- package/v2Containers/Sms/Create/actions.js +0 -1
- package/v2Containers/Sms/Edit/actions.js +0 -1
- package/v2Containers/Sms/Edit/index.js +0 -3
- package/v2Containers/Templates/actions.js +0 -2
- package/v2Containers/Templates/index.js +3 -6
- package/v2Containers/Templates/reducer.js +6 -13
- package/v2Containers/Templates/sagas.js +2 -2
- package/v2Containers/TemplatesV2/index.js +0 -4
- package/v2Containers/WeChat/MapTemplates/sagas.js +11 -22
- package/v2Containers/Zalo/index.js +0 -4
package/containers/Cap/sagas.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
fork, take, call, put, cancelled, takeLatest, all,
|
|
3
|
+
cancel,
|
|
3
4
|
} from 'redux-saga/effects';
|
|
4
5
|
import { getRedirectionUrl } from '@capillarytech/cap-ui-utils/utils/logoutUtil';
|
|
5
6
|
// import { normalize } from 'normalizr';
|
|
@@ -26,7 +27,7 @@ export function* authorize(user) {
|
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
function* switchOrg({orgID}) {
|
|
30
|
+
function* switchOrg({ orgID }) {
|
|
30
31
|
try {
|
|
31
32
|
LocalStorage.saveItem('orgID', orgID);
|
|
32
33
|
const res = yield call(Api.changeProxyOrg, orgID);
|
|
@@ -39,11 +40,12 @@ function* switchOrg({orgID}) {
|
|
|
39
40
|
export function* loginFlow() {
|
|
40
41
|
let condition = true;
|
|
41
42
|
while (condition) {
|
|
42
|
-
const {user} = yield take(types.LOGIN_REQUEST);
|
|
43
|
-
yield fork(authorize, user);
|
|
43
|
+
const { user } = yield take(types.LOGIN_REQUEST);
|
|
44
|
+
const task = yield fork(authorize, user);
|
|
44
45
|
const action = yield take([types.LOGOUT_REQUEST, types.LOGIN_FAILURE]);
|
|
45
46
|
if (action.type === types.LOGOUT_REQUEST) {
|
|
46
47
|
condition = false;
|
|
48
|
+
yield cancel(task);
|
|
47
49
|
}
|
|
48
50
|
// yield call(LocalStorage.clearItem, 'token');
|
|
49
51
|
// yield call(LocalStorage.clearItem, 'orgID');
|
|
@@ -58,7 +60,7 @@ export function* logoutFlow() {
|
|
|
58
60
|
const redirectUrl = getRedirectionUrl({
|
|
59
61
|
redirectUri: serverLogout?.redirectUri,
|
|
60
62
|
});
|
|
61
|
-
yield put({type: types.LOGOUT_SUCCESS});
|
|
63
|
+
yield put({ type: types.LOGOUT_SUCCESS });
|
|
62
64
|
yield call(LocalStorage.clearItem, 'token');
|
|
63
65
|
yield call(LocalStorage.clearItem, 'orgID');
|
|
64
66
|
yield call(LocalStorage.clearItem, 'user');
|
|
@@ -76,7 +78,7 @@ export function* fetchUserInfo({ callback }) {
|
|
|
76
78
|
const userData = result.user;
|
|
77
79
|
// const orgId = yield select(makeSelectOrgId());
|
|
78
80
|
// yield put({type: types.GET_ORG_DETAILS_REQUEST, orgId});
|
|
79
|
-
const currentOrgDetails = result
|
|
81
|
+
const { currentOrgDetails } = result;
|
|
80
82
|
if (!(currentOrgDetails && currentOrgDetails.basic_details && currentOrgDetails.basic_details.base_language && (currentOrgDetails.basic_details.base_language !== "" || currentOrgDetails.basic_details.base_language === null))) {
|
|
81
83
|
currentOrgDetails.basic_details.base_language = 'en';
|
|
82
84
|
}
|
|
@@ -94,7 +96,9 @@ export function* fetchUserInfo({ callback }) {
|
|
|
94
96
|
}
|
|
95
97
|
yield call(LocalStorage.saveItem, 'orgID', result.currentOrgId);
|
|
96
98
|
yield call(LocalStorage.saveItem, 'user', userData);
|
|
97
|
-
yield put({
|
|
99
|
+
yield put({
|
|
100
|
+
type: types.GET_USER_DATA_SUCCESS, userData, currentOrgId: result.currentOrgId, currentOrgDetails,
|
|
101
|
+
});
|
|
98
102
|
} catch (error) {
|
|
99
103
|
yield call(LocalStorage.clearItem, 'user');
|
|
100
104
|
yield put({
|
|
@@ -106,11 +110,12 @@ export function* fetchUserInfo({ callback }) {
|
|
|
106
110
|
|
|
107
111
|
export function* fetchSchemaForEntity(queryParams) {
|
|
108
112
|
try {
|
|
109
|
-
|
|
110
113
|
const result = yield call(Api.fetchSchemaForEntity, queryParams);
|
|
111
|
-
|
|
114
|
+
|
|
112
115
|
// const sidebar = result.response.sidebar;
|
|
113
|
-
yield put({
|
|
116
|
+
yield put({
|
|
117
|
+
type: types.GET_SCHEMA_FOR_ENTITY_SUCCESS, data: result.response, statusCode: result.status ? result.status.code : '', entityType: queryParams.queryParams.type,
|
|
118
|
+
});
|
|
114
119
|
} catch (error) {
|
|
115
120
|
yield put({ type: types.GET_SCHEMA_FOR_ENTITY_FAILURE, error });
|
|
116
121
|
}
|
|
@@ -151,4 +156,4 @@ export function* capSaga() {
|
|
|
151
156
|
watchForFetchUserInfo(),
|
|
152
157
|
watchFetchSchemaForEntity(),
|
|
153
158
|
]);
|
|
154
|
-
}
|
|
159
|
+
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { expectSaga } from 'redux-saga-test-plan';
|
|
2
2
|
import { throwError } from 'redux-saga-test-plan/providers';
|
|
3
3
|
import * as matchers from 'redux-saga-test-plan/matchers';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
take, fork, cancel, takeLatest,
|
|
6
|
+
} from 'redux-saga/effects';
|
|
7
|
+
import {
|
|
8
|
+
authorize, loginFlow, logoutFlow, watchForLogoutFlow, capSaga,
|
|
9
|
+
} from '../sagas';
|
|
5
10
|
import * as api from '../../../services/api';
|
|
6
|
-
import { take, fork, cancel, takeLatest } from 'redux-saga/effects';
|
|
7
11
|
import {
|
|
8
12
|
LOGIN_REQUEST,
|
|
9
13
|
LOGIN_FAILURE,
|
|
@@ -11,7 +15,7 @@ import {
|
|
|
11
15
|
LOGOUT_SUCCESS,
|
|
12
16
|
LOGOUT_FAILURE,
|
|
13
17
|
} from '../constants';
|
|
14
|
-
|
|
18
|
+
|
|
15
19
|
const error = new Error('error');
|
|
16
20
|
|
|
17
21
|
describe('capSaga', () => {
|
|
@@ -24,22 +28,21 @@ describe('loginFlow', () => {
|
|
|
24
28
|
it('should handle the login flow', () => {
|
|
25
29
|
const generator = loginFlow();
|
|
26
30
|
const user = { username: 'testuser', password: 'password123' };
|
|
27
|
-
|
|
31
|
+
let task;
|
|
28
32
|
// First iteration
|
|
29
33
|
expect(generator.next().value).toEqual(take(LOGIN_REQUEST));
|
|
30
34
|
expect(generator.next({ user }).value).toEqual(fork(authorize, user));
|
|
31
|
-
|
|
32
|
-
try{
|
|
35
|
+
task = generator.next().value; // Assign the task value
|
|
36
|
+
try {
|
|
33
37
|
const failureAction = { type: LOGIN_FAILURE };
|
|
34
38
|
|
|
35
|
-
|
|
39
|
+
expect(generator.next(logoutAction).value).toEqual(cancel(task));
|
|
36
40
|
|
|
37
41
|
// When LOGIN_FAILURE action is dispatched
|
|
38
42
|
expect(generator.next(failureAction).value).toEqual(take(LOGIN_REQUEST));
|
|
39
43
|
expect(generator.next().value).toEqual(fork(authorize, user));
|
|
40
44
|
expect(generator.next().done).toBe(true);
|
|
41
|
-
}
|
|
42
|
-
catch{}
|
|
45
|
+
} catch {}
|
|
43
46
|
});
|
|
44
47
|
});
|
|
45
48
|
describe('logoutFlow [Unit Test]', () => {
|
|
@@ -113,4 +116,4 @@ describe('logoutFlow [Unit Test]', () => {
|
|
|
113
116
|
);
|
|
114
117
|
});
|
|
115
118
|
});
|
|
116
|
-
});
|
|
119
|
+
});
|
package/hoc/withCreatives.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
2
|
import { connect } from 'react-redux';
|
|
3
|
-
import { bindActionCreators } from 'redux';
|
|
3
|
+
import { bindActionCreators, compose } from 'redux';
|
|
4
4
|
import { injectIntl } from 'react-intl';
|
|
5
5
|
import * as globalActions from '../v2Containers/Cap/actions';
|
|
6
6
|
import * as creativesContainerActions from '../v2Containers/CreativesContainer/actions';
|
|
7
7
|
import { UserIsAuthenticated } from '../utils/authWrapper';
|
|
8
|
-
import { compose } from 'redux';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Higher Order Component to common out creatives channel logic
|
|
@@ -19,7 +18,7 @@ export default ({
|
|
|
19
18
|
userAuth,
|
|
20
19
|
sagas = [],
|
|
21
20
|
reducers = [],
|
|
22
|
-
|
|
21
|
+
}) => {
|
|
23
22
|
const CreativesCommon = (props) => {
|
|
24
23
|
useEffect(() => {
|
|
25
24
|
const {
|
package/package.json
CHANGED
|
@@ -8,12 +8,13 @@ import React from 'react';
|
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import styled from 'styled-components';
|
|
10
10
|
import { compose } from 'redux';
|
|
11
|
-
import injectSaga from '../../utils/injectSaga';
|
|
12
|
-
import sagas from './saga';
|
|
13
11
|
import { loadItem } from 'services/localStorageApi';
|
|
14
12
|
import { intlShape, injectIntl } from 'react-intl';
|
|
15
13
|
import { withRouter } from 'react-router-dom';
|
|
16
14
|
import { get } from 'lodash';
|
|
15
|
+
import CapNavigation from '@capillarytech/cap-ui-library/CapNavigation';
|
|
16
|
+
import injectSaga from '../../utils/injectSaga';
|
|
17
|
+
import sagas from './saga';
|
|
17
18
|
import messages from './messages';
|
|
18
19
|
import { LOYALTY } from '../../v2Containers/App/constants';
|
|
19
20
|
import {
|
|
@@ -23,7 +24,6 @@ import {
|
|
|
23
24
|
DEFAULT_MODULE,
|
|
24
25
|
AI_DOCUMENTATION_BOT_DISABLED,
|
|
25
26
|
} from '../../v2Containers/Cap/constants';
|
|
26
|
-
import CapNavigation from '@capillarytech/cap-ui-library/CapNavigation';
|
|
27
27
|
import configPath from '../../config/path';
|
|
28
28
|
import * as Api from '../../services/api';
|
|
29
29
|
import { CapLeftNavigatioOpenCss, CapLeftNavigationCss } from './style';
|
|
@@ -118,7 +118,6 @@ export class NavigationBar extends React.Component {
|
|
|
118
118
|
ICONS.push(settingsIcon);
|
|
119
119
|
}
|
|
120
120
|
return showDocumentationBot ? ICONS.slice(1) : ICONS; // If showDocumentationBot is true, help icon will be replaced by Aira icon on UI
|
|
121
|
-
|
|
122
121
|
};
|
|
123
122
|
|
|
124
123
|
getDropdownMenu = () => {
|
|
@@ -148,12 +147,11 @@ export class NavigationBar extends React.Component {
|
|
|
148
147
|
const { location, intl: { formatMessage } } = this.props;
|
|
149
148
|
const { pathname } = location;
|
|
150
149
|
const parentModule = pathname.substring(pathname.lastIndexOf('/') + 1);
|
|
151
|
-
switch (parentModule) {
|
|
150
|
+
switch (parentModule) {
|
|
152
151
|
case LOYALTY:
|
|
153
152
|
return formatMessage(messages.loyaltyProgram);
|
|
154
153
|
default:
|
|
155
154
|
return formatMessage(messages.selectedProductDefault)
|
|
156
|
-
|
|
157
155
|
}
|
|
158
156
|
}
|
|
159
157
|
|
|
@@ -236,5 +234,5 @@ NavigationBar.propTypes = {
|
|
|
236
234
|
leftNavbarExpandedProp: PropTypes.bool,
|
|
237
235
|
};
|
|
238
236
|
|
|
239
|
-
const withSagas = sagas.map(saga => injectSaga(saga));
|
|
237
|
+
const withSagas = sagas.map((saga) => injectSaga(saga));
|
|
240
238
|
export default compose(...withSagas)(withRouter(injectIntl(NavigationBar)));
|
|
@@ -52,6 +52,8 @@ import { v2RcsSagas } from '../Rcs/sagas';
|
|
|
52
52
|
import { v2InAppSagas } from '../InApp/sagas';
|
|
53
53
|
import { v2ViberSagas } from '../Viber/sagas';
|
|
54
54
|
import { v2FacebookSagas } from '../Facebook/sagas';
|
|
55
|
+
import { v2ZaloSagas } from '../Zalo/saga';
|
|
56
|
+
import createReducer from '../Line/Container/reducer';
|
|
55
57
|
|
|
56
58
|
const gtm = window.dataLayer || [];
|
|
57
59
|
const {
|
|
@@ -618,7 +620,10 @@ const withWechatMapTemplatesSaga = injectSaga({ key: 'weChatMapTemplate', saga:
|
|
|
618
620
|
const withRcsSaga = injectSaga({ key: 'rcs', saga: v2RcsSagas });
|
|
619
621
|
const withInAppSaga = injectSaga({ key: 'inapp', saga: v2InAppSagas });
|
|
620
622
|
const withViberSaga = injectSaga({ key: 'viber', saga: v2ViberSagas });
|
|
623
|
+
const withZaloSaga = injectSaga({ key: 'zaloSaga', saga: v2ZaloSagas });
|
|
621
624
|
const withFacebookSaga = injectSaga({ key: 'facebook', saga: v2FacebookSagas });
|
|
625
|
+
const withLineReducer = injectReducer({ key: 'lineCreate', reducer: createReducer });
|
|
626
|
+
|
|
622
627
|
export default compose(
|
|
623
628
|
withSaga,
|
|
624
629
|
withSmsCreateSaga,
|
|
@@ -631,7 +636,9 @@ export default compose(
|
|
|
631
636
|
withInAppSaga,
|
|
632
637
|
withViberSaga,
|
|
633
638
|
withFacebookSaga,
|
|
639
|
+
withZaloSaga,
|
|
634
640
|
withReducer,
|
|
635
641
|
withZaloReducer,
|
|
642
|
+
withLineReducer,
|
|
636
643
|
withConnect,
|
|
637
644
|
)(injectIntl(Cap));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
take, call, put, cancelled, takeLatest, all,
|
|
3
3
|
fork,
|
|
4
|
+
cancel,
|
|
4
5
|
} from 'redux-saga/effects';
|
|
5
6
|
// import { normalize } from 'normalizr';
|
|
6
7
|
import * as Api from '../../services/api';
|
|
@@ -47,10 +48,11 @@ export function* loginFlow() {
|
|
|
47
48
|
let condition = true;
|
|
48
49
|
while (condition) {
|
|
49
50
|
const {user} = yield take(types.LOGIN_REQUEST);
|
|
50
|
-
yield fork(authorize, user);
|
|
51
|
+
const task = yield fork(authorize, user);
|
|
51
52
|
const action = yield take([types.LOGOUT_REQUEST_V2, types.LOGIN_FAILURE]);
|
|
52
53
|
if (action.type === types.LOGOUT_REQUEST_V2) {
|
|
53
54
|
condition = false;
|
|
55
|
+
yield cancel(task);
|
|
54
56
|
}
|
|
55
57
|
// yield call(LocalStorage.clearItem, 'token');
|
|
56
58
|
// yield call(LocalStorage.clearItem, 'orgID');
|
|
@@ -274,5 +276,5 @@ export function* v2CapSagas() {
|
|
|
274
276
|
watchGetTopbarMenuData(),
|
|
275
277
|
watchForGetVideosConfig(),
|
|
276
278
|
watchLiquidEntity(),
|
|
277
|
-
])
|
|
279
|
+
]);
|
|
278
280
|
}
|