@capillarytech/creatives-library 9.0.38 → 9.0.40-alpha.0
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 +1 -1
- package/translations/en.json +2 -2
- package/utils/permissions.js +59 -0
- package/utils/tests/permissions.test.js +116 -0
- package/v2Components/AccessForbidden/_accessForbidden.scss +14 -0
- package/v2Components/AccessForbidden/index.js +5 -3
- package/v2Components/AccessForbidden/messages.js +3 -2
- package/v2Components/NoPermissionWrapper/_noPermissionWrapper.scss +12 -0
- package/v2Components/NoPermissionWrapper/index.js +26 -0
- package/v2Containers/App/constants.js +5 -0
- package/v2Containers/Assets/Gallery/_gallery.scss +6 -0
- package/v2Containers/Assets/Gallery/index.js +34 -10
- package/v2Containers/Cap/index.js +5 -2
- package/v2Containers/Cap/messages.js +4 -0
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +2 -2
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +6 -6
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +4 -4
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +32 -32
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +36 -36
- package/v2Containers/Rcs/carouselUtils.js +46 -73
- package/v2Containers/Rcs/components/CarouselCard.js +6 -9
- package/v2Containers/Rcs/constants.js +2 -7
- package/v2Containers/Rcs/index.js +72 -126
- package/v2Containers/Rcs/rcsLibraryHydrationUtils.js +5 -42
- package/v2Containers/Rcs/tests/CarouselCard.test.js +1 -2
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +118 -118
- package/v2Containers/Rcs/tests/carouselUtils.test.js +15 -15
- package/v2Containers/Rcs/tests/index.test.js +10 -232
- package/v2Containers/Rcs/tests/utils.test.js +0 -17
- package/v2Containers/Rcs/utils.js +12 -51
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +8 -8
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +18 -18
- package/v2Containers/Templates/ChannelTypeIllustration.js +13 -2
- package/v2Containers/Templates/_templates.scss +6 -0
- package/v2Containers/Templates/index.js +141 -100
- package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +1 -1
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +174 -121
- package/v2Containers/TemplatesV2/index.js +20 -5
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +268 -268
package/package.json
CHANGED
package/translations/en.json
CHANGED
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"app.v2containers.SmsTrai.Edit.traiEditTitle": "Message",
|
|
64
64
|
"app.v2containers.SmsTrai.Edit.unicodeLabel": "Allow unicode characters",
|
|
65
65
|
"app.v2containers.SmsTrai.Edit.unsupportedTagsValidationError": "Unsupported tags: {unsupportedTags}. Please remove them from this message.",
|
|
66
|
-
"creatives.components.AccessForbidden.forbiddenDesc": "
|
|
67
|
-
"creatives.components.AccessForbidden.forbiddenHeader": "
|
|
66
|
+
"creatives.components.AccessForbidden.forbiddenDesc": "Please contact your organisation administrator to request access.",
|
|
67
|
+
"creatives.components.AccessForbidden.forbiddenHeader": "You don't have permission to view this page.",
|
|
68
68
|
"creatives.components.BreadCrumbs.header": "This is the BreadCrumbs component !",
|
|
69
69
|
"creatives.components.CapTagList.Cancel": "Cancel",
|
|
70
70
|
"creatives.components.CapTagList.Ok": "Ok",
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CREATIVE_VIEW,
|
|
3
|
+
CREATIVE_CREATE,
|
|
4
|
+
CREATIVE_EDIT,
|
|
5
|
+
CREATIVE_DELETE,
|
|
6
|
+
CREATIVES_UI_VIEW,
|
|
7
|
+
} from '../v2Containers/App/constants';
|
|
8
|
+
|
|
9
|
+
export const PERMISSIONS = {
|
|
10
|
+
CREATIVE_VIEW,
|
|
11
|
+
CREATIVE_CREATE,
|
|
12
|
+
CREATIVE_EDIT,
|
|
13
|
+
CREATIVE_DELETE,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const PERMISSION_IDS = {
|
|
17
|
+
[CREATIVE_VIEW]: 1508,
|
|
18
|
+
[CREATIVE_CREATE]: 1509,
|
|
19
|
+
[CREATIVE_EDIT]: 1510,
|
|
20
|
+
[CREATIVE_DELETE]: 1511,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Mode-aware access resolver for the tri-modal Creatives app.
|
|
25
|
+
* Standalone: the `cap` slice is passed as a prop by the connected container.
|
|
26
|
+
* Library / MFE: the host passes a `cap` (or legacy `Global`) prop.
|
|
27
|
+
* Reads the prop first, then falls back — mirrors TemplatesV2's existing
|
|
28
|
+
* `cap.user || Global.user` resolution.
|
|
29
|
+
*/
|
|
30
|
+
export const getUserAccess = (props = {}) => {
|
|
31
|
+
const { cap = {}, Global = {} } = props;
|
|
32
|
+
const user = (cap && cap.user) || (Global && Global.user) || {};
|
|
33
|
+
const isLoaded = !!(
|
|
34
|
+
user &&
|
|
35
|
+
typeof user === 'object' &&
|
|
36
|
+
Object.keys(user).length > 0
|
|
37
|
+
);
|
|
38
|
+
return {
|
|
39
|
+
accessiblePermissions: (isLoaded && user.accessiblePermissions) || [],
|
|
40
|
+
isLoaded,
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const hasPermission = (userAccess, code) => {
|
|
45
|
+
if (!userAccess) return false;
|
|
46
|
+
const granted = userAccess.accessiblePermissions || [];
|
|
47
|
+
const id = PERMISSION_IDS[code];
|
|
48
|
+
return (
|
|
49
|
+
granted.includes(code) ||
|
|
50
|
+
granted.includes(id) ||
|
|
51
|
+
granted.includes(String(id))
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// Zero-impact view gate: honour the new CREATIVE_VIEW OR the legacy CREATIVES_UI_VIEW.
|
|
56
|
+
export const canViewCreatives = userAccess =>
|
|
57
|
+
hasPermission(userAccess, CREATIVE_VIEW) ||
|
|
58
|
+
(userAccess &&
|
|
59
|
+
(userAccess.accessiblePermissions || []).includes(CREATIVES_UI_VIEW));
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test suite for RBAC permission helpers (app/utils/permissions.js).
|
|
3
|
+
* Covers getUserAccess (loaded/unloaded, cap vs Global, missing perms),
|
|
4
|
+
* hasPermission (null guard, code/id/string-id match, empty), and
|
|
5
|
+
* canViewCreatives (new perm, legacy perm, null guard).
|
|
6
|
+
*/
|
|
7
|
+
import {
|
|
8
|
+
PERMISSIONS,
|
|
9
|
+
PERMISSION_IDS,
|
|
10
|
+
getUserAccess,
|
|
11
|
+
hasPermission,
|
|
12
|
+
canViewCreatives,
|
|
13
|
+
} from '../permissions';
|
|
14
|
+
import {
|
|
15
|
+
CREATIVE_VIEW,
|
|
16
|
+
CREATIVE_CREATE,
|
|
17
|
+
CREATIVE_EDIT,
|
|
18
|
+
CREATIVE_DELETE,
|
|
19
|
+
CREATIVES_UI_VIEW,
|
|
20
|
+
} from '../../v2Containers/App/constants';
|
|
21
|
+
|
|
22
|
+
describe('permissions - exported maps', () => {
|
|
23
|
+
it('exposes the four creative permission codes', () => {
|
|
24
|
+
expect(PERMISSIONS).toEqual({
|
|
25
|
+
CREATIVE_VIEW,
|
|
26
|
+
CREATIVE_CREATE,
|
|
27
|
+
CREATIVE_EDIT,
|
|
28
|
+
CREATIVE_DELETE,
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('maps each permission code to its id', () => {
|
|
33
|
+
expect(PERMISSION_IDS[CREATIVE_VIEW]).toBe(1508);
|
|
34
|
+
expect(PERMISSION_IDS[CREATIVE_CREATE]).toBe(1509);
|
|
35
|
+
expect(PERMISSION_IDS[CREATIVE_EDIT]).toBe(1510);
|
|
36
|
+
expect(PERMISSION_IDS[CREATIVE_DELETE]).toBe(1511);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('getUserAccess', () => {
|
|
41
|
+
it('returns unloaded access with empty perms when no props are passed', () => {
|
|
42
|
+
expect(getUserAccess()).toEqual({ accessiblePermissions: [], isLoaded: false });
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('returns unloaded access for an empty props object', () => {
|
|
46
|
+
expect(getUserAccess({})).toEqual({ accessiblePermissions: [], isLoaded: false });
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('reads accessiblePermissions from cap.user when loaded', () => {
|
|
50
|
+
const result = getUserAccess({ cap: { user: { accessiblePermissions: [1508, 1509] } } });
|
|
51
|
+
expect(result).toEqual({ accessiblePermissions: [1508, 1509], isLoaded: true });
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('falls back to Global.user when cap.user is absent', () => {
|
|
55
|
+
const result = getUserAccess({ Global: { user: { accessiblePermissions: ['CREATIVE_VIEW'] } } });
|
|
56
|
+
expect(result).toEqual({ accessiblePermissions: ['CREATIVE_VIEW'], isLoaded: true });
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('is not loaded when the user object is empty', () => {
|
|
60
|
+
expect(getUserAccess({ cap: { user: {} } })).toEqual({ accessiblePermissions: [], isLoaded: false });
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('defaults accessiblePermissions to [] when a loaded user has none', () => {
|
|
64
|
+
const result = getUserAccess({ cap: { user: { id: 42 } } });
|
|
65
|
+
expect(result).toEqual({ accessiblePermissions: [], isLoaded: true });
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe('hasPermission', () => {
|
|
70
|
+
it('returns false when userAccess is null or undefined', () => {
|
|
71
|
+
expect(hasPermission(null, CREATIVE_VIEW)).toBe(false);
|
|
72
|
+
expect(hasPermission(undefined, CREATIVE_VIEW)).toBe(false);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('returns false when accessiblePermissions is missing', () => {
|
|
76
|
+
expect(hasPermission({}, CREATIVE_VIEW)).toBe(false);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('matches by permission code', () => {
|
|
80
|
+
expect(hasPermission({ accessiblePermissions: [CREATIVE_CREATE] }, CREATIVE_CREATE)).toBe(true);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('matches by numeric permission id', () => {
|
|
84
|
+
expect(hasPermission({ accessiblePermissions: [1509] }, CREATIVE_CREATE)).toBe(true);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('matches by string permission id', () => {
|
|
88
|
+
expect(hasPermission({ accessiblePermissions: ['1509'] }, CREATIVE_CREATE)).toBe(true);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('returns false when the permission is not granted', () => {
|
|
92
|
+
expect(hasPermission({ accessiblePermissions: [CREATIVE_VIEW] }, CREATIVE_DELETE)).toBe(false);
|
|
93
|
+
expect(hasPermission({ accessiblePermissions: [] }, CREATIVE_VIEW)).toBe(false);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
describe('canViewCreatives', () => {
|
|
98
|
+
it('allows when the new CREATIVE_VIEW permission is present', () => {
|
|
99
|
+
expect(canViewCreatives({ accessiblePermissions: [CREATIVE_VIEW] })).toBe(true);
|
|
100
|
+
expect(canViewCreatives({ accessiblePermissions: [1508] })).toBe(true);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('allows via the legacy CREATIVES_UI_VIEW permission', () => {
|
|
104
|
+
expect(canViewCreatives({ accessiblePermissions: [CREATIVES_UI_VIEW] })).toBe(true);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('returns a falsy value when userAccess is null', () => {
|
|
108
|
+
// short-circuits on `userAccess &&`, so returns null (falsy) rather than false
|
|
109
|
+
expect(canViewCreatives(null)).toBeFalsy();
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('returns false when neither view permission is present', () => {
|
|
113
|
+
expect(canViewCreatives({ accessiblePermissions: [CREATIVE_CREATE] })).toBe(false);
|
|
114
|
+
expect(canViewCreatives({})).toBe(false);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Access-denied screen: rbac-lock icon + heading + subtext (matches the shared
|
|
2
|
+
// "no access" screen used across Loyalty+ / Org Settings).
|
|
3
|
+
.no-access-icon {
|
|
4
|
+
font-size: 48px;
|
|
5
|
+
color: #8c8c8c;
|
|
6
|
+
}
|
|
7
|
+
.no-access-title {
|
|
8
|
+
margin-top: 16px;
|
|
9
|
+
}
|
|
10
|
+
.no-access-text {
|
|
11
|
+
margin-top: 8px;
|
|
12
|
+
color: #6b778c;
|
|
13
|
+
max-width: 420px;
|
|
14
|
+
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FormattedMessage } from 'react-intl';
|
|
3
|
-
import { CapRow, CapHeading } from '@capillarytech/cap-ui-library';
|
|
3
|
+
import { CapRow, CapHeading, CapIcon } from '@capillarytech/cap-ui-library';
|
|
4
4
|
import messages from './messages';
|
|
5
|
+
import './_accessForbidden.scss';
|
|
5
6
|
|
|
6
7
|
const AccessForbidden = () => (
|
|
7
8
|
<CapRow type='flex' vertical justify='center' align='middle' className="margin-t-32 text-align-center">
|
|
8
|
-
<
|
|
9
|
+
<CapIcon type="rbac-lock" className="no-access-icon" />
|
|
10
|
+
<CapHeading type="h3" className="no-access-title">
|
|
9
11
|
<FormattedMessage {...messages.forbiddenHeader} />
|
|
10
12
|
</CapHeading>
|
|
11
|
-
<CapHeading type="
|
|
13
|
+
<CapHeading type="h6" className="no-access-text">
|
|
12
14
|
<FormattedMessage {...messages.forbiddenDesc} />
|
|
13
15
|
</CapHeading>
|
|
14
16
|
</CapRow>
|
|
@@ -5,10 +5,11 @@ const prefix = 'creatives.components.AccessForbidden';
|
|
|
5
5
|
export default defineMessages({
|
|
6
6
|
forbiddenHeader: {
|
|
7
7
|
id: `${prefix}.forbiddenHeader`,
|
|
8
|
-
defaultMessage: '
|
|
8
|
+
defaultMessage: "You don't have permission to view this page.",
|
|
9
9
|
},
|
|
10
10
|
forbiddenDesc: {
|
|
11
11
|
id: `${prefix}.forbiddenDesc`,
|
|
12
|
-
defaultMessage:
|
|
12
|
+
defaultMessage:
|
|
13
|
+
'Please contact your organisation administrator to request access.',
|
|
13
14
|
},
|
|
14
15
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Dim + block interaction for a control the user lacks permission for.
|
|
2
|
+
// The wrapper keeps pointer events (so the CapTooltip still shows on hover) while the
|
|
3
|
+
// inner control is dimmed and non-interactive.
|
|
4
|
+
.rbac-no-permission {
|
|
5
|
+
display: inline-block;
|
|
6
|
+
cursor: not-allowed;
|
|
7
|
+
|
|
8
|
+
> * {
|
|
9
|
+
opacity: 0.4;
|
|
10
|
+
pointer-events: none;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormattedMessage } from 'react-intl';
|
|
3
|
+
import CapTooltip from '@capillarytech/cap-ui-library/CapTooltip';
|
|
4
|
+
import globalMessages from '../../v2Containers/Cap/messages';
|
|
5
|
+
import './_noPermissionWrapper.scss';
|
|
6
|
+
|
|
7
|
+
// Wraps a single control and, when the user is not `allowed`, dims it + blocks
|
|
8
|
+
// interaction (via CSS) and shows a permission tooltip on hover. Uses CapTooltip
|
|
9
|
+
// instead of hand-rolled positioning/portals.
|
|
10
|
+
const NoPermissionWrapper = ({ allowed, children, message }) => {
|
|
11
|
+
const child = React.Children.only(children);
|
|
12
|
+
|
|
13
|
+
if (allowed || child.props.disabled) {
|
|
14
|
+
return child;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<CapTooltip
|
|
19
|
+
title={message || <FormattedMessage {...globalMessages.noPermissionAction} />}
|
|
20
|
+
>
|
|
21
|
+
<span className="rbac-no-permission">{child}</span>
|
|
22
|
+
</CapTooltip>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default NoPermissionWrapper;
|
|
@@ -97,6 +97,11 @@ export const BEE_PLUGIN = 'BEE_PLUGIN';
|
|
|
97
97
|
export const NO_COMMUNICATION = 'NO_COMMUNICATION';
|
|
98
98
|
export const FTP = 'FTP';
|
|
99
99
|
export const CREATIVES_UI_VIEW = 'CREATIVES_UI_VIEW';
|
|
100
|
+
// VAPT RBAC granular Creatives permissions (module creatives/ui)
|
|
101
|
+
export const CREATIVE_VIEW = 'CREATIVE_VIEW';
|
|
102
|
+
export const CREATIVE_CREATE = 'CREATIVE_CREATE';
|
|
103
|
+
export const CREATIVE_EDIT = 'CREATIVE_EDIT';
|
|
104
|
+
export const CREATIVE_DELETE = 'CREATIVE_DELETE';
|
|
100
105
|
|
|
101
106
|
export const APPLY_NOW = <FormattedMessage {...globalMessages.applyNow} />;
|
|
102
107
|
export const NO_CALL_TO_ACTION = <FormattedMessage {...globalMessages.noCallToAction} />;
|
|
@@ -13,10 +13,12 @@ import { FormattedMessage, injectIntl, intlShape } from 'react-intl';
|
|
|
13
13
|
import { createStructuredSelector } from 'reselect';
|
|
14
14
|
import moment from "moment";
|
|
15
15
|
import _ from "lodash";
|
|
16
|
-
import { CapHeading, CapHeader, CapInput, CapButton, CapIcon, CapDropdown, CapMenu, CapCustomCard, CapSlideBox, CapLabel, CapIllustration, CapNotification,} from '@capillarytech/cap-ui-library';
|
|
16
|
+
import { CapHeading, CapHeader, CapInput, CapButton, CapIcon, CapDropdown, CapMenu, CapCustomCard, CapSlideBox, CapLabel, CapIllustration, CapNotification, CapTooltip,} from '@capillarytech/cap-ui-library';
|
|
17
|
+
import NoPermissionWrapper from '../../../v2Components/NoPermissionWrapper';
|
|
17
18
|
import { Popover } from 'antd';
|
|
18
19
|
import makeSelectGallery from './selectors';
|
|
19
20
|
import messages from './messages';
|
|
21
|
+
import globalMessages from '../../Cap/messages';
|
|
20
22
|
import * as actions from './actions';
|
|
21
23
|
import { UserIsAuthenticated } from '../../../utils/authWrapper';
|
|
22
24
|
import * as globalActions from '../../Cap/actions';
|
|
@@ -307,9 +309,18 @@ export class Gallery extends React.Component { // eslint-disable-line react/pref
|
|
|
307
309
|
<div className="more-icon-wrapper">
|
|
308
310
|
<Popover
|
|
309
311
|
placement="leftTop"
|
|
310
|
-
content={<div
|
|
311
|
-
<
|
|
312
|
-
|
|
312
|
+
content={<div>
|
|
313
|
+
<p
|
|
314
|
+
className={this.props.canDelete === false ? 'rbac-disabled' : ''}
|
|
315
|
+
onClick={() => { if (this.props.canDelete !== false) this.deleteAsset(asset); }}
|
|
316
|
+
>
|
|
317
|
+
{this.props.canDelete === false ? (
|
|
318
|
+
<CapTooltip title={<FormattedMessage {...globalMessages.noPermissionAction} />}><span><FormattedMessage {...messages.delete} /></span></CapTooltip>
|
|
319
|
+
) : (
|
|
320
|
+
<FormattedMessage {...messages.delete} />
|
|
321
|
+
)}
|
|
322
|
+
</p>
|
|
323
|
+
</div>} trigger="click">
|
|
313
324
|
<i className="material-icons creative-icons">more_vert</i>
|
|
314
325
|
</Popover>
|
|
315
326
|
</div>
|
|
@@ -345,8 +356,15 @@ export class Gallery extends React.Component { // eslint-disable-line react/pref
|
|
|
345
356
|
<CapDropdown
|
|
346
357
|
overlay={
|
|
347
358
|
<CapMenu>
|
|
348
|
-
<CapMenu.Item
|
|
349
|
-
|
|
359
|
+
<CapMenu.Item
|
|
360
|
+
className={`delete-gallery ${this.props.canDelete === false ? 'rbac-disabled' : ''}`.trim()}
|
|
361
|
+
onClick={() => { if (this.props.canDelete !== false) this.deleteAsset(template); }}
|
|
362
|
+
>
|
|
363
|
+
{this.props.canDelete === false ? (
|
|
364
|
+
<CapTooltip title={<FormattedMessage {...globalMessages.noPermissionAction} />}><span><FormattedMessage {...messages.delete} /></span></CapTooltip>
|
|
365
|
+
) : (
|
|
366
|
+
<FormattedMessage {...messages.delete} />
|
|
367
|
+
)}
|
|
350
368
|
</CapMenu.Item>
|
|
351
369
|
</CapMenu>
|
|
352
370
|
}
|
|
@@ -382,7 +400,11 @@ export class Gallery extends React.Component { // eslint-disable-line react/pref
|
|
|
382
400
|
_.isEmpty(templates) &&
|
|
383
401
|
_.isEmpty(searchText) &&
|
|
384
402
|
!searchLoader &&
|
|
385
|
-
<CapIllustration
|
|
403
|
+
<CapIllustration
|
|
404
|
+
{...this.getIllustrationProps}
|
|
405
|
+
disabled={this.props.canCreate === false}
|
|
406
|
+
buttonTooltip={this.props.canCreate === false ? this.props.intl.formatMessage(globalMessages.noPermissionAction) : undefined}
|
|
407
|
+
/>
|
|
386
408
|
)}
|
|
387
409
|
</div>
|
|
388
410
|
}
|
|
@@ -458,9 +480,11 @@ export class Gallery extends React.Component { // eslint-disable-line react/pref
|
|
|
458
480
|
<div style={{ textAlign: 'right', marginTop: '16px', width: '50%'}}>
|
|
459
481
|
<form encType="multipart/form-data" id="myForm">
|
|
460
482
|
<input style={{ display: 'none'}} id="fileName" type="file" onClick={(e) => {e.target.value=null}} onChange={(e) => this.uploadImages(e, {files: e.target.files})} accept="image/*" multiple/>
|
|
461
|
-
<
|
|
462
|
-
<
|
|
463
|
-
|
|
483
|
+
<NoPermissionWrapper allowed={this.props.canCreate !== false}>
|
|
484
|
+
<CapButton className="upload-image-gallery" type={this.props.location.query.type !== 'embedded' ? 'primary' : 'secondary'} onClick={(e) => this.openFileDialog(e)} style={{float: 'right'}}>
|
|
485
|
+
<FormattedMessage {...messages.upload} />
|
|
486
|
+
</CapButton>
|
|
487
|
+
</NoPermissionWrapper>
|
|
464
488
|
</form>
|
|
465
489
|
</div>
|
|
466
490
|
)
|
|
@@ -19,7 +19,7 @@ import * as appActions from '../App/actions';
|
|
|
19
19
|
import config from '../../config/app';
|
|
20
20
|
import NavigationBar from '../../v2Components/NavigationBar';
|
|
21
21
|
import { engagePlusPublicPath, publicPath } from '../../config/path';
|
|
22
|
-
import { GTM_TRACKING_ID, CREATIVES_UI_VIEW, FAILURE } from '../App/constants';
|
|
22
|
+
import { GTM_TRACKING_ID, CREATIVES_UI_VIEW, CREATIVE_VIEW, FAILURE } from '../App/constants';
|
|
23
23
|
import { makeSelectLocale } from '../../v2Containers/LanguageProvider/selectors';
|
|
24
24
|
import CapSupportVideosWrapper from '@capillarytech/cap-ui-library/CapSupportVideosWrapper';
|
|
25
25
|
import { replaceDynamicAndCompare } from '@capillarytech/cap-ui-library/CapSupportVideosWrapper/utils';
|
|
@@ -115,7 +115,10 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
115
115
|
const parentModule = pathname.substring(pathname.lastIndexOf('/') + 1);
|
|
116
116
|
this.props.actions.getUserData((userData, currentOrgDetails = {}) => { //taking currentOrgDetails as we are not getting this data in this.props.Global props.
|
|
117
117
|
const { accessibleFeatures = [] } = currentOrgDetails;
|
|
118
|
-
if (
|
|
118
|
+
if (
|
|
119
|
+
!userData.accessiblePermissions.includes(CREATIVES_UI_VIEW) &&
|
|
120
|
+
!userData.accessiblePermissions.includes(CREATIVE_VIEW)
|
|
121
|
+
) {
|
|
119
122
|
this.setState({ isCreativesAccessible: false });
|
|
120
123
|
}
|
|
121
124
|
const userGtmData = this.getUserGtmData();
|
|
@@ -209,5 +209,9 @@ export default defineMessages({
|
|
|
209
209
|
id: 'creatives.componentsV2.autofill',
|
|
210
210
|
defaultMessage: 'Autofill',
|
|
211
211
|
},
|
|
212
|
+
noPermissionAction: {
|
|
213
|
+
id: 'creatives.componentsV2.noPermissionAction',
|
|
214
|
+
defaultMessage: "You don't have permission to perform this action.",
|
|
215
|
+
},
|
|
212
216
|
});
|
|
213
217
|
|
|
@@ -141,8 +141,8 @@ exports[`<Cap /> should render correct component 1`] = `
|
|
|
141
141
|
"app.v2containers.SmsTrai.Edit.traiEditTitle": "Message",
|
|
142
142
|
"app.v2containers.SmsTrai.Edit.unicodeLabel": "Allow unicode characters",
|
|
143
143
|
"app.v2containers.SmsTrai.Edit.unsupportedTagsValidationError": "Unsupported tags: {unsupportedTags}. Please remove them from this message.",
|
|
144
|
-
"creatives.components.AccessForbidden.forbiddenDesc": "
|
|
145
|
-
"creatives.components.AccessForbidden.forbiddenHeader": "
|
|
144
|
+
"creatives.components.AccessForbidden.forbiddenDesc": "Please contact your organisation administrator to request access.",
|
|
145
|
+
"creatives.components.AccessForbidden.forbiddenHeader": "You don't have permission to view this page.",
|
|
146
146
|
"creatives.components.BreadCrumbs.header": "This is the BreadCrumbs component !",
|
|
147
147
|
"creatives.components.CapTagList.Cancel": "Cancel",
|
|
148
148
|
"creatives.components.CapTagList.Ok": "Ok",
|
|
@@ -87,8 +87,8 @@ exports[`Creatives line image carousel test/> should render 1`] = `
|
|
|
87
87
|
"app.v2containers.SmsTrai.Edit.traiEditTitle": "Message",
|
|
88
88
|
"app.v2containers.SmsTrai.Edit.unicodeLabel": "Allow unicode characters",
|
|
89
89
|
"app.v2containers.SmsTrai.Edit.unsupportedTagsValidationError": "Unsupported tags: {unsupportedTags}. Please remove them from this message.",
|
|
90
|
-
"creatives.components.AccessForbidden.forbiddenDesc": "
|
|
91
|
-
"creatives.components.AccessForbidden.forbiddenHeader": "
|
|
90
|
+
"creatives.components.AccessForbidden.forbiddenDesc": "Please contact your organisation administrator to request access.",
|
|
91
|
+
"creatives.components.AccessForbidden.forbiddenHeader": "You don't have permission to view this page.",
|
|
92
92
|
"creatives.components.BreadCrumbs.header": "This is the BreadCrumbs component !",
|
|
93
93
|
"creatives.components.CapTagList.Cancel": "Cancel",
|
|
94
94
|
"creatives.components.CapTagList.Ok": "Ok",
|
|
@@ -4228,8 +4228,8 @@ exports[`Creatives line image carousel test/> should render 2`] = `
|
|
|
4228
4228
|
"app.v2containers.SmsTrai.Edit.traiEditTitle": "Message",
|
|
4229
4229
|
"app.v2containers.SmsTrai.Edit.unicodeLabel": "Allow unicode characters",
|
|
4230
4230
|
"app.v2containers.SmsTrai.Edit.unsupportedTagsValidationError": "Unsupported tags: {unsupportedTags}. Please remove them from this message.",
|
|
4231
|
-
"creatives.components.AccessForbidden.forbiddenDesc": "
|
|
4232
|
-
"creatives.components.AccessForbidden.forbiddenHeader": "
|
|
4231
|
+
"creatives.components.AccessForbidden.forbiddenDesc": "Please contact your organisation administrator to request access.",
|
|
4232
|
+
"creatives.components.AccessForbidden.forbiddenHeader": "You don't have permission to view this page.",
|
|
4233
4233
|
"creatives.components.BreadCrumbs.header": "This is the BreadCrumbs component !",
|
|
4234
4234
|
"creatives.components.CapTagList.Cancel": "Cancel",
|
|
4235
4235
|
"creatives.components.CapTagList.Ok": "Ok",
|
|
@@ -8508,8 +8508,8 @@ exports[`Creatives line image carousel test/> should render 3`] = `
|
|
|
8508
8508
|
"app.v2containers.SmsTrai.Edit.traiEditTitle": "Message",
|
|
8509
8509
|
"app.v2containers.SmsTrai.Edit.unicodeLabel": "Allow unicode characters",
|
|
8510
8510
|
"app.v2containers.SmsTrai.Edit.unsupportedTagsValidationError": "Unsupported tags: {unsupportedTags}. Please remove them from this message.",
|
|
8511
|
-
"creatives.components.AccessForbidden.forbiddenDesc": "
|
|
8512
|
-
"creatives.components.AccessForbidden.forbiddenHeader": "
|
|
8511
|
+
"creatives.components.AccessForbidden.forbiddenDesc": "Please contact your organisation administrator to request access.",
|
|
8512
|
+
"creatives.components.AccessForbidden.forbiddenHeader": "You don't have permission to view this page.",
|
|
8513
8513
|
"creatives.components.BreadCrumbs.header": "This is the BreadCrumbs component !",
|
|
8514
8514
|
"creatives.components.CapTagList.Cancel": "Cancel",
|
|
8515
8515
|
"creatives.components.CapTagList.Ok": "Ok",
|
|
@@ -87,8 +87,8 @@ exports[`line wrapper test/> should render line component new 1`] = `
|
|
|
87
87
|
"app.v2containers.SmsTrai.Edit.traiEditTitle": "Message",
|
|
88
88
|
"app.v2containers.SmsTrai.Edit.unicodeLabel": "Allow unicode characters",
|
|
89
89
|
"app.v2containers.SmsTrai.Edit.unsupportedTagsValidationError": "Unsupported tags: {unsupportedTags}. Please remove them from this message.",
|
|
90
|
-
"creatives.components.AccessForbidden.forbiddenDesc": "
|
|
91
|
-
"creatives.components.AccessForbidden.forbiddenHeader": "
|
|
90
|
+
"creatives.components.AccessForbidden.forbiddenDesc": "Please contact your organisation administrator to request access.",
|
|
91
|
+
"creatives.components.AccessForbidden.forbiddenHeader": "You don't have permission to view this page.",
|
|
92
92
|
"creatives.components.BreadCrumbs.header": "This is the BreadCrumbs component !",
|
|
93
93
|
"creatives.components.CapTagList.Cancel": "Cancel",
|
|
94
94
|
"creatives.components.CapTagList.Ok": "Ok",
|
|
@@ -15138,8 +15138,8 @@ exports[`line wrapper test/> should render line component old 1`] = `
|
|
|
15138
15138
|
"app.v2containers.SmsTrai.Edit.traiEditTitle": "Message",
|
|
15139
15139
|
"app.v2containers.SmsTrai.Edit.unicodeLabel": "Allow unicode characters",
|
|
15140
15140
|
"app.v2containers.SmsTrai.Edit.unsupportedTagsValidationError": "Unsupported tags: {unsupportedTags}. Please remove them from this message.",
|
|
15141
|
-
"creatives.components.AccessForbidden.forbiddenDesc": "
|
|
15142
|
-
"creatives.components.AccessForbidden.forbiddenHeader": "
|
|
15141
|
+
"creatives.components.AccessForbidden.forbiddenDesc": "Please contact your organisation administrator to request access.",
|
|
15142
|
+
"creatives.components.AccessForbidden.forbiddenHeader": "You don't have permission to view this page.",
|
|
15143
15143
|
"creatives.components.BreadCrumbs.header": "This is the BreadCrumbs component !",
|
|
15144
15144
|
"creatives.components.CapTagList.Cancel": "Cancel",
|
|
15145
15145
|
"creatives.components.CapTagList.Ok": "Ok",
|