@capillarytech/creatives-library 9.0.32 → 9.0.34
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/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/Rcs/index.js +3 -3
- package/v2Containers/Templates/_templates.scss +1 -1
- package/v2Containers/Templates/index.js +1 -0
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +5 -0
- package/v2Containers/TemplatesV2/TemplatesV2.style.js +8 -3
- package/v2Containers/TemplatesV2/index.js +22 -9
|
@@ -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
|
+
}
|
|
@@ -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) => {
|
|
@@ -1066,9 +1066,9 @@ export const Rcs = (props) => {
|
|
|
1066
1066
|
if (mediaType) {
|
|
1067
1067
|
setTemplateMediaType(mediaType);
|
|
1068
1068
|
}
|
|
1069
|
-
const tempOrientation = cardSettings
|
|
1070
|
-
const tempAlignment = cardSettings
|
|
1071
|
-
const tempHeight = mediaData
|
|
1069
|
+
const tempOrientation = cardSettings?.cardOrientation;
|
|
1070
|
+
const tempAlignment = cardSettings?.mediaAlignment;
|
|
1071
|
+
const tempHeight = mediaData?.height;
|
|
1072
1072
|
|
|
1073
1073
|
// Map to actual RCS_IMAGE_DIMENSIONS keys
|
|
1074
1074
|
let tempDimension;
|
|
@@ -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
|
>
|
|
@@ -239,6 +239,7 @@ exports[`Test Templates container Should render sms illustration when no templat
|
|
|
239
239
|
<CapButton
|
|
240
240
|
className="create-new-sms margin-l-8 margin-b-12"
|
|
241
241
|
disabled={false}
|
|
242
|
+
isAddBtn={true}
|
|
242
243
|
onClick={[Function]}
|
|
243
244
|
type="primary"
|
|
244
245
|
>
|
|
@@ -813,6 +814,7 @@ exports[`Test Templates container Should render temlates when whatsapp templates
|
|
|
813
814
|
<CapButton
|
|
814
815
|
className="create-new-whatsapp margin-l-8 margin-b-12"
|
|
815
816
|
disabled={false}
|
|
817
|
+
isAddBtn={true}
|
|
816
818
|
onClick={[Function]}
|
|
817
819
|
type="primary"
|
|
818
820
|
>
|
|
@@ -1223,6 +1225,7 @@ exports[`Test Templates container Test max templates exceeded 1`] = `
|
|
|
1223
1225
|
<CapButton
|
|
1224
1226
|
className="create-new-whatsapp margin-l-8 margin-b-12"
|
|
1225
1227
|
disabled={false}
|
|
1228
|
+
isAddBtn={true}
|
|
1226
1229
|
onClick={[Function]}
|
|
1227
1230
|
type="primary"
|
|
1228
1231
|
>
|
|
@@ -1696,6 +1699,7 @@ exports[`Test Templates container Test max templates not exceeded 1`] = `
|
|
|
1696
1699
|
<CapButton
|
|
1697
1700
|
className="create-new-whatsapp margin-l-8 margin-b-12"
|
|
1698
1701
|
disabled={false}
|
|
1702
|
+
isAddBtn={true}
|
|
1699
1703
|
onClick={[Function]}
|
|
1700
1704
|
type="primary"
|
|
1701
1705
|
>
|
|
@@ -2169,6 +2173,7 @@ exports[`Test Templates container Test max templates warning 1`] = `
|
|
|
2169
2173
|
<CapButton
|
|
2170
2174
|
className="create-new-whatsapp margin-l-8 margin-b-12"
|
|
2171
2175
|
disabled={false}
|
|
2176
|
+
isAddBtn={true}
|
|
2172
2177
|
onClick={[Function]}
|
|
2173
2178
|
type="primary"
|
|
2174
2179
|
>
|
|
@@ -10,10 +10,9 @@ export default css`
|
|
|
10
10
|
|
|
11
11
|
.component-wrapper {
|
|
12
12
|
${(props) => props.isFullMode ? `
|
|
13
|
-
max-width: 71.25rem;
|
|
14
13
|
margin: 0 auto;
|
|
15
14
|
width: 100%;
|
|
16
|
-
padding: 0
|
|
15
|
+
padding: 0;
|
|
17
16
|
/* Only main channel tabs content, not HTML Editor validation panel tabs */
|
|
18
17
|
> .cap-tab-v2 > .ant-tabs-content-holder > .ant-tabs-content,
|
|
19
18
|
> .cap-tab-v2 > .ant-tabs-content {
|
|
@@ -97,6 +96,12 @@ export default css`
|
|
|
97
96
|
`;
|
|
98
97
|
|
|
99
98
|
export const CapTabStyle = css`
|
|
100
|
-
${(props) => props.isFullMode ? `margin-top: ${CAP_SPACE_24}
|
|
99
|
+
${(props) => props.isFullMode ? `margin-top: ${CAP_SPACE_24};` : ``
|
|
100
|
+
}
|
|
101
|
+
.ant-tabs-nav-list {
|
|
102
|
+
gap: 2rem;
|
|
103
|
+
}
|
|
104
|
+
.ant-tabs-tab + .ant-tabs-tab {
|
|
105
|
+
margin: 0 !important;
|
|
101
106
|
}
|
|
102
107
|
`;
|
|
@@ -10,7 +10,7 @@ import { connect } from 'react-redux';
|
|
|
10
10
|
import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
|
|
11
11
|
import { createStructuredSelector } from 'reselect';
|
|
12
12
|
import { bindActionCreators, compose } from 'redux';
|
|
13
|
-
import { CapTab, CapCustomCard, CapButton,
|
|
13
|
+
import { CapTab, CapCustomCard, CapButton, CapIcon, CapSpin, CapTooltip } from '@capillarytech/cap-ui-library';
|
|
14
14
|
import { find, get, pick } from 'lodash';
|
|
15
15
|
import Helmet from 'react-helmet';
|
|
16
16
|
|
|
@@ -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);
|
|
@@ -422,14 +443,6 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
422
443
|
/>
|
|
423
444
|
)}
|
|
424
445
|
<section className="component-wrapper">
|
|
425
|
-
{isFullMode && (
|
|
426
|
-
<CapHeader
|
|
427
|
-
title={<FormattedMessage {...messages.creatives} />}
|
|
428
|
-
{...(!useLocalTemplates && {
|
|
429
|
-
description: <FormattedMessage {...messages.creativesDesc} />,
|
|
430
|
-
})}
|
|
431
|
-
/>
|
|
432
|
-
)}
|
|
433
446
|
{hideChannelTabsForLocalSms ? (
|
|
434
447
|
<section className="templates-v2-local-sms-pane">{activeLocalPane?.content}</section>
|
|
435
448
|
) : (
|