Skip to content

Commit 5d3623f

Browse files
author
feixuanli
authored
feat(siderail): take in both controlsFormat as BTN and TOOLTIP (#1819)
1 parent 324c4be commit 5d3623f

File tree

4 files changed

+57
-5
lines changed

4 files changed

+57
-5
lines changed

src/features/classification/constants.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ const DEFAULT_MAX_APP_COUNT = 3;
44
const SECURITY_CONTROLS_FORMAT: {
55
FULL: 'full',
66
SHORT: 'short',
7+
SHORT_WITH_BTN: 'shortWithBtn', // will remove after eua release
78
SHORT_WITH_TOOLTIP: 'shortWithTooltip',
89
} = {
910
FULL: 'full',
1011
SHORT: 'short',
11-
SHORT_WITH_TOOLTIP: 'shortWithTooltip',
12+
SHORT_WITH_TOOLTIP: 'shortWithTooltip', // will remove after eua release
13+
SHORT_WITH_BTN: 'shortWithBtn',
1214
};
1315

1416
const ACCESS_POLICY_RESTRICTION: {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import { DEFAULT_MAX_APP_COUNT, SECURITY_CONTROLS_FORMAT } from '../constants';
1010

1111
import './SecurityControls.scss';
1212

13-
const { FULL, SHORT, SHORT_WITH_TOOLTIP } = SECURITY_CONTROLS_FORMAT;
13+
// will remove SHORT_WITH_TOOLTIP after eua release
14+
const { FULL, SHORT, SHORT_WITH_TOOLTIP, SHORT_WITH_BTN } = SECURITY_CONTROLS_FORMAT;
1415

1516
type Props = {
1617
controls: Controls,
@@ -28,7 +29,8 @@ const SecurityControls = ({ controls, controlsFormat, maxAppCount }: Props) => {
2829
const shortMessage = getShortSecurityControlsMessage(controls);
2930
items = shortMessage ? [shortMessage] : [];
3031

31-
if (items.length && controlsFormat === SHORT_WITH_TOOLTIP) {
32+
// will remove SHORT_WITH_TOOLTIP after eua release
33+
if (items.length && (controlsFormat === SHORT_WITH_TOOLTIP || controlsFormat === SHORT_WITH_BTN)) {
3234
tooltipItems = getFullSecurityControlsMessages(controls, maxAppCount);
3335
}
3436
}

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import SecurityControlsItem from '../SecurityControlsItem';
44
import SecurityControls from '../SecurityControls';
55
import { SECURITY_CONTROLS_FORMAT } from '../../constants';
66

7-
const { FULL, SHORT, SHORT_WITH_TOOLTIP } = SECURITY_CONTROLS_FORMAT;
7+
const { FULL, SHORT, SHORT_WITH_TOOLTIP, SHORT_WITH_BTN } = SECURITY_CONTROLS_FORMAT;
88

99
describe('features/classification/security-controls/SecurityControls', () => {
1010
let wrapper;
@@ -51,11 +51,17 @@ describe('features/classification/security-controls/SecurityControls', () => {
5151
expect(wrapper).toMatchSnapshot();
5252
});
5353

54+
// will remove after eua release
5455
test('should render SecurityControls with single SecurityControlsItem and tooltip items when using SHORT_WITH_TOOLTIP controlsFormat', () => {
5556
wrapper.setProps({ controlsFormat: SHORT_WITH_TOOLTIP });
5657
expect(wrapper).toMatchSnapshot();
5758
});
5859

60+
test('should render SecurityControls with single SecurityControlsItem and tooltip items when using SHORT_WITH_BTN controlsFormat', () => {
61+
wrapper.setProps({ controlsFormat: SHORT_WITH_BTN });
62+
expect(wrapper).toMatchSnapshot();
63+
});
64+
5965
test('should render SecurityControls multiple SecurityControlsItem when using FULL controlsFormat', () => {
6066
wrapper.setProps({ controlsFormat: FULL });
6167
expect(wrapper).toMatchSnapshot();
@@ -67,9 +73,12 @@ describe('features/classification/security-controls/SecurityControls', () => {
6773

6874
wrapper.setProps({ controlsFormat: SHORT });
6975
expect(wrapper.hasClass('bdl-SecurityControls--summarized')).toBe(true);
70-
76+
// will remove after eua release
7177
wrapper.setProps({ controlsFormat: SHORT_WITH_TOOLTIP });
7278
expect(wrapper.hasClass('bdl-SecurityControls--summarized')).toBe(true);
79+
80+
wrapper.setProps({ controlsFormat: SHORT_WITH_BTN });
81+
expect(wrapper.hasClass('bdl-SecurityControls--summarized')).toBe(true);
7382
});
7483

7584
test('should restrict displayed app names to maxAppCount', () => {

src/features/classification/security-controls/__tests__/__snapshots__/SecurityControls.test.js.snap

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,45 @@ exports[`features/classification/security-controls/SecurityControls should rende
5050
</ul>
5151
`;
5252

53+
exports[`features/classification/security-controls/SecurityControls should render SecurityControls with single SecurityControlsItem and tooltip items when using SHORT_WITH_BTN controlsFormat 1`] = `
54+
<ul
55+
className="bdl-SecurityControls bdl-SecurityControls--summarized"
56+
>
57+
<SecurityControlsItem
58+
key="0"
59+
message={
60+
Object {
61+
"defaultMessage": "Sharing, download and app restrictions apply",
62+
"id": "boxui.securityControls.shortAllRestrictions",
63+
}
64+
}
65+
tooltipItems={
66+
Array [
67+
Object {
68+
"defaultMessage": "Shared links allowed for collaborators only.",
69+
"id": "boxui.securityControls.sharingCollabOnly",
70+
},
71+
Object {
72+
"defaultMessage": "External collaboration limited to approved domains.",
73+
"id": "boxui.securityControls.externalCollabDomainList",
74+
},
75+
Object {
76+
"defaultMessage": "Download restricted on Box Drive, except Owners/Co-Owners.",
77+
"id": "boxui.securityControls.desktopDownloadOwners",
78+
},
79+
Object {
80+
"defaultMessage": "Only select applications are allowed: {appNames}",
81+
"id": "boxui.securityControls.appDownloadWhitelist",
82+
"values": Object {
83+
"appNames": "",
84+
},
85+
},
86+
]
87+
}
88+
/>
89+
</ul>
90+
`;
91+
5392
exports[`features/classification/security-controls/SecurityControls should render SecurityControls with single SecurityControlsItem and tooltip items when using SHORT_WITH_TOOLTIP controlsFormat 1`] = `
5493
<ul
5594
className="bdl-SecurityControls bdl-SecurityControls--summarized"

0 commit comments

Comments
 (0)