Skip to content

Commit c278167

Browse files
author
feixuanli
authored
feat(classification): add watermarking to security controls (#2807)
1 parent f9b78a1 commit c278167

7 files changed

Lines changed: 87 additions & 47 deletions

File tree

i18n/en-US.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,8 +1234,12 @@ boxui.securityControls.shortSharing = Sharing restriction applies
12341234
boxui.securityControls.shortSharingApp = Sharing and app restrictions apply
12351235
# Short summary displayed for classification when both sharing and download restrictions are applied to it
12361236
boxui.securityControls.shortSharingDownload = Sharing and download restrictions apply
1237+
# Short summary displayed for classification when watermarking is applied to it
1238+
boxui.securityControls.shortWatermarking = Watermarking applied
12371239
# Button to display security controls modal
12381240
boxui.securityControls.viewAll = View All
1241+
# Bullet point that summarizes watermarking applied to classification
1242+
boxui.securityControls.watermarkingApplied = Watermarking will be applied for Previewer Uploaders, Previewers and Viewers.
12391243
# Bullet point that summarizes web download restrictions applied to classification, when restriction applies to external users
12401244
boxui.securityControls.webDownloadExternal = Download restricted on web for external users.
12411245
# Bullet point that summarizes web download restrictions applied to classification, when restriction applies to external users and managed users except Owners/Co-Owners

src/features/classification/constants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ const ACCESS_POLICY_RESTRICTION: {
1717
EXTERNAL_COLLAB: 'externalCollab',
1818
FTP: 'ftp',
1919
SHARED_LINK: 'sharedLink',
20+
WATERMARK: 'watermark',
2021
} = {
2122
SHARED_LINK: 'sharedLink',
2223
DOWNLOAD: 'download',
2324
EXTERNAL_COLLAB: 'externalCollab',
2425
APP: 'app',
2526
FTP: 'ftp',
27+
WATERMARK: 'watermark',
2628
};
2729

2830
const DOWNLOAD_CONTROL: {

src/features/classification/flowTypes.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,16 @@ type SharedLinkRestrictions = {
4444
accessLevel: SharedLinkAccessLevel,
4545
};
4646

47+
type watermarkApplied = {
48+
enabled?: boolean,
49+
};
50+
4751
type Controls = {
4852
app?: ApplicationRestriction,
4953
download?: DownloadRestrictions,
5054
externalCollab?: ExternalCollabRestriction,
5155
sharedLink?: SharedLinkRestrictions,
56+
watermark?: watermarkApplied,
5257
};
5358

5459
type ControlsFormat = $Values<typeof SECURITY_CONTROLS_FORMAT>;

src/features/classification/security-controls/SecurityControls.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ class SecurityControls extends React.Component<Props, State> {
6767
if (controlsFormat === FULL) {
6868
items = getFullSecurityControlsMessages(controls, maxAppCount);
6969
} else {
70-
const shortMessage = getShortSecurityControlsMessage(controls);
71-
items = shortMessage ? [shortMessage] : [];
70+
items = getShortSecurityControlsMessage(controls);
7271

7372
if (items.length && controlsFormat === SHORT_WITH_BTN) {
7473
modalItems = getFullSecurityControlsMessages(controls, maxAppCount);

src/features/classification/security-controls/__tests__/utils.test.js

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,69 +25,75 @@ describe('features/classification/security-controls/utils', () => {
2525

2626
describe('getShortSecurityControlsMessage()', () => {
2727
test('should return null when there are no restrictions', () => {
28-
expect(getShortSecurityControlsMessage({})).toBeNull();
28+
expect(getShortSecurityControlsMessage({})).toEqual([]);
2929
});
3030

3131
test('should not return messages when shared link restriction has a "public" access level', () => {
3232
accessPolicy = { sharedLink: { accessLevel: PUBLIC } };
33-
expect(getShortSecurityControlsMessage(accessPolicy)).toBeNull();
33+
expect(getShortSecurityControlsMessage(accessPolicy)).toEqual([]);
3434
});
3535

36-
test('should return all restrictions message when all restrictions are present', () => {
37-
accessPolicy = { sharedLink: {}, download: {}, externalCollab: {}, app: {} };
38-
expect(getShortSecurityControlsMessage(accessPolicy).message).toBe(messages.shortAllRestrictions);
36+
test('should return correct message when all restrictions are present', () => {
37+
accessPolicy = { sharedLink: {}, download: {}, externalCollab: {}, app: {}, watermark: {} };
38+
expect(getShortSecurityControlsMessage(accessPolicy)[0].message).toBe(messages.shortAllRestrictions);
39+
expect(getShortSecurityControlsMessage(accessPolicy)[1].message).toBe(messages.shortWatermarking);
3940
});
4041

4142
test('should return all restrictions message when download, app and either shared link, or external collab restrictions are present', () => {
4243
accessPolicy = { sharedLink: {}, download: {}, app: {} };
43-
expect(getShortSecurityControlsMessage(accessPolicy).message).toBe(messages.shortAllRestrictions);
44+
expect(getShortSecurityControlsMessage(accessPolicy)[0].message).toBe(messages.shortAllRestrictions);
4445
accessPolicy = { externalCollab: {}, download: {}, app: {} };
45-
expect(getShortSecurityControlsMessage(accessPolicy).message).toBe(messages.shortAllRestrictions);
46+
expect(getShortSecurityControlsMessage(accessPolicy)[0].message).toBe(messages.shortAllRestrictions);
4647
});
4748

4849
test('should return correct message when download and either shared link, or external collab restrictions are present', () => {
4950
accessPolicy = { sharedLink: {}, download: {} };
50-
expect(getShortSecurityControlsMessage(accessPolicy).message).toBe(messages.shortSharingDownload);
51+
expect(getShortSecurityControlsMessage(accessPolicy)[0].message).toBe(messages.shortSharingDownload);
5152
accessPolicy = { externalCollab: {}, download: {} };
52-
expect(getShortSecurityControlsMessage(accessPolicy).message).toBe(messages.shortSharingDownload);
53+
expect(getShortSecurityControlsMessage(accessPolicy)[0].message).toBe(messages.shortSharingDownload);
5354
});
5455

5556
test('should return correct message when app and either shared link, or external collab restrictions are present', () => {
5657
accessPolicy = { sharedLink: {}, app: {} };
57-
expect(getShortSecurityControlsMessage(accessPolicy).message).toBe(messages.shortSharingApp);
58+
expect(getShortSecurityControlsMessage(accessPolicy)[0].message).toBe(messages.shortSharingApp);
5859
accessPolicy = { externalCollab: {}, app: {} };
59-
expect(getShortSecurityControlsMessage(accessPolicy).message).toBe(messages.shortSharingApp);
60+
expect(getShortSecurityControlsMessage(accessPolicy)[0].message).toBe(messages.shortSharingApp);
6061
});
6162

6263
test('should return correct message when app and download restrictions are present', () => {
6364
accessPolicy = { download: {}, app: {} };
64-
expect(getShortSecurityControlsMessage(accessPolicy).message).toBe(messages.shortDownloadApp);
65+
expect(getShortSecurityControlsMessage(accessPolicy)[0].message).toBe(messages.shortDownloadApp);
6566
});
6667

6768
test('should return correct message when there are shared link or external collab restrictions', () => {
6869
accessPolicy = { sharedLink: {}, externalCollab: {} };
69-
expect(getShortSecurityControlsMessage(accessPolicy).message).toBe(messages.shortSharing);
70+
expect(getShortSecurityControlsMessage(accessPolicy)[0].message).toBe(messages.shortSharing);
7071

7172
accessPolicy = { sharedLink: {} };
72-
expect(getShortSecurityControlsMessage(accessPolicy).message).toBe(messages.shortSharing);
73+
expect(getShortSecurityControlsMessage(accessPolicy)[0].message).toBe(messages.shortSharing);
7374

7475
accessPolicy = { externalCollab: {} };
75-
expect(getShortSecurityControlsMessage(accessPolicy).message).toBe(messages.shortSharing);
76+
expect(getShortSecurityControlsMessage(accessPolicy)[0].message).toBe(messages.shortSharing);
7677
});
7778

7879
test('should return correct message when there is a download restriction', () => {
7980
accessPolicy = { download: {} };
80-
expect(getShortSecurityControlsMessage(accessPolicy).message).toBe(messages.shortDownload);
81+
expect(getShortSecurityControlsMessage(accessPolicy)[0].message).toBe(messages.shortDownload);
8182
});
8283

8384
test('should return correct message when there is a download restriction', () => {
8485
accessPolicy = { app: {} };
85-
expect(getShortSecurityControlsMessage(accessPolicy).message).toBe(messages.shortApp);
86+
expect(getShortSecurityControlsMessage(accessPolicy)[0].message).toBe(messages.shortApp);
87+
});
88+
89+
test('should return correct message when there is a watermark restriction', () => {
90+
accessPolicy = { watermark: {} };
91+
expect(getShortSecurityControlsMessage(accessPolicy)[0].message).toBe(messages.shortWatermarking);
8692
});
8793

8894
test('should not return tooltipMessage', () => {
8995
accessPolicy = { sharedLink: {}, download: {}, externalCollab: {}, app: {} };
90-
expect(getShortSecurityControlsMessage(accessPolicy).tooltipMessage).toBeUndefined();
96+
expect(getShortSecurityControlsMessage(accessPolicy)[0].tooltipMessage).toBeUndefined();
9197
});
9298
});
9399

@@ -112,6 +118,15 @@ describe('features/classification/security-controls/utils', () => {
112118
]);
113119
});
114120

121+
test('should include correct message when watermark is applied', () => {
122+
accessPolicy = {
123+
watermark: {
124+
enabled: true,
125+
},
126+
};
127+
expect(getFullSecurityControlsMessages(accessPolicy)).toEqual([{ message: messages.watermarkingApplied }]);
128+
});
129+
115130
test('should include correct message when external collab is blocked', () => {
116131
accessPolicy = {
117132
externalCollab: {

src/features/classification/security-controls/messages.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ const messages = defineMessages({
2424
'Short summary displayed for classification when an application download restriction is applied to it',
2525
id: 'boxui.securityControls.shortApp',
2626
},
27+
shortWatermarking: {
28+
defaultMessage: 'Watermarking applied',
29+
description: 'Short summary displayed for classification when watermarking is applied to it',
30+
id: 'boxui.securityControls.shortWatermarking',
31+
},
2732
shortSharingDownload: {
2833
defaultMessage: 'Sharing and download restrictions apply',
2934
description:
@@ -58,6 +63,11 @@ const messages = defineMessages({
5863
description: 'Bullet point that summarizes collaborators shared link restriction applied to classification',
5964
id: 'boxui.securityControls.sharingCollabAndCompanyOnly',
6065
},
66+
watermarkingApplied: {
67+
defaultMessage: 'Watermarking will be applied for Previewer Uploaders, Previewers and Viewers.',
68+
description: 'Bullet point that summarizes watermarking applied to classification',
69+
id: 'boxui.securityControls.watermarkingApplied',
70+
},
6171
externalCollabBlock: {
6272
defaultMessage: 'External collaboration restricted.',
6373
description:

src/features/classification/security-controls/utils.js

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,47 +15,41 @@ import {
1515
SHARED_LINK_ACCESS_LEVEL,
1616
} from '../constants';
1717

18-
const { SHARED_LINK, DOWNLOAD, EXTERNAL_COLLAB, APP } = ACCESS_POLICY_RESTRICTION;
18+
const { SHARED_LINK, DOWNLOAD, EXTERNAL_COLLAB, APP, WATERMARK } = ACCESS_POLICY_RESTRICTION;
1919
const { DEFAULT, WITH_APP_LIST, WITH_OVERFLOWN_APP_LIST } = APP_RESTRICTION_MESSAGE_TYPE;
2020
const { DESKTOP, MOBILE, WEB } = DOWNLOAD_CONTROL;
2121
const { BLOCK, WHITELIST, BLACKLIST } = LIST_ACCESS_LEVEL;
2222
const { COLLAB_ONLY, COLLAB_AND_COMPANY_ONLY, PUBLIC } = SHARED_LINK_ACCESS_LEVEL;
2323

24-
const getShortSecurityControlsMessage = (controls: Controls): ?MessageItem => {
25-
const { sharedLink, download, externalCollab, app } = controls;
24+
const getShortSecurityControlsMessage = (controls: Controls): Array<MessageItem> => {
25+
const items = [];
26+
const { sharedLink, download, externalCollab, app, watermark } = controls;
27+
2628
// Shared link and external collab restrictions are grouped
2729
// together as generic "sharing" restrictions
2830
const sharing = (sharedLink && sharedLink.accessLevel !== PUBLIC) || externalCollab;
2931

3032
if (sharing && download && app) {
31-
return { message: messages.shortAllRestrictions };
32-
}
33-
34-
if (sharing && download) {
35-
return { message: messages.shortSharingDownload };
36-
}
37-
38-
if (sharing && app) {
39-
return { message: messages.shortSharingApp };
40-
}
41-
42-
if (download && app) {
43-
return { message: messages.shortDownloadApp };
44-
}
45-
46-
if (sharing) {
47-
return { message: messages.shortSharing };
33+
items.push({ message: messages.shortAllRestrictions });
34+
} else if (sharing && download) {
35+
items.push({ message: messages.shortSharingDownload });
36+
} else if (sharing && app) {
37+
items.push({ message: messages.shortSharingApp });
38+
} else if (download && app) {
39+
items.push({ message: messages.shortDownloadApp });
40+
} else if (sharing) {
41+
items.push({ message: messages.shortSharing });
42+
} else if (download) {
43+
items.push({ message: messages.shortDownload });
44+
} else if (app) {
45+
items.push({ message: messages.shortApp });
4846
}
4947

50-
if (download) {
51-
return { message: messages.shortDownload };
48+
if (watermark) {
49+
items.push({ message: messages.shortWatermarking });
5250
}
5351

54-
if (app) {
55-
return { message: messages.shortApp };
56-
}
57-
58-
return null;
52+
return items;
5953
};
6054

6155
const getSharedLinkMessages = (controls: Controls): Array<MessageItem> => {
@@ -76,6 +70,16 @@ const getSharedLinkMessages = (controls: Controls): Array<MessageItem> => {
7670
return items;
7771
};
7872

73+
const getWatermarkingMessages = (controls: Controls): Array<MessageItem> => {
74+
const items = [];
75+
const isWatermarkEnabled = getProp(controls, `${WATERMARK}.enabled`, false);
76+
if (isWatermarkEnabled) {
77+
items.push({ message: messages.watermarkingApplied });
78+
}
79+
80+
return items;
81+
};
82+
7983
const getExternalCollabMessages = (controls: Controls): Array<MessageItem> => {
8084
const items = [];
8185
const accessLevel = getProp(controls, `${EXTERNAL_COLLAB}.accessLevel`);
@@ -191,6 +195,7 @@ const getFullSecurityControlsMessages = (controls: Controls, maxAppCount?: numbe
191195
...getExternalCollabMessages(controls),
192196
...getDownloadMessages(controls),
193197
...getAppDownloadMessages(controls, maxAppCount),
198+
...getWatermarkingMessages(controls),
194199
];
195200
return items;
196201
};

0 commit comments

Comments
 (0)