@imposium-hub/components 1.62.0 → 1.62.2
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/dist/cjs/components/publish-wizard/PublishWizard.js +12 -2
- package/dist/cjs/components/publish-wizard/PublishWizard.js.map +1 -1
- package/dist/cjs/components/publish-wizard/publish/EmailWorkflow.js +116 -36
- package/dist/cjs/components/publish-wizard/publish/EmailWorkflow.js.map +1 -1
- package/dist/cjs/components/story-previewer/StoryPreviewer.js +8 -4
- package/dist/cjs/components/story-previewer/StoryPreviewer.js.map +1 -1
- package/dist/cjs/constants/copy.d.ts +3 -0
- package/dist/cjs/constants/copy.js +3 -0
- package/dist/cjs/constants/copy.js.map +1 -1
- package/dist/cjs/services/API.d.ts +2 -0
- package/dist/cjs/services/API.js +23 -0
- package/dist/cjs/services/API.js.map +1 -1
- package/dist/esm/components/publish-wizard/PublishWizard.js +13 -3
- package/dist/esm/components/publish-wizard/PublishWizard.js.map +1 -1
- package/dist/esm/components/publish-wizard/publish/EmailWorkflow.js +110 -34
- package/dist/esm/components/publish-wizard/publish/EmailWorkflow.js.map +1 -1
- package/dist/esm/components/story-previewer/StoryPreviewer.js +5 -2
- package/dist/esm/components/story-previewer/StoryPreviewer.js.map +1 -1
- package/dist/esm/constants/copy.d.ts +3 -0
- package/dist/esm/constants/copy.js +3 -0
- package/dist/esm/constants/copy.js.map +1 -1
- package/dist/esm/services/API.d.ts +2 -0
- package/dist/esm/services/API.js +19 -0
- package/dist/esm/services/API.js.map +1 -1
- package/package.json +1 -1
- package/src/components/publish-wizard/PublishWizard.tsx +31 -1
- package/src/components/publish-wizard/publish/EmailWorkflow.tsx +147 -42
- package/src/components/story-previewer/StoryPreviewer.tsx +7 -2
- package/src/constants/copy.ts +4 -0
- package/src/services/API.ts +36 -0
|
@@ -16,6 +16,7 @@ import { CRM_PLACEMENT_VARS } from '../../../constants/publish';
|
|
|
16
16
|
|
|
17
17
|
interface IEmailWorkflowProps {
|
|
18
18
|
story: any;
|
|
19
|
+
activeDataset: any;
|
|
19
20
|
variables: any;
|
|
20
21
|
createFreshBatch: (e: string) => any;
|
|
21
22
|
getBatches: () => any;
|
|
@@ -23,7 +24,6 @@ interface IEmailWorkflowProps {
|
|
|
23
24
|
importBatchFromCsv: (
|
|
24
25
|
storyId: string,
|
|
25
26
|
batchId: string,
|
|
26
|
-
batchName: string,
|
|
27
27
|
csvFile: File,
|
|
28
28
|
accessKey: string,
|
|
29
29
|
compId: string,
|
|
@@ -31,6 +31,17 @@ interface IEmailWorkflowProps {
|
|
|
31
31
|
addMedia: boolean,
|
|
32
32
|
overrides?: any
|
|
33
33
|
) => any;
|
|
34
|
+
publishDataset: boolean;
|
|
35
|
+
activeDatasetId?: string;
|
|
36
|
+
importBatchFromDataset: (
|
|
37
|
+
batchId: string,
|
|
38
|
+
datasetId: string,
|
|
39
|
+
accessKey: string,
|
|
40
|
+
compId: string,
|
|
41
|
+
embed: boolean,
|
|
42
|
+
addMedia: boolean,
|
|
43
|
+
overrides?: any
|
|
44
|
+
) => any;
|
|
34
45
|
renderBatch: (batchId: string, postRenderActions?: any) => any;
|
|
35
46
|
status: string;
|
|
36
47
|
accessKey: string;
|
|
@@ -43,6 +54,7 @@ interface IEmailWorkflowProps {
|
|
|
43
54
|
handleError: (e) => any;
|
|
44
55
|
batchJobs: any;
|
|
45
56
|
isExport?: boolean;
|
|
57
|
+
isEmail?: boolean;
|
|
46
58
|
updateAssociation: (
|
|
47
59
|
api: IImposiumAPI,
|
|
48
60
|
colIndex: number,
|
|
@@ -78,6 +90,7 @@ interface IEmailWorkflowState {
|
|
|
78
90
|
batchError: string;
|
|
79
91
|
creativeManagerOverrides: CrMOverrides;
|
|
80
92
|
waitingForPublish: boolean;
|
|
93
|
+
hasUploadDataset: boolean;
|
|
81
94
|
}
|
|
82
95
|
|
|
83
96
|
class EmailWorkflow extends React.PureComponent<IEmailWorkflowProps, IEmailWorkflowState> {
|
|
@@ -114,7 +127,8 @@ class EmailWorkflow extends React.PureComponent<IEmailWorkflowProps, IEmailWorkf
|
|
|
114
127
|
notification_email: '',
|
|
115
128
|
placement_type: 'crm-adstudio'
|
|
116
129
|
},
|
|
117
|
-
waitingForPublish: false
|
|
130
|
+
waitingForPublish: false,
|
|
131
|
+
hasUploadDataset: false
|
|
118
132
|
};
|
|
119
133
|
|
|
120
134
|
this.hiddenFileInputRef = React.createRef();
|
|
@@ -124,19 +138,20 @@ class EmailWorkflow extends React.PureComponent<IEmailWorkflowProps, IEmailWorkf
|
|
|
124
138
|
this.getInventory();
|
|
125
139
|
}
|
|
126
140
|
|
|
127
|
-
public componentDidUpdate(
|
|
128
|
-
prevProps: Readonly<IEmailWorkflowProps>,
|
|
129
|
-
prevState: Readonly<IEmailWorkflowState>
|
|
130
|
-
): void {
|
|
141
|
+
public componentDidUpdate(prevProps: Readonly<IEmailWorkflowProps>): void {
|
|
131
142
|
const {
|
|
132
143
|
activeBatch: {
|
|
133
144
|
data: { columns }
|
|
134
145
|
},
|
|
135
146
|
batchJobs: { missing },
|
|
136
|
-
publishData: { publishing }
|
|
147
|
+
publishData: { publishing },
|
|
148
|
+
publishDataset,
|
|
149
|
+
isExport,
|
|
150
|
+
isEmail,
|
|
151
|
+
isCrM
|
|
137
152
|
} = this.props;
|
|
138
153
|
|
|
139
|
-
const { waitingForPublish } = this.state;
|
|
154
|
+
const { waitingForPublish, hasUploadDataset } = this.state;
|
|
140
155
|
if (missing.length >= 0 && columns) {
|
|
141
156
|
const varArray = this.getVarArray();
|
|
142
157
|
const colArray = this.getColArray();
|
|
@@ -144,7 +159,15 @@ class EmailWorkflow extends React.PureComponent<IEmailWorkflowProps, IEmailWorkf
|
|
|
144
159
|
}
|
|
145
160
|
|
|
146
161
|
if (!publishing && prevProps.publishData.publishing && waitingForPublish) {
|
|
147
|
-
|
|
162
|
+
if (publishDataset) {
|
|
163
|
+
this.createFreshBatchFromDataset();
|
|
164
|
+
} else {
|
|
165
|
+
this.createFreshBatchFromCsv();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (((isExport && !isCrM) || isEmail) && !hasUploadDataset && publishDataset) {
|
|
170
|
+
this.doUploadDataset();
|
|
148
171
|
}
|
|
149
172
|
}
|
|
150
173
|
|
|
@@ -188,7 +211,7 @@ class EmailWorkflow extends React.PureComponent<IEmailWorkflowProps, IEmailWorkf
|
|
|
188
211
|
}
|
|
189
212
|
}
|
|
190
213
|
|
|
191
|
-
private
|
|
214
|
+
private createFreshBatchFromCsv() {
|
|
192
215
|
const { handleError } = this.props;
|
|
193
216
|
|
|
194
217
|
const file = this.hiddenFileInputRef.current.files[0];
|
|
@@ -196,9 +219,26 @@ class EmailWorkflow extends React.PureComponent<IEmailWorkflowProps, IEmailWorkf
|
|
|
196
219
|
this.props
|
|
197
220
|
.createFreshBatch(this.getBatchName())
|
|
198
221
|
.then((res) => {
|
|
199
|
-
const { id,
|
|
222
|
+
const { id, story_id } = res;
|
|
223
|
+
this.setState({ selectedBatchId: id });
|
|
224
|
+
this.importBatchFromCsv({ story_id, id, file });
|
|
225
|
+
})
|
|
226
|
+
.catch((e) => {
|
|
227
|
+
handleError(e);
|
|
228
|
+
this.setState({ uploadComplete: false, uploading: false });
|
|
229
|
+
throw e;
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
private createFreshBatchFromDataset() {
|
|
234
|
+
const { handleError } = this.props;
|
|
235
|
+
|
|
236
|
+
this.props
|
|
237
|
+
.createFreshBatch(this.getBatchName())
|
|
238
|
+
.then((res) => {
|
|
239
|
+
const { id } = res;
|
|
200
240
|
this.setState({ selectedBatchId: id });
|
|
201
|
-
this.
|
|
241
|
+
this.importBatchFromDataset({ id });
|
|
202
242
|
})
|
|
203
243
|
.catch((e) => {
|
|
204
244
|
handleError(e);
|
|
@@ -273,6 +313,24 @@ class EmailWorkflow extends React.PureComponent<IEmailWorkflowProps, IEmailWorkf
|
|
|
273
313
|
return batchName;
|
|
274
314
|
}
|
|
275
315
|
|
|
316
|
+
private doUploadDataset() {
|
|
317
|
+
const {
|
|
318
|
+
publishData: { publishing }
|
|
319
|
+
} = this.props;
|
|
320
|
+
|
|
321
|
+
this.setState({
|
|
322
|
+
uploading: true,
|
|
323
|
+
renderedBatch: false,
|
|
324
|
+
hasUploadDataset: true
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
if (publishing) {
|
|
328
|
+
this.setState({ waitingForPublish: true });
|
|
329
|
+
} else {
|
|
330
|
+
this.createFreshBatchFromDataset();
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
276
334
|
private doUploadCsv = (uploadEvt): void => {
|
|
277
335
|
const {
|
|
278
336
|
publishData: { publishing }
|
|
@@ -286,7 +344,7 @@ class EmailWorkflow extends React.PureComponent<IEmailWorkflowProps, IEmailWorkf
|
|
|
286
344
|
if (publishing) {
|
|
287
345
|
this.setState({ waitingForPublish: true });
|
|
288
346
|
} else {
|
|
289
|
-
this.
|
|
347
|
+
this.createFreshBatchFromCsv();
|
|
290
348
|
}
|
|
291
349
|
};
|
|
292
350
|
|
|
@@ -306,21 +364,42 @@ class EmailWorkflow extends React.PureComponent<IEmailWorkflowProps, IEmailWorkf
|
|
|
306
364
|
this.renderBatch({ id });
|
|
307
365
|
}
|
|
308
366
|
|
|
309
|
-
private
|
|
367
|
+
private importBatchFromCsv({ story_id, id, file }) {
|
|
310
368
|
const { accessKey, compositionId, isExport, onError } = this.props;
|
|
311
369
|
onError(false); // reset the parent error
|
|
312
370
|
this.props
|
|
313
|
-
.importBatchFromCsv(
|
|
314
|
-
|
|
371
|
+
.importBatchFromCsv(story_id, id, file, accessKey, compositionId, !isExport, isExport)
|
|
372
|
+
.then(() => {
|
|
373
|
+
if (this.props.batchJobs.missing.length > 0) {
|
|
374
|
+
onError(true); // set the error to true
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
this.setState({ uploadComplete: true, uploading: false });
|
|
378
|
+
this.getBatch();
|
|
379
|
+
|
|
380
|
+
if (isExport && Object.keys(this.props.batchJobs.missing).length === 0) {
|
|
381
|
+
this.renderBatch({ id });
|
|
382
|
+
}
|
|
383
|
+
})
|
|
384
|
+
.catch((e) => {
|
|
385
|
+
this.setState({ uploadComplete: false, uploading: false });
|
|
386
|
+
throw e;
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
private importBatchFromDataset({ id }) {
|
|
391
|
+
const { accessKey, compositionId, isExport, onError, activeDatasetId } = this.props;
|
|
392
|
+
onError(false); // reset the parent error
|
|
393
|
+
this.props
|
|
394
|
+
.importBatchFromDataset(
|
|
315
395
|
id,
|
|
316
|
-
|
|
317
|
-
file,
|
|
396
|
+
activeDatasetId,
|
|
318
397
|
accessKey,
|
|
319
398
|
compositionId,
|
|
320
399
|
!isExport,
|
|
321
400
|
isExport
|
|
322
401
|
)
|
|
323
|
-
.then((
|
|
402
|
+
.then(() => {
|
|
324
403
|
if (this.props.batchJobs.missing.length > 0) {
|
|
325
404
|
onError(true); // set the error to true
|
|
326
405
|
}
|
|
@@ -408,7 +487,7 @@ class EmailWorkflow extends React.PureComponent<IEmailWorkflowProps, IEmailWorkf
|
|
|
408
487
|
}
|
|
409
488
|
|
|
410
489
|
public renderLabel() {
|
|
411
|
-
const { isExport, batchJobs } = this.props;
|
|
490
|
+
const { isExport, batchJobs, publishDataset } = this.props;
|
|
412
491
|
const { renderedBatch, selectedBatchId, uploading, uploadComplete } = this.state;
|
|
413
492
|
|
|
414
493
|
if (
|
|
@@ -437,9 +516,11 @@ class EmailWorkflow extends React.PureComponent<IEmailWorkflowProps, IEmailWorkf
|
|
|
437
516
|
</span>
|
|
438
517
|
);
|
|
439
518
|
}
|
|
519
|
+
|
|
440
520
|
return (
|
|
441
521
|
<span>
|
|
442
|
-
{ICON_UPLOAD}
|
|
522
|
+
{ICON_UPLOAD}
|
|
523
|
+
{publishDataset ? copy.publish.uploadDataset : copy.publish.uploadCsv}
|
|
443
524
|
</span>
|
|
444
525
|
);
|
|
445
526
|
}
|
|
@@ -584,26 +665,43 @@ class EmailWorkflow extends React.PureComponent<IEmailWorkflowProps, IEmailWorkf
|
|
|
584
665
|
const {
|
|
585
666
|
isExport,
|
|
586
667
|
batchJobs: { missing, renders },
|
|
587
|
-
isCrM
|
|
668
|
+
isCrM,
|
|
669
|
+
publishDataset
|
|
588
670
|
} = this.props;
|
|
589
671
|
|
|
590
|
-
const emailOptions = [
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
672
|
+
const emailOptions = [];
|
|
673
|
+
|
|
674
|
+
const downloadSampleCsv = {
|
|
675
|
+
label: (
|
|
676
|
+
<span>
|
|
677
|
+
{ICON_DOWNLOAD} {copy.publish.downloadSampleCsvLink}
|
|
678
|
+
</span>
|
|
679
|
+
),
|
|
680
|
+
onClick: () => this.downloadSampleCsv(),
|
|
681
|
+
key: 'download-sample'
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
const selectCsv = {
|
|
685
|
+
label: this.renderLabel(),
|
|
686
|
+
onClick: () => this.selectCsv(),
|
|
687
|
+
key: 'upload',
|
|
688
|
+
disabled: isExport ? uploadComplete || uploading : uploading
|
|
689
|
+
};
|
|
690
|
+
|
|
691
|
+
const uploadDataset = {
|
|
692
|
+
label: this.renderLabel(),
|
|
693
|
+
onClick: () => this.doUploadDataset(),
|
|
694
|
+
key: 'upload',
|
|
695
|
+
disabled: isExport ? uploadComplete || uploading : uploading
|
|
696
|
+
};
|
|
697
|
+
|
|
698
|
+
if (!publishDataset) {
|
|
699
|
+
emailOptions.push(downloadSampleCsv);
|
|
700
|
+
emailOptions.push(selectCsv);
|
|
701
|
+
} else {
|
|
702
|
+
emailOptions.push(uploadDataset);
|
|
703
|
+
}
|
|
704
|
+
|
|
607
705
|
const downloadCsvLabel = downloading ? (
|
|
608
706
|
<span>
|
|
609
707
|
<Spinner />
|
|
@@ -667,11 +765,17 @@ class EmailWorkflow extends React.PureComponent<IEmailWorkflowProps, IEmailWorkf
|
|
|
667
765
|
</>
|
|
668
766
|
);
|
|
669
767
|
|
|
768
|
+
console.log(this.props.activeDataset);
|
|
769
|
+
const title = publishDataset
|
|
770
|
+
? copy.publish.datasetTitle.replace('[dataset_name]', this.props.activeDataset?.name)
|
|
771
|
+
: copy.publish.emailTitle;
|
|
772
|
+
const desc = publishDataset ? '' : copy.publish.emailDesc;
|
|
773
|
+
|
|
670
774
|
const uploadCSV = (
|
|
671
775
|
<div>
|
|
672
|
-
<h2>{
|
|
776
|
+
<h2>{title}</h2>
|
|
673
777
|
<HRule />
|
|
674
|
-
<p>{
|
|
778
|
+
<p>{desc}</p>
|
|
675
779
|
<input
|
|
676
780
|
type='file'
|
|
677
781
|
style={{ display: 'none' }}
|
|
@@ -726,7 +830,8 @@ const mapStateToProps = (state): any => {
|
|
|
726
830
|
return {
|
|
727
831
|
activeBatch: state.activeBatch,
|
|
728
832
|
batchesList: state.batchesList,
|
|
729
|
-
publishData: state.publish
|
|
833
|
+
publishData: state.publish,
|
|
834
|
+
activeDataset: state.datasets.present.activeDataset
|
|
730
835
|
};
|
|
731
836
|
};
|
|
732
837
|
|
|
@@ -133,12 +133,14 @@ class StoryPreviewer extends React.PureComponent<IStoryPreviewerProps, IStoryPre
|
|
|
133
133
|
|
|
134
134
|
private getInventoryDefaults() {
|
|
135
135
|
const { variables } = this.props;
|
|
136
|
+
const inventoryOverrides = this.props.editor?.inventoryOverrides;
|
|
136
137
|
const newInv = {};
|
|
137
138
|
|
|
138
139
|
for (const i in variables) {
|
|
139
140
|
if (variables.hasOwnProperty(i)) {
|
|
141
|
+
const override = inventoryOverrides ? inventoryOverrides[i] : null;
|
|
140
142
|
const inv = variables[i];
|
|
141
|
-
newInv[inv.id] = this.getVariableValue(inv.previewItem);
|
|
143
|
+
newInv[inv.id] = override ? override : this.getVariableValue(inv.previewItem);
|
|
142
144
|
}
|
|
143
145
|
}
|
|
144
146
|
|
|
@@ -192,7 +194,10 @@ class StoryPreviewer extends React.PureComponent<IStoryPreviewerProps, IStoryPre
|
|
|
192
194
|
this.createExperience();
|
|
193
195
|
}
|
|
194
196
|
|
|
195
|
-
if (
|
|
197
|
+
if (
|
|
198
|
+
prevProps.variables !== this.props.variables ||
|
|
199
|
+
prevProps.editor?.inventoryOverrides !== this.props.editor?.inventoryOverrides
|
|
200
|
+
) {
|
|
196
201
|
const inventoryOptions = this.getInventoryOptions();
|
|
197
202
|
const inventory = this.getInventoryDefaults();
|
|
198
203
|
|
package/src/constants/copy.ts
CHANGED
|
@@ -149,8 +149,12 @@ export const publish = {
|
|
|
149
149
|
emailTitle: 'STEP 3: Upload a CSV file with your user information in it.',
|
|
150
150
|
emailDesc:
|
|
151
151
|
'You can download a sample CSV with fields to populate as a starting point. Or you can upload one that already has the data in it.',
|
|
152
|
+
datasetTitle: 'STEP 3: Render batch using dataset: [dataset_name]',
|
|
153
|
+
datasetDesc:
|
|
154
|
+
'You can select or modified the Dataset to populate as a starting point. Or you can upload one that already has the data in it.',
|
|
152
155
|
downloadSampleCsvLink: 'Download Sample CSV',
|
|
153
156
|
uploadCsv: 'Upload Your CSV',
|
|
157
|
+
uploadDataset: 'Proceed with Dataset',
|
|
154
158
|
generatingLink: 'STEP 4: Generating embed links',
|
|
155
159
|
downloadLink: 'STEP 5: Download Your CSV file',
|
|
156
160
|
btnDownload: 'Download CSV',
|
package/src/services/API.ts
CHANGED
|
@@ -67,6 +67,14 @@ export interface IImposiumAPI {
|
|
|
67
67
|
compId?: string,
|
|
68
68
|
addMedia?: boolean
|
|
69
69
|
): Promise<any | Error>;
|
|
70
|
+
importBatchDataFromDataset(
|
|
71
|
+
batchId: string,
|
|
72
|
+
datasetId: string,
|
|
73
|
+
embed?: boolean,
|
|
74
|
+
accessKey?: string,
|
|
75
|
+
compId?: string,
|
|
76
|
+
addMedia?: boolean
|
|
77
|
+
): Promise<any | Error>;
|
|
70
78
|
updateBatchColumns(batchId: string, columns: any);
|
|
71
79
|
insertNewRow(batchId: string, rowIndex: number);
|
|
72
80
|
updateCellValue(batchId: string, colIndex: number, rowIndex: number, value: string);
|
|
@@ -717,6 +725,34 @@ export default class API {
|
|
|
717
725
|
});
|
|
718
726
|
};
|
|
719
727
|
|
|
728
|
+
public importBatchDataFromDataset = (
|
|
729
|
+
batchId: string,
|
|
730
|
+
datasetId: string,
|
|
731
|
+
embed: boolean = false,
|
|
732
|
+
accessKey: string = null,
|
|
733
|
+
compId: string = null,
|
|
734
|
+
addMedia: boolean = false
|
|
735
|
+
): Promise<any | Error> => {
|
|
736
|
+
const formData: FormData = new FormData();
|
|
737
|
+
|
|
738
|
+
if (embed && accessKey && compId) {
|
|
739
|
+
formData.append('include_email_embed', 'true');
|
|
740
|
+
formData.append('composition_id', compId);
|
|
741
|
+
formData.append('access_key', accessKey);
|
|
742
|
+
} else if (compId) {
|
|
743
|
+
formData.append('composition_id', compId);
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
if (addMedia) {
|
|
747
|
+
formData.append('include_media', 'true');
|
|
748
|
+
}
|
|
749
|
+
return this.doRequest({
|
|
750
|
+
method: 'POST',
|
|
751
|
+
url: `/batch/${batchId}/data/from-dataset/${datasetId}`,
|
|
752
|
+
data: formData
|
|
753
|
+
});
|
|
754
|
+
};
|
|
755
|
+
|
|
720
756
|
public updateBatchColumns = (batchId: string, columns: any[]): Promise<any | Error> => {
|
|
721
757
|
return this.doRequest({
|
|
722
758
|
method: 'PUT',
|