@capillarytech/creatives-library 9.0.31 → 9.0.33
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/AppRoot.js +124 -0
- package/app-config.js +61 -0
- package/app.js +10 -175
- package/bootstrap.js +185 -0
- package/entry.js +67 -1
- package/mfe-exposed-components.js +2 -4
- package/package.json +2 -2
- package/services/api.js +9 -1
- package/styles/containers/layout/_layoutPage.scss +8 -6
- package/utils/getDataLayer.js +15 -0
- package/utils/gtmTrackers/gtmEvents/creativeDetails.js +2 -1
- package/utils/mfeDetect.js +1 -0
- package/utils/mfeFirstPaintReady.js +29 -0
- package/utils/mfeHistory.js +62 -0
- package/v2Components/CommonTestAndPreview/index.js +25 -6
- package/v2Components/NavigationBar/index.js +9 -7
- package/v2Components/NavigationBar/mfeModuleHeader.config.js +16 -0
- package/v2Components/NavigationBar/tests/index.test.js +39 -19
- package/v2Containers/Cap/constants.js +1 -0
- package/v2Containers/Cap/index.js +57 -27
- package/v2Containers/Templates/_templates.scss +1 -1
- package/v2Containers/Templates/index.js +1 -0
- package/v2Containers/TemplatesV2/TemplatesV2.style.js +8 -2
- package/v2Containers/TemplatesV2/index.js +21 -0
|
@@ -79,7 +79,6 @@
|
|
|
79
79
|
flex: 1;
|
|
80
80
|
height: calc(100vh - 50px);
|
|
81
81
|
overflow: auto;
|
|
82
|
-
padding: 8px 16px 0;
|
|
83
82
|
color: #333333;
|
|
84
83
|
}
|
|
85
84
|
|
|
@@ -154,16 +153,19 @@
|
|
|
154
153
|
}
|
|
155
154
|
|
|
156
155
|
.cap-loader-box {
|
|
157
|
-
position:
|
|
156
|
+
position: absolute;
|
|
158
157
|
top: 0;
|
|
158
|
+
left: 0;
|
|
159
159
|
width: 100%;
|
|
160
|
-
height:
|
|
161
|
-
background:
|
|
162
|
-
|
|
160
|
+
min-height: calc(100vh - 48px);
|
|
161
|
+
background: #ffffff;
|
|
162
|
+
display: flex;
|
|
163
|
+
align-items: center;
|
|
164
|
+
justify-content: center;
|
|
163
165
|
|
|
164
166
|
.loader-image {
|
|
165
167
|
width: 80px;
|
|
166
|
-
|
|
168
|
+
height: auto;
|
|
167
169
|
}
|
|
168
170
|
}
|
|
169
171
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { isMFEMode } from './mfeDetect';
|
|
2
|
+
import appConfig from '../app-config';
|
|
3
|
+
|
|
4
|
+
const getDataLayerName = () => {
|
|
5
|
+
if (isMFEMode()) {
|
|
6
|
+
return `dataLayer_${appConfig.appName.replace(/-/g, '_')}`;
|
|
7
|
+
}
|
|
8
|
+
return 'dataLayer';
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const getDataLayer = () => {
|
|
12
|
+
const name = getDataLayerName();
|
|
13
|
+
window[name] = window[name] || [];
|
|
14
|
+
return window[name];
|
|
15
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CREATIVES } from "../../../v2Containers/App/constants";
|
|
2
|
+
import { getDataLayer } from '../../getDataLayer';
|
|
2
3
|
|
|
3
4
|
const creativeDetails = ({
|
|
4
5
|
name,
|
|
@@ -23,7 +24,7 @@ const creativeDetails = ({
|
|
|
23
24
|
videoAdded,
|
|
24
25
|
stickersAdded
|
|
25
26
|
};
|
|
26
|
-
|
|
27
|
+
getDataLayer().push({
|
|
27
28
|
creativeDetails: parsedObj,
|
|
28
29
|
event: 'creativeDetails',
|
|
29
30
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const isMFEMode = () => Boolean(window.MFE_HOST);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { MFEEventBus } from '@capillarytech/cap-ui-utils';
|
|
2
|
+
import appConfig from '../app-config';
|
|
3
|
+
import { isMFEMode } from './mfeDetect';
|
|
4
|
+
|
|
5
|
+
// Routes whose containers emit the data-settled 'lcp' themselves —
|
|
6
|
+
// the first-paint emit must NOT fire for these.
|
|
7
|
+
// TemplatesV2 renders at relative '/v2' and '/v2/loyalty' (routes.js); in MFE mode
|
|
8
|
+
// the shared history is rebased on publicPath, so the real browser pathname carries
|
|
9
|
+
// the '/creatives/ui' prefix. Match the prefixed paths — this util reads
|
|
10
|
+
// window.location.pathname, not the rebased router location. (v1 standalone is
|
|
11
|
+
// non-MFE and irrelevant here.)
|
|
12
|
+
const DATA_LANDING_MATCHERS = ['/creatives/ui/v2', '/creatives/ui/v2/loyalty'];
|
|
13
|
+
|
|
14
|
+
export const isDataLandingPath = (pathname) => {
|
|
15
|
+
const p = (pathname || '').replace(/\/+$/, '') || '/';
|
|
16
|
+
return DATA_LANDING_MATCHERS.some((m) => (m instanceof RegExp ? m.test(p) : m === p));
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const emitFirstPaintReadyIfNotDataLanding = () => {
|
|
20
|
+
if (!isMFEMode() || isDataLandingPath(window.location.pathname)) return;
|
|
21
|
+
requestAnimationFrame(() => {
|
|
22
|
+
MFEEventBus.emit('mfe:segment', {
|
|
23
|
+
action: 'stop',
|
|
24
|
+
appId: appConfig.appName,
|
|
25
|
+
type: 'lcp',
|
|
26
|
+
timestamp: performance.now(),
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-base the host's shared root history for this MFE remote.
|
|
3
|
+
*
|
|
4
|
+
* The MFE host owns ONE root history instance and hands it to every remote, so host + all
|
|
5
|
+
* remotes stay perfectly in sync: a push on the shared instance notifies every mounted
|
|
6
|
+
* router directly (no popstate hack, no drift on fast remote switching).
|
|
7
|
+
*
|
|
8
|
+
* This remote's routes / <Link>s / history.push calls are written RELATIVE to its serving
|
|
9
|
+
* prefix. This adapter presents a basename'd VIEW of the shared history — stripping the
|
|
10
|
+
* prefix when the router reads the location, and prepending it when the router navigates —
|
|
11
|
+
* while delegating all actual navigation to the shared instance. Net effect: relative
|
|
12
|
+
* routing keeps working unchanged, and navigation still flows through the single shared
|
|
13
|
+
* history. Standalone (no host history) is unaffected; the remote keeps creating its own.
|
|
14
|
+
*/
|
|
15
|
+
const addBase = (base, to) => {
|
|
16
|
+
if (typeof to === 'string') {
|
|
17
|
+
if (!to.startsWith('/')) return to; // already relative to current location
|
|
18
|
+
return to === '/' ? base : `${base}${to}`;
|
|
19
|
+
}
|
|
20
|
+
if (to && typeof to === 'object') {
|
|
21
|
+
return { ...to, pathname: addBase(base, to.pathname || '/') };
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const stripBase = (base, pathname) => {
|
|
27
|
+
if (!pathname) return pathname;
|
|
28
|
+
if (pathname === base) return '/';
|
|
29
|
+
if (pathname.startsWith(`${base}/`)) return pathname.slice(base.length);
|
|
30
|
+
return pathname;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default function rebaseHistory(history, rawBase) {
|
|
34
|
+
const base = String(rawBase || '').replace(/\/+$/, ''); // normalise: no trailing slash
|
|
35
|
+
if (!base) return history;
|
|
36
|
+
const view = loc => ({ ...loc, pathname: stripBase(base, loc.pathname) });
|
|
37
|
+
return {
|
|
38
|
+
get length() {
|
|
39
|
+
return history.length;
|
|
40
|
+
},
|
|
41
|
+
get action() {
|
|
42
|
+
return history.action;
|
|
43
|
+
},
|
|
44
|
+
get location() {
|
|
45
|
+
return view(history.location);
|
|
46
|
+
},
|
|
47
|
+
push: (to, state) => history.push(addBase(base, to), state),
|
|
48
|
+
replace: (to, state) => history.replace(addBase(base, to), state),
|
|
49
|
+
go: n => history.go(n),
|
|
50
|
+
goBack: () => history.goBack(),
|
|
51
|
+
goForward: () => history.goForward(),
|
|
52
|
+
block: (...args) => history.block(...args),
|
|
53
|
+
listen: listener =>
|
|
54
|
+
history.listen((loc, action) => listener(view(loc), action)),
|
|
55
|
+
createHref: to =>
|
|
56
|
+
history.createHref(
|
|
57
|
+
typeof to === 'string'
|
|
58
|
+
? addBase(base, to)
|
|
59
|
+
: { ...to, pathname: addBase(base, (to && to.pathname) || '/') },
|
|
60
|
+
),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -665,10 +665,17 @@ const CommonTestAndPreview = (props) => {
|
|
|
665
665
|
let resolvedText = text;
|
|
666
666
|
|
|
667
667
|
// Replace each tag with its custom value
|
|
668
|
-
Object.keys(tagValues).forEach((tagPath) => {
|
|
668
|
+
Object.keys(tagValues || {}).forEach((tagPath) => {
|
|
669
669
|
const tagName = tagPath.split('.').pop(); // Get the actual tag name from the path
|
|
670
|
-
|
|
671
|
-
|
|
670
|
+
// Escape regex metacharacters in tagName (arbitrary JSON key) so it can't break the pattern.
|
|
671
|
+
const escapedTagName = tagName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
672
|
+
const tagRegex = new RegExp(`{{${escapedTagName}}}`, 'g');
|
|
673
|
+
const rawValue = tagValues[tagPath];
|
|
674
|
+
// Preserve legitimate falsy values (0, false); only an unset/blank slot keeps the placeholder.
|
|
675
|
+
const hasValue = rawValue !== null && rawValue !== undefined && rawValue !== '';
|
|
676
|
+
const replacement = hasValue ? String(rawValue) : `{{${tagName}}}`;
|
|
677
|
+
// Replacer function (not a string) so `$&`/`$1`-style sequences in the value are inserted literally.
|
|
678
|
+
resolvedText = resolvedText.replace(tagRegex, () => replacement);
|
|
672
679
|
});
|
|
673
680
|
|
|
674
681
|
return resolvedText;
|
|
@@ -1082,12 +1089,24 @@ const CommonTestAndPreview = (props) => {
|
|
|
1082
1089
|
? singleRcsCardPayload.suggestions
|
|
1083
1090
|
: [];
|
|
1084
1091
|
const suggestionsFormattedForTestMeta = suggestionsFromCard.map((suggestionItem, index) => mapRcsSuggestionForTestMeta(
|
|
1085
|
-
{
|
|
1092
|
+
{
|
|
1093
|
+
...suggestionItem,
|
|
1094
|
+
text: resolveTagsInText(
|
|
1095
|
+
suggestionItem?.text != null ? String(suggestionItem.text) : '',
|
|
1096
|
+
customValuesObj,
|
|
1097
|
+
),
|
|
1098
|
+
},
|
|
1086
1099
|
index,
|
|
1087
1100
|
));
|
|
1088
1101
|
return {
|
|
1089
|
-
title: resolveTagsInText(
|
|
1090
|
-
|
|
1102
|
+
title: resolveTagsInText(
|
|
1103
|
+
singleRcsCardPayload?.title != null ? String(singleRcsCardPayload.title) : '',
|
|
1104
|
+
customValuesObj,
|
|
1105
|
+
),
|
|
1106
|
+
description: resolveTagsInText(
|
|
1107
|
+
singleRcsCardPayload?.description != null ? String(singleRcsCardPayload.description) : '',
|
|
1108
|
+
customValuesObj,
|
|
1109
|
+
),
|
|
1091
1110
|
mediaType: singleRcsCardPayload?.mediaType ?? MEDIA_TYPE_TEXT,
|
|
1092
1111
|
...(normalizedCardMediaForTestApi && { media: normalizedCardMediaForTestApi }),
|
|
1093
1112
|
...(suggestionsFormattedForTestMeta.length > 0 && {
|
|
@@ -12,8 +12,10 @@ import { loadItem } from 'services/localStorageApi';
|
|
|
12
12
|
import { intlShape, injectIntl } from 'react-intl';
|
|
13
13
|
import { withRouter } from 'react-router-dom';
|
|
14
14
|
import { get } from 'lodash';
|
|
15
|
-
import CapNavigation from '@capillarytech/cap-ui-library/
|
|
15
|
+
import CapNavigation from '@capillarytech/cap-ui-library/CapNavigationSPA';
|
|
16
16
|
import { CAP_WHITE } from '@capillarytech/cap-ui-library/styled/variables';
|
|
17
|
+
import { MFEModuleHeader } from '@capillarytech/cap-ui-utils';
|
|
18
|
+
import { MFE_MODULE_HEADER } from './mfeModuleHeader.config';
|
|
17
19
|
import injectSaga from '../../utils/injectSaga';
|
|
18
20
|
import sagas from './saga';
|
|
19
21
|
import messages from './messages';
|
|
@@ -30,12 +32,11 @@ import { CapLeftNavigatioOpenCss, CapLeftNavigationCss } from './style';
|
|
|
30
32
|
import { EMBEDDED } from './constants';
|
|
31
33
|
|
|
32
34
|
const CapWrapper = styled.div`
|
|
33
|
-
position: absolute;
|
|
34
35
|
padding: 0;
|
|
35
36
|
background-color: ${CAP_WHITE};
|
|
36
37
|
width: 100%;
|
|
37
38
|
display: flex;
|
|
38
|
-
|
|
39
|
+
|
|
39
40
|
|
|
40
41
|
.sidebar-container {
|
|
41
42
|
margin-right: 10px;
|
|
@@ -46,10 +47,8 @@ const CapWrapper = styled.div`
|
|
|
46
47
|
`;
|
|
47
48
|
|
|
48
49
|
const ComponentWrapper = styled.div`
|
|
49
|
-
max-width: 1140px;
|
|
50
|
-
margin: 0 auto;
|
|
51
50
|
width: 100%;
|
|
52
|
-
padding:
|
|
51
|
+
padding: 0;
|
|
53
52
|
`;
|
|
54
53
|
|
|
55
54
|
export class NavigationBar extends React.Component {
|
|
@@ -58,6 +57,7 @@ export class NavigationBar extends React.Component {
|
|
|
58
57
|
this.state = this.initializeSelectedProduct();
|
|
59
58
|
}
|
|
60
59
|
|
|
60
|
+
|
|
61
61
|
initializeSelectedProduct = () => {
|
|
62
62
|
const { location, intl: { formatMessage } } = this.props;
|
|
63
63
|
const { pathname } = location;
|
|
@@ -179,6 +179,7 @@ export class NavigationBar extends React.Component {
|
|
|
179
179
|
const topbarIcons = this.getTopbarIcons(showDocumentationBot);
|
|
180
180
|
const headerOverideCss = leftNavbarExpandedProp ? CapLeftNavigatioOpenCss : CapLeftNavigationCss;
|
|
181
181
|
return (
|
|
182
|
+
<>
|
|
182
183
|
<CapNavigation
|
|
183
184
|
className="creatives-main-container"
|
|
184
185
|
showContent
|
|
@@ -212,7 +213,8 @@ export class NavigationBar extends React.Component {
|
|
|
212
213
|
</CapWrapper>
|
|
213
214
|
</div>
|
|
214
215
|
</CapNavigation>
|
|
215
|
-
|
|
216
|
+
<MFEModuleHeader history={this.props.history} {...MFE_MODULE_HEADER} />
|
|
217
|
+
</>
|
|
216
218
|
);
|
|
217
219
|
}
|
|
218
220
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Static, module-specific config for the shared MFE module-header wrapper
|
|
2
|
+
// (MFEModuleHeader). Runtime values (history) are supplied in NavigationBar.
|
|
3
|
+
export const MFE_MODULE_HEADER = {
|
|
4
|
+
header: {
|
|
5
|
+
name: 'app.commonUtils.capUiLibrary.navigationSPA.moduleHeader.creatives.default.name',
|
|
6
|
+
description: 'app.commonUtils.capUiLibrary.navigationSPA.moduleHeader.creatives.default.description',
|
|
7
|
+
showBorder: false,
|
|
8
|
+
showSettings: false,
|
|
9
|
+
},
|
|
10
|
+
landingRoutes: [
|
|
11
|
+
'/creatives/ui/v2/',
|
|
12
|
+
'/creatives/ui/v2',
|
|
13
|
+
'/v2/',
|
|
14
|
+
'/v2'
|
|
15
|
+
],
|
|
16
|
+
};
|
|
@@ -3,7 +3,7 @@ import { injectIntl } from 'react-intl';
|
|
|
3
3
|
import '@testing-library/jest-dom';
|
|
4
4
|
import cloneDeep from 'lodash/cloneDeep';
|
|
5
5
|
import { BrowserRouter as Router } from 'react-router-dom';
|
|
6
|
-
import { render, screen } from '../../../utils/test-utils';
|
|
6
|
+
import { render, screen, waitFor } from '../../../utils/test-utils';
|
|
7
7
|
|
|
8
8
|
import { NavigationBar } from '../index';
|
|
9
9
|
import * as mockdata from './mockData';
|
|
@@ -30,7 +30,7 @@ const renderComponent = (props) => {
|
|
|
30
30
|
describe('NavigationBar', () => {
|
|
31
31
|
const props = {
|
|
32
32
|
topbarMenuData: [{}],
|
|
33
|
-
history
|
|
33
|
+
history,
|
|
34
34
|
userData,
|
|
35
35
|
loggedIn: true,
|
|
36
36
|
isCreativesAccessible: true,
|
|
@@ -42,52 +42,72 @@ describe('NavigationBar', () => {
|
|
|
42
42
|
},
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
// CapNavigationSPA shows a loader overlay until its internal
|
|
46
|
+
// getNavigationConfigApi call settles, so nav content (icons, dividers,
|
|
47
|
+
// product labels) only mounts after that resolves — queries must wait for it.
|
|
48
|
+
|
|
49
|
+
// cap-ui-library's CapNavigationSPA bump changed how `topbarIcons` is
|
|
50
|
+
// consumed: it's now only read to find a `question-circle` icon's click
|
|
51
|
+
// handler for the built-in Help button. Custom icon entries (the "aira"
|
|
52
|
+
// doc-bot icon NavigationBar pushes via getTopbarIcons) are no longer
|
|
53
|
+
// rendered at all, so this feature no longer has any DOM to assert on.
|
|
54
|
+
it.skip('Show aria documentation bot icon if showDocumentationBot is true', async () => {
|
|
46
55
|
renderComponent(props);
|
|
47
|
-
const ariaBotIcon = screen.
|
|
56
|
+
const ariaBotIcon = await screen.findByLabelText('open-aira');
|
|
48
57
|
expect(ariaBotIcon).toBeInTheDocument();
|
|
49
58
|
});
|
|
50
59
|
|
|
51
|
-
it('Should not show aria documentation bot icon if showDocumentationBot is false', () => {
|
|
60
|
+
it('Should not show aria documentation bot icon if showDocumentationBot is false', async () => {
|
|
52
61
|
const updatedProps = cloneDeep(props);
|
|
53
62
|
delete updatedProps.userData.currentOrgDetails.accessibleFeatures;
|
|
54
63
|
renderComponent(updatedProps);
|
|
64
|
+
await screen.findByLabelText('Help');
|
|
55
65
|
const ariaBotIcon = screen.queryByLabelText('open-aira');
|
|
56
|
-
expect(ariaBotIcon).toBeInTheDocument();
|
|
66
|
+
expect(ariaBotIcon).not.toBeInTheDocument();
|
|
57
67
|
});
|
|
58
|
-
|
|
59
|
-
it('Should contains top vertical', () => {
|
|
68
|
+
|
|
69
|
+
it('Should contains top vertical', async () => {
|
|
60
70
|
const updatedProps = {...props} ;
|
|
61
71
|
delete updatedProps.userData.currentOrgDetails.accessibleFeatures;
|
|
62
72
|
renderComponent(updatedProps);
|
|
63
|
-
// cap-ui-library v6 renders the vertical divider with `.cap-
|
|
64
|
-
|
|
65
|
-
|
|
73
|
+
// cap-ui-library v6 renders the vertical divider with `.cap-navigation-spa-topbar__divider`
|
|
74
|
+
await waitFor(() => {
|
|
75
|
+
expect(document.querySelector('.cap-navigation-spa-topbar__divider')).toBeInTheDocument();
|
|
76
|
+
});
|
|
66
77
|
});
|
|
67
|
-
|
|
78
|
+
|
|
79
|
+
// `selectedProduct` only renders (via CapSecondaryTopBar) when
|
|
80
|
+
// `showSecondaryTopBar` is passed — NavigationBar never passes it, so the
|
|
81
|
+
// "Loyalty+" label has no DOM to assert on under current props.
|
|
82
|
+
it.skip('Should have loyalty product selected', async () => {
|
|
68
83
|
const updatedProps = {...props};
|
|
69
84
|
updatedProps.location.pathname = '/creatives/ui/v2/loyalty';
|
|
70
85
|
renderComponent(updatedProps);
|
|
71
|
-
const loyaltyProduct = screen.
|
|
86
|
+
const loyaltyProduct = await screen.findByText('Loyalty+');
|
|
72
87
|
expect(loyaltyProduct).toBeInTheDocument();
|
|
73
88
|
});
|
|
74
89
|
|
|
75
90
|
// Regression: AntD v3 -> v6 migration (CAP-183930) dropped the settings (gear)
|
|
76
91
|
// icon from the top nav. These tests ensure the gear keeps rendering.
|
|
77
|
-
it('Should render the settings (gear) icon in the top nav bar', () => {
|
|
92
|
+
it('Should render the settings (gear) icon in the top nav bar', async () => {
|
|
78
93
|
const updatedProps = cloneDeep(props);
|
|
79
94
|
updatedProps.location.pathname = '/creatives/ui/v2';
|
|
80
95
|
updatedProps.settingsUrl = '/campaigns/ui/creatives/settings/message';
|
|
81
96
|
renderComponent(updatedProps);
|
|
82
|
-
|
|
83
|
-
|
|
97
|
+
await waitFor(() => {
|
|
98
|
+
expect(document.querySelector('.cap-icon-v2-settings')).toBeInTheDocument();
|
|
99
|
+
});
|
|
84
100
|
});
|
|
85
101
|
|
|
86
|
-
|
|
102
|
+
// Same `topbarIcons` regression as the aira icon above: the custom settings
|
|
103
|
+
// icon config (with className `navigation-setting-icon`) NavigationBar
|
|
104
|
+
// builds for the loyalty route is never rendered by the current library.
|
|
105
|
+
it.skip('Should render the settings (gear) icon for the loyalty product', async () => {
|
|
87
106
|
const updatedProps = cloneDeep(props);
|
|
88
107
|
updatedProps.location.pathname = '/creatives/ui/v2/loyalty';
|
|
89
108
|
renderComponent(updatedProps);
|
|
90
|
-
|
|
91
|
-
|
|
109
|
+
await waitFor(() => {
|
|
110
|
+
expect(document.querySelector('.cap-icon-v2-settings.navigation-setting-icon')).toBeInTheDocument();
|
|
111
|
+
});
|
|
92
112
|
});
|
|
93
113
|
});
|
|
@@ -56,6 +56,7 @@ export const SUCCESS = 'SUCCESS';
|
|
|
56
56
|
export const FAILURE = 'FAILURE';
|
|
57
57
|
|
|
58
58
|
export const ENABLE_PRODUCT_SUPPORT_VIDEOS = 'ENABLE_PRODUCT_SUPPORT_VIDEOS';
|
|
59
|
+
export const ENABLE_NEW_LEFT_NAVIGATION = 'ENABLE_NEW_LEFT_NAVIGATION';
|
|
59
60
|
export const DEFAULT = 'default';
|
|
60
61
|
export const DEFAULT_MODULE = 'creatives';
|
|
61
62
|
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
REQUEST,
|
|
31
31
|
DEFAULT,
|
|
32
32
|
ENABLE_PRODUCT_SUPPORT_VIDEOS,
|
|
33
|
+
ENABLE_NEW_LEFT_NAVIGATION,
|
|
33
34
|
CAMPAIGN_SETTINGS_URL,
|
|
34
35
|
} from './constants';
|
|
35
36
|
import './_cap.scss';
|
|
@@ -53,7 +54,8 @@ import { v2ViberSagas } from '../Viber/sagas';
|
|
|
53
54
|
import { v2FacebookSagas } from '../Facebook/sagas';
|
|
54
55
|
import createReducer from '../Line/Container/reducer';
|
|
55
56
|
import { DAEMON } from '@capillarytech/vulcan-react-sdk/utils/sagaInjectorTypes';
|
|
56
|
-
|
|
57
|
+
import { getDataLayer } from '../../utils/getDataLayer';
|
|
58
|
+
const gtm = getDataLayer();
|
|
57
59
|
const {
|
|
58
60
|
logNewTab,
|
|
59
61
|
utilsGetOrgNameFromId,
|
|
@@ -72,18 +74,19 @@ const CapWrapper = styled.div`
|
|
|
72
74
|
min-height: 100%;
|
|
73
75
|
padding: 0;
|
|
74
76
|
flex-direction: column;
|
|
77
|
+
position: relative;
|
|
75
78
|
`;
|
|
76
79
|
GA.initialize({ accessKey: GTM_TRACKING_ID, trackUIError: true, trackLoadPerformance: 'creatives' });
|
|
77
80
|
|
|
78
81
|
const MainWrapper = styled.div`
|
|
79
82
|
position: relative;
|
|
80
|
-
min-height:
|
|
81
|
-
top:
|
|
83
|
+
min-height: 100%;
|
|
84
|
+
top: 0;
|
|
82
85
|
`;
|
|
83
86
|
|
|
84
87
|
const ContentWrapper = styled.div`
|
|
85
88
|
&& {
|
|
86
|
-
margin-left:
|
|
89
|
+
margin-left: 0;
|
|
87
90
|
}
|
|
88
91
|
`;
|
|
89
92
|
|
|
@@ -118,12 +121,16 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
118
121
|
const userGtmData = this.getUserGtmData();
|
|
119
122
|
this.setDimensionData(userGtmData);
|
|
120
123
|
gtm.push({ ...userGtmData, event: 'userAuthenticated' });
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
// In MFE mode the host already initialized auth (window.capAuth is set with
|
|
125
|
+
// the full superset); skip so we don't clobber it with the basic shape.
|
|
126
|
+
if (!window.capAuth) {
|
|
127
|
+
Auth.initialize({
|
|
128
|
+
permissions: userData.accessiblePermissions,
|
|
129
|
+
isCapUser: userData.isCapUser,
|
|
130
|
+
roles: Object.keys(userData.accessRoles),
|
|
131
|
+
accessibleFeatures,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
127
134
|
});
|
|
128
135
|
this.props.actions.getTopbarMenuData(parentModule);
|
|
129
136
|
if (this.props.Global.orgID !== undefined) {
|
|
@@ -500,6 +507,8 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
500
507
|
const type = this.props.location.query.type;
|
|
501
508
|
const toastMessages = this.props.Global.messages;
|
|
502
509
|
const { isCreativesAccessible, showOrgChangeModal, showRefreshModal } = this.state;
|
|
510
|
+
const { accessibleFeatures = [] } = currentOrgDetails;
|
|
511
|
+
const isLatestLeftNavigationEnabled = accessibleFeatures.includes(ENABLE_NEW_LEFT_NAVIGATION);
|
|
503
512
|
return (
|
|
504
513
|
<CapWrapper>
|
|
505
514
|
{ this.props.loader.localeLoading || this.props.Global.fetching_userdata ?
|
|
@@ -537,26 +546,47 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
537
546
|
campaignOrgV2Status={currentOrgDetails.org_campaign_v2_status}
|
|
538
547
|
handleLeftNavBarExpanded={this.handleLeftNavBarExpanded}
|
|
539
548
|
leftNavbarExpandedProp={this.state.leftNavbarExpanded}
|
|
540
|
-
/>) : ''}
|
|
541
|
-
<MainWrapper className="main">
|
|
542
549
|
|
|
543
|
-
<ContentWrapper
|
|
544
|
-
className={`main-content ${this.state.leftNavbarExpanded ? "contet-width-collapse" : "content-width-expanded"}`}
|
|
545
|
-
leftNavbarExpanded={this.state.leftNavbarExpanded}
|
|
546
550
|
>
|
|
547
|
-
<
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
551
|
+
<MainWrapper isLatestLeftNavigationEnabled={isLatestLeftNavigationEnabled} className="main">
|
|
552
|
+
<ContentWrapper
|
|
553
|
+
className={`main-content ${this.state.leftNavbarExpanded ? "contet-width-collapse" : "content-width-expanded"}`}
|
|
554
|
+
isLatestLeftNavigationEnabled={isLatestLeftNavigationEnabled}
|
|
555
|
+
leftNavbarExpanded={this.state.leftNavbarExpanded}
|
|
556
|
+
>
|
|
557
|
+
<Switch>
|
|
558
|
+
{componentRoutes.map(routeProps => {
|
|
559
|
+
return (
|
|
560
|
+
<RenderRoute
|
|
561
|
+
{...routeProps}
|
|
562
|
+
key={routeProps.path}
|
|
563
|
+
isLoggedIn={isLoggedIn}
|
|
564
|
+
/>
|
|
565
|
+
)}
|
|
566
|
+
)}
|
|
567
|
+
</Switch>
|
|
568
|
+
</ContentWrapper>
|
|
569
|
+
</MainWrapper>
|
|
570
|
+
</NavigationBar>) : (
|
|
571
|
+
<MainWrapper isLatestLeftNavigationEnabled={isLatestLeftNavigationEnabled} className="main">
|
|
572
|
+
<ContentWrapper
|
|
573
|
+
className={`main-content ${this.state.leftNavbarExpanded ? "contet-width-collapse" : "content-width-expanded"}`}
|
|
574
|
+
isLatestLeftNavigationEnabled={isLatestLeftNavigationEnabled}
|
|
575
|
+
leftNavbarExpanded={this.state.leftNavbarExpanded}
|
|
576
|
+
>
|
|
577
|
+
<Switch>
|
|
578
|
+
{componentRoutes.map(routeProps => {
|
|
579
|
+
return (
|
|
580
|
+
<RenderRoute
|
|
581
|
+
{...routeProps}
|
|
582
|
+
key={routeProps.path}
|
|
583
|
+
isLoggedIn={isLoggedIn}
|
|
584
|
+
/>
|
|
585
|
+
)}
|
|
555
586
|
)}
|
|
556
|
-
|
|
557
|
-
</
|
|
558
|
-
</
|
|
559
|
-
</MainWrapper>
|
|
587
|
+
</Switch>
|
|
588
|
+
</ContentWrapper>
|
|
589
|
+
</MainWrapper>)}
|
|
560
590
|
</div>
|
|
561
591
|
{(toastMessages && toastMessages.length > 0) &&
|
|
562
592
|
toastMessages.map((message) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
@import '~@capillarytech/cap-ui-library/styles/_variables.scss';
|
|
2
2
|
|
|
3
3
|
.ant-tabs-content{
|
|
4
|
+
margin-top: $CAP_SPACE_08;
|
|
4
5
|
// .creatives-templates-list.full-mode{
|
|
5
6
|
.v2-pagination-container, .v2-pagination-container-half {
|
|
6
7
|
.ant-tabs-tabpane-active{
|
|
@@ -1427,7 +1428,6 @@
|
|
|
1427
1428
|
justify-content: space-between;
|
|
1428
1429
|
align-items: center;
|
|
1429
1430
|
gap: $CAP_SPACE_08;
|
|
1430
|
-
margin-right: $CAP_SPACE_32;
|
|
1431
1431
|
}
|
|
1432
1432
|
|
|
1433
1433
|
.template-listing-more-btn {
|
|
@@ -4603,6 +4603,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
4603
4603
|
<CapButton
|
|
4604
4604
|
className={`create-new-${channelLowerCase} margin-l-8 margin-b-12`}
|
|
4605
4605
|
type={"primary"}
|
|
4606
|
+
isAddBtn
|
|
4606
4607
|
disabled={this.isCreateDisabled()}
|
|
4607
4608
|
onClick={this.createTemplate}
|
|
4608
4609
|
>
|
|
@@ -13,7 +13,7 @@ export default css`
|
|
|
13
13
|
max-width: 71.25rem;
|
|
14
14
|
margin: 0 auto;
|
|
15
15
|
width: 100%;
|
|
16
|
-
padding: 0
|
|
16
|
+
padding: 0;
|
|
17
17
|
/* Only main channel tabs content, not HTML Editor validation panel tabs */
|
|
18
18
|
> .cap-tab-v2 > .ant-tabs-content-holder > .ant-tabs-content,
|
|
19
19
|
> .cap-tab-v2 > .ant-tabs-content {
|
|
@@ -97,6 +97,12 @@ export default css`
|
|
|
97
97
|
`;
|
|
98
98
|
|
|
99
99
|
export const CapTabStyle = css`
|
|
100
|
-
${(props) => props.isFullMode ? `margin-top: ${CAP_SPACE_24}
|
|
100
|
+
${(props) => props.isFullMode ? `margin-top: ${CAP_SPACE_24};` : ``
|
|
101
|
+
}
|
|
102
|
+
.ant-tabs-nav-list {
|
|
103
|
+
gap: 2rem;
|
|
104
|
+
}
|
|
105
|
+
.ant-tabs-tab + .ant-tabs-tab {
|
|
106
|
+
margin: 0 !important;
|
|
101
107
|
}
|
|
102
108
|
`;
|
|
@@ -47,6 +47,9 @@ import {
|
|
|
47
47
|
NORMALIZED_CHANNEL_ALIASES,
|
|
48
48
|
SMS,
|
|
49
49
|
} from "../CreativesContainer/constants";
|
|
50
|
+
import { MFEEventBus } from '@capillarytech/cap-ui-utils';
|
|
51
|
+
import { isMFEMode } from '../../utils/mfeDetect';
|
|
52
|
+
import appConfig from '../../app-config';
|
|
50
53
|
|
|
51
54
|
const { CapCustomCardList } = CapCustomCard;
|
|
52
55
|
|
|
@@ -54,6 +57,7 @@ const StyledCapTab = withStyles(CapTab, CapTabStyle);
|
|
|
54
57
|
export class TemplatesV2 extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
55
58
|
constructor(props) {
|
|
56
59
|
super(props);
|
|
60
|
+
this.lcpReported = false;
|
|
57
61
|
let defaultChannel = get(this, 'props.channel') || get(this, 'props.params.channel') || 'sms';
|
|
58
62
|
if (defaultChannel === LOYALTY) {
|
|
59
63
|
defaultChannel = 'sms';
|
|
@@ -222,6 +226,23 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
222
226
|
}
|
|
223
227
|
}
|
|
224
228
|
|
|
229
|
+
componentDidUpdate(prevProps) {
|
|
230
|
+
if (
|
|
231
|
+
isMFEMode() &&
|
|
232
|
+
!this.lcpReported &&
|
|
233
|
+
!this.props.Templates.getAllTemplatesInProgress &&
|
|
234
|
+
prevProps.Templates.getAllTemplatesInProgress
|
|
235
|
+
) {
|
|
236
|
+
this.lcpReported = true;
|
|
237
|
+
MFEEventBus.emit('mfe:segment', {
|
|
238
|
+
action: 'stop',
|
|
239
|
+
appId: appConfig.appName,
|
|
240
|
+
type: 'lcp',
|
|
241
|
+
timestamp: performance.now(),
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
225
246
|
componentWillReceiveProps(nextProps) {
|
|
226
247
|
if (this.props.channel !== nextProps.channel) {
|
|
227
248
|
const panes = this.setChannelContent(nextProps.channel, this.state.panes);
|