@capillarytech/creatives-library 6.10.1 → 6.10.3
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/components/CapTagList/index.js +1 -1
- package/components/Edmeditor/index.js +1 -1
- package/components/FormBuilder/index.js +0 -1
- package/containers/TagList/index.js +3 -3
- package/index.html +3 -0
- package/package.json +2 -1
- package/services/api.js +19 -4
- package/translations/en.json +117 -4
- package/translations/zh.json +113 -0
- package/v2Components/BeeEditor/index.js +263 -0
- package/v2Components/BeeEditor/index.scss +11 -0
- package/v2Components/BeeEditor/messages.js +71 -0
- package/v2Components/BeeEditor/tests/index.test.js +10 -0
- package/v2Components/CapTagList/index.js +55 -26
- package/v2Components/CmsTemplatesComponent/index.js +4 -4
- package/v2Components/Edmeditor/index.js +1 -1
- package/v2Components/EmailPreview/_emailPreview.scss +2 -2
- package/v2Components/FormBuilder/index.js +78 -43
- package/v2Containers/App/constants.js +1 -0
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +51 -51
- package/v2Containers/CreativesContainer/index.js +7 -2
- package/v2Containers/Email/constants.js +1 -0
- package/v2Containers/Email/index.js +170 -116
- package/v2Containers/Email/initialSchema.js +18 -3
- package/v2Containers/Email/sagas.js +2 -2
- package/v2Containers/Email/selectors.js +5 -0
- package/v2Containers/EmailWrapper/index.js +19 -3
- package/v2Containers/Line/Container/Image/index.js +2 -1
- package/v2Containers/Line/Container/ImageCarousel/index.js +1 -1
- package/v2Containers/Line/Container/ImageMap/index.js +20 -5
- package/v2Containers/TagList/index.js +13 -6
- package/v2Containers/Templates/actions.js +122 -117
- package/v2Containers/Templates/constants.js +49 -47
- package/v2Containers/Templates/index.js +36 -20
- package/v2Containers/Templates/messages.js +8 -0
- package/v2Containers/Templates/reducer.js +153 -145
- package/v2Containers/Templates/sagas.js +179 -179
- package/v2Containers/Templates/selectors.js +19 -1
|
@@ -1,179 +1,179 @@
|
|
|
1
|
-
import { call, put, takeLatest, take, cancel } from 'redux-saga/effects';
|
|
2
|
-
import { LOCATION_CHANGE } from 'react-router-redux';
|
|
3
|
-
// import { schema, normalize } from 'normalizr';
|
|
4
|
-
import * as Api from '../../services/api';
|
|
5
|
-
import * as types from './constants';
|
|
6
|
-
|
|
7
|
-
// Individual exports for testing
|
|
8
|
-
export function* getAllTemplates(channel, queryParams) {
|
|
9
|
-
try {
|
|
10
|
-
const result = yield call(Api.getAllTemplates, channel, queryParams);
|
|
11
|
-
const channelTemplates = (channel.channel === 'wechat') ? {templates: [...result.response.mapped, ...result.response.richmedia]} : result.response;
|
|
12
|
-
// const sidebar = result.response.sidebar;
|
|
13
|
-
if (channel.channel === 'wechat' && channel.queryParams && channel.queryParams.sortBy && channel.queryParams.sortBy.toLocaleLowerCase() === ("Most Recent").toLocaleLowerCase()) {
|
|
14
|
-
channelTemplates.templates.sort((a, b) => {
|
|
15
|
-
const dateA = new Date(a.updatedAt);
|
|
16
|
-
const dateB = new Date(b.updatedAt);
|
|
17
|
-
return dateB - dateA;
|
|
18
|
-
});
|
|
19
|
-
} else if (channel.channel === 'wechat' && channel.queryParams && channel.queryParams.sortBy && channel.queryParams.sortBy.toLocaleLowerCase() === ("Alphabetically").toLocaleLowerCase()) {
|
|
20
|
-
channelTemplates.templates.sort((a, b) => b.name - a.name);
|
|
21
|
-
}
|
|
22
|
-
yield put({ type: types.GET_ALL_TEMPLATES_SUCCESS, data: channelTemplates, weCRMTemplate: result.response.unMapped, isReset: channel.queryParams.page === 1 });
|
|
23
|
-
} catch (error) {
|
|
24
|
-
yield put({ type: types.GET_ALL_TEMPLATES_FAILURE, error });
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function* deleteTemplate(channel, id) {
|
|
29
|
-
try {
|
|
30
|
-
const result = yield call(Api.deleteTemplate, channel, id);
|
|
31
|
-
// const sidebar = result.response.sidebar;
|
|
32
|
-
yield put({ type: types.DELETE_TEMPLATE_SUCCESS, data: result.response });
|
|
33
|
-
} catch (error) {
|
|
34
|
-
yield put({ type: types.DELETE_TEMPLATE_FAILURE, error });
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function* fetchUserList() {
|
|
39
|
-
try {
|
|
40
|
-
const result = yield call(Api.getUserList);
|
|
41
|
-
yield [
|
|
42
|
-
put({
|
|
43
|
-
type: types.GET_USER_LIST_SUCCESS,
|
|
44
|
-
data: result.data.result,
|
|
45
|
-
}),
|
|
46
|
-
];
|
|
47
|
-
} catch (error) {
|
|
48
|
-
yield [
|
|
49
|
-
put({
|
|
50
|
-
type: types.GET_USER_LIST_FAILURE,
|
|
51
|
-
data: error,
|
|
52
|
-
}),
|
|
53
|
-
];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function* fetchWeCrmAccounts(action) {
|
|
58
|
-
try {
|
|
59
|
-
const result = yield call(Api.fetchWeCrmAccounts, action.source);
|
|
60
|
-
yield [
|
|
61
|
-
put({
|
|
62
|
-
type: types.GET_WECRM_ACCOUNTS_SUCCESS,
|
|
63
|
-
data: result.response,
|
|
64
|
-
}),
|
|
65
|
-
];
|
|
66
|
-
} catch (error) {
|
|
67
|
-
yield [
|
|
68
|
-
put({
|
|
69
|
-
type: types.GET_WECRM_ACCOUNTS_FAILURE,
|
|
70
|
-
data: error,
|
|
71
|
-
}),
|
|
72
|
-
];
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function* sendZippedFile({selectedFile, errorHandler, successHandler}) {
|
|
77
|
-
let errorMessage = "";
|
|
78
|
-
try {
|
|
79
|
-
const result = yield call(Api.sendZippedFile, selectedFile);
|
|
80
|
-
if (result.status.isError) {
|
|
81
|
-
errorMessage = result.message;
|
|
82
|
-
yield errorHandler(errorMessage);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
console.log("Got Result ", result);
|
|
86
|
-
console.log("Got decoded result", decodeURIComponent(result.response.metaEntity.htmlContent));
|
|
87
|
-
yield [
|
|
88
|
-
put({
|
|
89
|
-
type: types.SEND_ZIPPED_FILE_SUCCESS,
|
|
90
|
-
selectedTemplate: decodeURIComponent(result.response.metaEntity.htmlContent),
|
|
91
|
-
}),
|
|
92
|
-
];
|
|
93
|
-
yield successHandler();
|
|
94
|
-
} catch (error) {
|
|
95
|
-
yield errorHandler();
|
|
96
|
-
yield [
|
|
97
|
-
put({
|
|
98
|
-
type: types.SEND_ZIPPED_FILE_FAILURE,
|
|
99
|
-
data: errorMessage,
|
|
100
|
-
}),
|
|
101
|
-
];
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export function*
|
|
106
|
-
try {
|
|
107
|
-
console.log('saga getAllTemplates');
|
|
108
|
-
const result = yield call(Api.
|
|
109
|
-
const edmTemplates = result.response;
|
|
110
|
-
yield put({ type: types.
|
|
111
|
-
} catch (error) {
|
|
112
|
-
yield put({ type: types.
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export function* getTemplateDetails(id, channel) {
|
|
117
|
-
try {
|
|
118
|
-
console.log('saga get Template details', id);
|
|
119
|
-
const result = yield call(Api.getTemplateDetails, id, channel);
|
|
120
|
-
// const sidebar = result.response.sidebar;
|
|
121
|
-
yield put({ type: types.GET_TEMPLATE_DETAILS_SUCCESS, data: result.response });
|
|
122
|
-
} catch (error) {
|
|
123
|
-
yield put({ type: types.GET_TEMPLATE_DETAILS_FAILURE, error });
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function* watchGetAllTemplates() {
|
|
128
|
-
const watcher = yield takeLatest(types.GET_ALL_TEMPLATES_REQUEST, getAllTemplates);
|
|
129
|
-
yield take(LOCATION_CHANGE);
|
|
130
|
-
yield cancel(watcher);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function* watchDeleteTemplate() {
|
|
134
|
-
const watcher = yield takeLatest(types.DELETE_TEMPLATE_REQUEST, deleteTemplate);
|
|
135
|
-
yield take(LOCATION_CHANGE);
|
|
136
|
-
yield cancel(watcher);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function* watchGetUserList() {
|
|
140
|
-
const watcher = yield takeLatest(types.GET_USER_LIST_REQUEST, fetchUserList);
|
|
141
|
-
yield take(LOCATION_CHANGE);
|
|
142
|
-
yield cancel(watcher);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function* watchFetchWeCrmAccounts() {
|
|
146
|
-
console.log('watching wecrm accounts');
|
|
147
|
-
const watcher = yield takeLatest(types.GET_WECRM_ACCOUNTS_REQUEST, fetchWeCrmAccounts);
|
|
148
|
-
yield take(LOCATION_CHANGE);
|
|
149
|
-
yield cancel(watcher);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function* watchSendingFile() {
|
|
153
|
-
const watcher = yield takeLatest(types.SEND_ZIPPED_FILE_REQUEST, sendZippedFile);
|
|
154
|
-
yield take(LOCATION_CHANGE);
|
|
155
|
-
yield cancel(watcher);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function*
|
|
159
|
-
const watcher = yield takeLatest(types.
|
|
160
|
-
yield take(LOCATION_CHANGE);
|
|
161
|
-
yield cancel(watcher);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function* watchGetTemplateDetails() {
|
|
165
|
-
const watcher = yield takeLatest(types.GET_TEMPLATE_DETAILS_REQUEST, getTemplateDetails);
|
|
166
|
-
yield take(LOCATION_CHANGE);
|
|
167
|
-
yield cancel(watcher);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// All sagas to be loaded
|
|
171
|
-
export default [
|
|
172
|
-
watchGetAllTemplates,
|
|
173
|
-
watchDeleteTemplate,
|
|
174
|
-
watchGetUserList,
|
|
175
|
-
watchFetchWeCrmAccounts,
|
|
176
|
-
watchSendingFile,
|
|
177
|
-
|
|
178
|
-
watchGetTemplateDetails,
|
|
179
|
-
];
|
|
1
|
+
import { call, put, takeLatest, take, cancel } from 'redux-saga/effects';
|
|
2
|
+
import { LOCATION_CHANGE } from 'react-router-redux';
|
|
3
|
+
// import { schema, normalize } from 'normalizr';
|
|
4
|
+
import * as Api from '../../services/api';
|
|
5
|
+
import * as types from './constants';
|
|
6
|
+
|
|
7
|
+
// Individual exports for testing
|
|
8
|
+
export function* getAllTemplates(channel, queryParams) {
|
|
9
|
+
try {
|
|
10
|
+
const result = yield call(Api.getAllTemplates, channel, queryParams);
|
|
11
|
+
const channelTemplates = (channel.channel === 'wechat') ? {templates: [...result.response.mapped, ...result.response.richmedia]} : result.response;
|
|
12
|
+
// const sidebar = result.response.sidebar;
|
|
13
|
+
if (channel.channel === 'wechat' && channel.queryParams && channel.queryParams.sortBy && channel.queryParams.sortBy.toLocaleLowerCase() === ("Most Recent").toLocaleLowerCase()) {
|
|
14
|
+
channelTemplates.templates.sort((a, b) => {
|
|
15
|
+
const dateA = new Date(a.updatedAt);
|
|
16
|
+
const dateB = new Date(b.updatedAt);
|
|
17
|
+
return dateB - dateA;
|
|
18
|
+
});
|
|
19
|
+
} else if (channel.channel === 'wechat' && channel.queryParams && channel.queryParams.sortBy && channel.queryParams.sortBy.toLocaleLowerCase() === ("Alphabetically").toLocaleLowerCase()) {
|
|
20
|
+
channelTemplates.templates.sort((a, b) => b.name - a.name);
|
|
21
|
+
}
|
|
22
|
+
yield put({ type: types.GET_ALL_TEMPLATES_SUCCESS, data: channelTemplates, weCRMTemplate: result.response.unMapped, isReset: channel.queryParams.page === 1 });
|
|
23
|
+
} catch (error) {
|
|
24
|
+
yield put({ type: types.GET_ALL_TEMPLATES_FAILURE, error });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function* deleteTemplate(channel, id) {
|
|
29
|
+
try {
|
|
30
|
+
const result = yield call(Api.deleteTemplate, channel, id);
|
|
31
|
+
// const sidebar = result.response.sidebar;
|
|
32
|
+
yield put({ type: types.DELETE_TEMPLATE_SUCCESS, data: result.response });
|
|
33
|
+
} catch (error) {
|
|
34
|
+
yield put({ type: types.DELETE_TEMPLATE_FAILURE, error });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function* fetchUserList() {
|
|
39
|
+
try {
|
|
40
|
+
const result = yield call(Api.getUserList);
|
|
41
|
+
yield [
|
|
42
|
+
put({
|
|
43
|
+
type: types.GET_USER_LIST_SUCCESS,
|
|
44
|
+
data: result.data.result,
|
|
45
|
+
}),
|
|
46
|
+
];
|
|
47
|
+
} catch (error) {
|
|
48
|
+
yield [
|
|
49
|
+
put({
|
|
50
|
+
type: types.GET_USER_LIST_FAILURE,
|
|
51
|
+
data: error,
|
|
52
|
+
}),
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function* fetchWeCrmAccounts(action) {
|
|
58
|
+
try {
|
|
59
|
+
const result = yield call(Api.fetchWeCrmAccounts, action.source);
|
|
60
|
+
yield [
|
|
61
|
+
put({
|
|
62
|
+
type: types.GET_WECRM_ACCOUNTS_SUCCESS,
|
|
63
|
+
data: result.response,
|
|
64
|
+
}),
|
|
65
|
+
];
|
|
66
|
+
} catch (error) {
|
|
67
|
+
yield [
|
|
68
|
+
put({
|
|
69
|
+
type: types.GET_WECRM_ACCOUNTS_FAILURE,
|
|
70
|
+
data: error,
|
|
71
|
+
}),
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function* sendZippedFile({selectedFile, errorHandler, successHandler}) {
|
|
77
|
+
let errorMessage = "";
|
|
78
|
+
try {
|
|
79
|
+
const result = yield call(Api.sendZippedFile, selectedFile);
|
|
80
|
+
if (result.status.isError) {
|
|
81
|
+
errorMessage = result.message;
|
|
82
|
+
yield errorHandler(errorMessage);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
console.log("Got Result ", result);
|
|
86
|
+
console.log("Got decoded result", decodeURIComponent(result.response.metaEntity.htmlContent));
|
|
87
|
+
yield [
|
|
88
|
+
put({
|
|
89
|
+
type: types.SEND_ZIPPED_FILE_SUCCESS,
|
|
90
|
+
selectedTemplate: decodeURIComponent(result.response.metaEntity.htmlContent),
|
|
91
|
+
}),
|
|
92
|
+
];
|
|
93
|
+
yield successHandler();
|
|
94
|
+
} catch (error) {
|
|
95
|
+
yield errorHandler();
|
|
96
|
+
yield [
|
|
97
|
+
put({
|
|
98
|
+
type: types.SEND_ZIPPED_FILE_FAILURE,
|
|
99
|
+
data: errorMessage,
|
|
100
|
+
}),
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function* getDefaultBeeTemplates() {
|
|
106
|
+
try {
|
|
107
|
+
console.log('saga getAllTemplates');
|
|
108
|
+
const result = yield call(Api.getDefaultBeeTemplates);
|
|
109
|
+
const edmTemplates = result.response;
|
|
110
|
+
yield put({ type: types.GET_DEAFULT_BEE_TEMPLATES_SUCCESS, data: edmTemplates });
|
|
111
|
+
} catch (error) {
|
|
112
|
+
yield put({ type: types.GET_DEAFULT_BEE_TEMPLATES_FAILURE, error });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function* getTemplateDetails(id, channel) {
|
|
117
|
+
try {
|
|
118
|
+
console.log('saga get Template details', id);
|
|
119
|
+
const result = yield call(Api.getTemplateDetails, id, channel);
|
|
120
|
+
// const sidebar = result.response.sidebar;
|
|
121
|
+
yield put({ type: types.GET_TEMPLATE_DETAILS_SUCCESS, data: result.response });
|
|
122
|
+
} catch (error) {
|
|
123
|
+
yield put({ type: types.GET_TEMPLATE_DETAILS_FAILURE, error });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function* watchGetAllTemplates() {
|
|
128
|
+
const watcher = yield takeLatest(types.GET_ALL_TEMPLATES_REQUEST, getAllTemplates);
|
|
129
|
+
yield take(LOCATION_CHANGE);
|
|
130
|
+
yield cancel(watcher);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function* watchDeleteTemplate() {
|
|
134
|
+
const watcher = yield takeLatest(types.DELETE_TEMPLATE_REQUEST, deleteTemplate);
|
|
135
|
+
yield take(LOCATION_CHANGE);
|
|
136
|
+
yield cancel(watcher);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function* watchGetUserList() {
|
|
140
|
+
const watcher = yield takeLatest(types.GET_USER_LIST_REQUEST, fetchUserList);
|
|
141
|
+
yield take(LOCATION_CHANGE);
|
|
142
|
+
yield cancel(watcher);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function* watchFetchWeCrmAccounts() {
|
|
146
|
+
console.log('watching wecrm accounts');
|
|
147
|
+
const watcher = yield takeLatest(types.GET_WECRM_ACCOUNTS_REQUEST, fetchWeCrmAccounts);
|
|
148
|
+
yield take(LOCATION_CHANGE);
|
|
149
|
+
yield cancel(watcher);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function* watchSendingFile() {
|
|
153
|
+
const watcher = yield takeLatest(types.SEND_ZIPPED_FILE_REQUEST, sendZippedFile);
|
|
154
|
+
yield take(LOCATION_CHANGE);
|
|
155
|
+
yield cancel(watcher);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function* watchGetDefaultBeeTemplates() {
|
|
159
|
+
const watcher = yield takeLatest(types.GET_DEAFULT_BEE_TEMPLATES_REQUEST, getDefaultBeeTemplates);
|
|
160
|
+
yield take(LOCATION_CHANGE);
|
|
161
|
+
yield cancel(watcher);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function* watchGetTemplateDetails() {
|
|
165
|
+
const watcher = yield takeLatest(types.GET_TEMPLATE_DETAILS_REQUEST, getTemplateDetails);
|
|
166
|
+
yield take(LOCATION_CHANGE);
|
|
167
|
+
yield cancel(watcher);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// All sagas to be loaded
|
|
171
|
+
export default [
|
|
172
|
+
watchGetAllTemplates,
|
|
173
|
+
watchDeleteTemplate,
|
|
174
|
+
watchGetUserList,
|
|
175
|
+
watchFetchWeCrmAccounts,
|
|
176
|
+
watchSendingFile,
|
|
177
|
+
watchGetDefaultBeeTemplates,
|
|
178
|
+
watchGetTemplateDetails,
|
|
179
|
+
];
|
|
@@ -57,12 +57,30 @@ const selectCmsTemplates = () => createSelector(makeSelectTemplates(), (template
|
|
|
57
57
|
return null;
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
+
const selectCmsTemplatesLoader = () => createSelector(
|
|
61
|
+
makeSelectTemplates(),
|
|
62
|
+
(templates) => templates.getCmsTemplatesInProgress,
|
|
63
|
+
);
|
|
64
|
+
|
|
60
65
|
const selectEdmEditor = () => createSelector(makeSelectTemplates(), (templates) => {
|
|
61
66
|
const {edmTemplate} = templates;
|
|
62
67
|
return edmTemplate || null;
|
|
63
68
|
});
|
|
69
|
+
|
|
70
|
+
const selectBEEEditor = () => createSelector(makeSelectTemplates(), (templates) => {
|
|
71
|
+
const {BEETemplate} = templates;
|
|
72
|
+
return BEETemplate || null;
|
|
73
|
+
});
|
|
74
|
+
|
|
64
75
|
export {
|
|
65
76
|
uploadSelector,
|
|
66
77
|
templateUserList,
|
|
67
|
-
makeSelectTemplates,
|
|
78
|
+
makeSelectTemplates,
|
|
79
|
+
makeSelectTemplatesResponse,
|
|
80
|
+
selectTemplateContent,
|
|
81
|
+
selectEmailLayout,
|
|
82
|
+
selectCmsTemplates,
|
|
83
|
+
selectEdmEditor,
|
|
84
|
+
selectBEEEditor,
|
|
85
|
+
selectCmsTemplatesLoader,
|
|
68
86
|
};
|