@capillarytech/creatives-library 7.7.24 → 7.7.25
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/package.json
CHANGED
|
@@ -11,3 +11,7 @@ export const GENERATE_PREVIEW_FAILURE = 'app/CapFacebookPreview/GET_PREVIEW_FAIL
|
|
|
11
11
|
|
|
12
12
|
export const CLEAR_PREVIEW = 'app/CapFacebookPreview/CLEAR_PREVIEW';
|
|
13
13
|
|
|
14
|
+
export const PREVIEW_NOT_REQUESTED = "PreviewNotRequested";
|
|
15
|
+
export const FETCH_PREVIEW_REQUESTED = "PreviewRequested";
|
|
16
|
+
export const FETCH_PREVIEW_SUCCESS = "PreviewRequestSuccess";
|
|
17
|
+
export const FETCH_PREVIEW_FAILURE = "PreviewRequestFailure";
|
|
@@ -30,6 +30,11 @@ import {
|
|
|
30
30
|
CAROUSEL,
|
|
31
31
|
NO_CALL_TO_ACTION,
|
|
32
32
|
} from '../../v2Containers/Facebook/Advertisement/constant';
|
|
33
|
+
import {
|
|
34
|
+
FETCH_PREVIEW_REQUESTED,
|
|
35
|
+
FETCH_PREVIEW_SUCCESS,
|
|
36
|
+
PREVIEW_NOT_REQUESTED,
|
|
37
|
+
} from './constants';
|
|
33
38
|
import './index.scss';
|
|
34
39
|
|
|
35
40
|
export const CapFacebookPreview = (props) => {
|
|
@@ -55,7 +60,10 @@ export const CapFacebookPreview = (props) => {
|
|
|
55
60
|
const [disableAfterPreviewGenerate, setDisableAfterPreviewGenerate] = useState(false);
|
|
56
61
|
const [random, setRandom] = useState(0);
|
|
57
62
|
const {pageAccessToken, pageId} = orgUnitFacebookPageSettingsMap;
|
|
58
|
-
const {previewIframe = "",
|
|
63
|
+
const {previewIframe = "", fetchPreviewStatus = PREVIEW_NOT_REQUESTED, previewIframeError = ""} = facebookPreviewData;
|
|
64
|
+
const [previewLoaded, setPreviewLoaded] = useState(false);
|
|
65
|
+
const [isRefreshing, setIsRefreshing] = useState(false);
|
|
66
|
+
let isSpinning = false;
|
|
59
67
|
const facebookAdOptions = [
|
|
60
68
|
{
|
|
61
69
|
value: "DESKTOP_FEED_STANDARD",
|
|
@@ -284,9 +292,17 @@ export const CapFacebookPreview = (props) => {
|
|
|
284
292
|
};
|
|
285
293
|
|
|
286
294
|
const resetIframe = () => {
|
|
295
|
+
previewLoaded && setPreviewLoaded(false);
|
|
296
|
+
!isRefreshing && setIsRefreshing(true);
|
|
287
297
|
const r = random + 1;
|
|
288
298
|
setRandom(r);
|
|
289
299
|
};
|
|
300
|
+
const unsetLoader = () => {
|
|
301
|
+
setTimeout(function() {
|
|
302
|
+
!previewLoaded && setPreviewLoaded(true);
|
|
303
|
+
isRefreshing && setIsRefreshing(false);
|
|
304
|
+
}.bind(this), 5000);
|
|
305
|
+
}
|
|
290
306
|
const getIframe = (iframe) => {
|
|
291
307
|
const divTag = document.createElement('div');
|
|
292
308
|
divTag.innerHTML = iframe;
|
|
@@ -295,13 +311,16 @@ export const CapFacebookPreview = (props) => {
|
|
|
295
311
|
<iframe
|
|
296
312
|
src={src}
|
|
297
313
|
key={random}
|
|
298
|
-
style={{border: "none"}}
|
|
314
|
+
style={{ border: "none" }}
|
|
299
315
|
width={"600px"}
|
|
300
316
|
scrolling="no"
|
|
301
317
|
height={"1000px"}
|
|
302
318
|
className="cap-facebook-ad-iframe"
|
|
319
|
+
onLoad={
|
|
320
|
+
unsetLoader()
|
|
321
|
+
}
|
|
303
322
|
/>
|
|
304
|
-
|
|
323
|
+
</>);
|
|
305
324
|
};
|
|
306
325
|
|
|
307
326
|
const showRefreshButton = () => {
|
|
@@ -340,74 +359,80 @@ export const CapFacebookPreview = (props) => {
|
|
|
340
359
|
}
|
|
341
360
|
}, [previewIframeError]);
|
|
342
361
|
return (
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
362
|
+
<>
|
|
363
|
+
{isSpinning = (fetchPreviewStatus === FETCH_PREVIEW_REQUESTED) ||
|
|
364
|
+
((fetchPreviewStatus === FETCH_PREVIEW_SUCCESS) && !previewLoaded) ||
|
|
365
|
+
isRefreshing}
|
|
366
|
+
<CapSpin
|
|
367
|
+
spinning={isSpinning}>
|
|
368
|
+
<div style={{ display: 'inline-block' }}>
|
|
369
|
+
<CapSelect
|
|
370
|
+
label={formatMessage(messages.previewBasedonAdPlacement)}
|
|
371
|
+
key={"select-previewBasedonAdPlacement"}
|
|
372
|
+
onChange={onChangeAdPreviewFormat}
|
|
373
|
+
style={{ width: '328px', paddingBottom: 16 }}
|
|
374
|
+
options={adOptions}
|
|
375
|
+
value={adPreviewFormat}
|
|
376
|
+
>
|
|
377
|
+
</CapSelect>
|
|
378
|
+
</div>
|
|
379
|
+
{!hideInfoText && <CapLabel
|
|
380
|
+
type="label1"
|
|
381
|
+
style={{ paddingBottom: 16, textAlign: 'left', width: 392 }}
|
|
352
382
|
>
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
383
|
+
{formatMessage(messages.previewAdDesc)}
|
|
384
|
+
</CapLabel>}
|
|
385
|
+
<div style={{ marginBottom: 16 }}>
|
|
386
|
+
{(disablePreviewButton || disableAfterPreviewGenerate) ?
|
|
387
|
+
<CapTooltip title={formatMessage(messages.generatePreviewDisableToolTip)}>
|
|
388
|
+
<div className="button-disabled-tooltip-wrapper">
|
|
389
|
+
<CapButton
|
|
390
|
+
type="secondary"
|
|
391
|
+
disabled
|
|
358
392
|
>
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
</div>
|
|
372
|
-
</CapTooltip> :
|
|
373
|
-
<CapButton
|
|
393
|
+
<FormattedMessage {...messages.generatePreview} />
|
|
394
|
+
</CapButton>
|
|
395
|
+
</div>
|
|
396
|
+
</CapTooltip> :
|
|
397
|
+
<CapButton
|
|
398
|
+
type="secondary"
|
|
399
|
+
onClick={generatePreview}
|
|
400
|
+
>
|
|
401
|
+
<FormattedMessage {...messages.generatePreview} />
|
|
402
|
+
</CapButton>}
|
|
403
|
+
{isRefreshButton && (<CapButton
|
|
404
|
+
onClick={resetIframe}
|
|
374
405
|
type="secondary"
|
|
375
|
-
|
|
406
|
+
style={{ marginLeft: 16 }}
|
|
376
407
|
>
|
|
377
|
-
|
|
378
|
-
</CapButton>}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
</
|
|
404
|
-
|
|
405
|
-
src={facebookEmptyPlaceholder}
|
|
406
|
-
alt="default"
|
|
407
|
-
width="316px"
|
|
408
|
-
height="392px"
|
|
409
|
-
/> : getIframe(previewIframe)}
|
|
410
|
-
</CapSpin>
|
|
408
|
+
{formatMessage(messages.refreshPreview)}
|
|
409
|
+
</CapButton>)}
|
|
410
|
+
</div>
|
|
411
|
+
{isRefreshButton && <div style={{ marginBottom: 16 }}>
|
|
412
|
+
<CapIcon
|
|
413
|
+
type="info"
|
|
414
|
+
svgProps={{
|
|
415
|
+
width: 16,
|
|
416
|
+
height: 16,
|
|
417
|
+
}}
|
|
418
|
+
>
|
|
419
|
+
</CapIcon>
|
|
420
|
+
<CapLabel.CapLabelInline
|
|
421
|
+
type="label1"
|
|
422
|
+
size="s"
|
|
423
|
+
style={{ marginBottom: 16, width: 392 }}
|
|
424
|
+
>
|
|
425
|
+
{formatMessage(messages.videoNotePreview)}
|
|
426
|
+
</CapLabel.CapLabelInline>
|
|
427
|
+
</div>}
|
|
428
|
+
{previewIframe === "" ? <CapImage
|
|
429
|
+
src={facebookEmptyPlaceholder}
|
|
430
|
+
alt="default"
|
|
431
|
+
width="316px"
|
|
432
|
+
height="392px"
|
|
433
|
+
/> : getIframe(previewIframe)}
|
|
434
|
+
</CapSpin>
|
|
435
|
+
</>
|
|
411
436
|
);
|
|
412
437
|
};
|
|
413
438
|
|
|
@@ -6,29 +6,38 @@
|
|
|
6
6
|
|
|
7
7
|
import { fromJS } from 'immutable';
|
|
8
8
|
import get from 'lodash/get';
|
|
9
|
-
import
|
|
9
|
+
import {
|
|
10
|
+
GENERATE_PREVIEW_REQUEST,
|
|
11
|
+
GENERATE_PREVIEW_SUCCESS,
|
|
12
|
+
GENERATE_PREVIEW_FAILURE,
|
|
13
|
+
CLEAR_PREVIEW,
|
|
14
|
+
FETCH_PREVIEW_REQUESTED,
|
|
15
|
+
FETCH_PREVIEW_SUCCESS,
|
|
16
|
+
FETCH_PREVIEW_FAILURE,
|
|
17
|
+
PREVIEW_NOT_REQUESTED,
|
|
18
|
+
} from './constants';
|
|
10
19
|
|
|
11
20
|
const initialState = fromJS({
|
|
12
|
-
|
|
21
|
+
fetchPreviewStatus: PREVIEW_NOT_REQUESTED,
|
|
13
22
|
previewIframe: "",
|
|
14
23
|
previewIframeError: "",
|
|
15
24
|
});
|
|
16
25
|
|
|
17
26
|
function capFacebookPreviewReducer(state = initialState, action) {
|
|
18
27
|
switch (action.type) {
|
|
19
|
-
case
|
|
20
|
-
return state.set('
|
|
28
|
+
case GENERATE_PREVIEW_REQUEST:
|
|
29
|
+
return state.set('fetchPreviewStatus', FETCH_PREVIEW_REQUESTED)
|
|
21
30
|
.set('previewIframe', "")
|
|
22
31
|
.set("previewIframeError", "");
|
|
23
|
-
case
|
|
24
|
-
return state.set('
|
|
32
|
+
case GENERATE_PREVIEW_SUCCESS:
|
|
33
|
+
return state.set('fetchPreviewStatus', FETCH_PREVIEW_SUCCESS)
|
|
25
34
|
.set('previewIframe', get(action, 'payload.fbPreview[0].body', ""));
|
|
26
|
-
case
|
|
27
|
-
return state.set('
|
|
35
|
+
case GENERATE_PREVIEW_FAILURE:
|
|
36
|
+
return state.set('fetchPreviewStatus', FETCH_PREVIEW_FAILURE)
|
|
28
37
|
.set('previewIframe', "")
|
|
29
38
|
.set("previewIframeError", get(action, 'payload.message', ""));
|
|
30
|
-
case
|
|
31
|
-
return state.set('
|
|
39
|
+
case CLEAR_PREVIEW:
|
|
40
|
+
return state.set('fetchPreviewStatus', PREVIEW_NOT_REQUESTED)
|
|
32
41
|
.set('previewIframe', "")
|
|
33
42
|
.set("previewIframeError", "");
|
|
34
43
|
default:
|