Skip to content

Commit a79e193

Browse files
fix(usm): add role img to shared link expiration tooltip icon (#3195)
* fix(usm): add role img to shared link expiration tooltip icon * fix(usm): add role img to shared link expiration tooltip icon
1 parent c32bbae commit a79e193

File tree

3 files changed

+67
-127
lines changed

3 files changed

+67
-127
lines changed

src/features/unified-share-modal/SharedLinkSection.js

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import * as React from 'react';
44
import noop from 'lodash/noop';
5-
import { FormattedMessage } from 'react-intl';
5+
import { FormattedMessage, injectIntl } from 'react-intl';
6+
import type { IntlShape } from 'react-intl';
67

78
import PlainButton from '../../components/plain-button';
89
import Button from '../../components/button';
@@ -51,7 +52,7 @@ type Props = {
5152
newPermissionLevel: permissionLevelType,
5253
) => Promise<{ permissionLevel: permissionLevelType }>,
5354
config?: USMConfig,
54-
intl: any,
55+
intl: IntlShape,
5556
isAllowEditSharedLinkForFileEnabled: boolean,
5657
item: itemtype,
5758
itemType: ItemType,
@@ -307,7 +308,7 @@ class SharedLinkSection extends React.Component<Props, State> {
307308
/>
308309
</Tooltip>
309310
{!hideEmailButton && (
310-
<Tooltip position="top-left" text={<FormattedMessage {...messages.sendSharedLink} />}>
311+
<Tooltip position="top-left" text={intl.formatMessage(messages.sendSharedLink)}>
311312
<Button
312313
aria-label={intl.formatMessage(messages.sendSharedLink)}
313314
className="email-shared-link-btn"
@@ -371,7 +372,7 @@ class SharedLinkSection extends React.Component<Props, State> {
371372
</GuideTooltip>
372373
)}
373374
{isEditableBoxNote && (
374-
<Tooltip text={<FormattedMessage {...messages.sharedLinkPermissionsEditTooltip} />}>
375+
<Tooltip text={intl.formatMessage(messages.sharedLinkPermissionsEditTooltip)}>
375376
<PlainButton isDisabled className="can-edit-btn">
376377
<FormattedMessage {...messages.sharedLinkPermissionsEdit} />
377378
</PlainButton>
@@ -431,9 +432,7 @@ class SharedLinkSection extends React.Component<Props, State> {
431432
position="middle-right"
432433
showCloseButton
433434
text={
434-
tooltips['shared-link-settings'] || (
435-
<FormattedMessage {...messages.sharedLinkSettingsCalloutText} />
436-
)
435+
tooltips['shared-link-settings'] || intl.formatMessage(messages.sharedLinkSettingsCalloutText)
437436
}
438437
theme="callout"
439438
>
@@ -452,7 +451,7 @@ class SharedLinkSection extends React.Component<Props, State> {
452451
}
453452

454453
renderToggle() {
455-
const { item, onDismissTooltip, onToggleSharedLink, sharedLink, submitting, tooltips } = this.props;
454+
const { intl, item, onDismissTooltip, onToggleSharedLink, sharedLink, submitting, tooltips } = this.props;
456455
const { canChangeAccessLevel, expirationTimestamp, url } = sharedLink;
457456
const isSharedLinkEnabled = !!url;
458457
const canAddSharedLink = this.canAddSharedLink(isSharedLinkEnabled, item.grantedPermissions.itemShare);
@@ -469,16 +468,11 @@ class SharedLinkSection extends React.Component<Props, State> {
469468
<FormattedMessage {...messages.linkShareOn} />
470469
<Tooltip
471470
position="top-center"
472-
text={
473-
<FormattedMessage
474-
{...messages.sharedLinkExpirationTooltip}
475-
values={{
476-
expiration: convertToMs(expirationTimestamp),
477-
}}
478-
/>
479-
}
471+
text={intl.formatMessage(messages.sharedLinkExpirationTooltip, {
472+
expiration: convertToMs(expirationTimestamp),
473+
})}
480474
>
481-
<span className="shared-link-expiration-badge">
475+
<span className="shared-link-expiration-badge" role="img">
482476
<IconClock color={bdlWatermelonRed} />
483477
</span>
484478
</Tooltip>
@@ -523,10 +517,7 @@ class SharedLinkSection extends React.Component<Props, State> {
523517
);
524518
}
525519
return (
526-
<Tooltip
527-
position="top-right"
528-
text={<FormattedMessage {...messages.sharedLinkDisabledTooltipCopy} />}
529-
>
520+
<Tooltip position="top-right" text={intl.formatMessage(messages.sharedLinkDisabledTooltipCopy)}>
530521
{toggleComponent}
531522
</Tooltip>
532523
);
@@ -541,7 +532,7 @@ class SharedLinkSection extends React.Component<Props, State> {
541532
<Tooltip
542533
className="usm-disabled-message-tooltip"
543534
position="top-right"
544-
text={<FormattedMessage {...tooltipDisabledMessage} />}
535+
text={intl.formatMessage(tooltipDisabledMessage)}
545536
>
546537
{toggleComponent}
547538
</Tooltip>
@@ -574,5 +565,5 @@ class SharedLinkSection extends React.Component<Props, State> {
574565
);
575566
}
576567
}
577-
578-
export default SharedLinkSection;
568+
export { SharedLinkSection as SharedLinkSectionBase };
569+
export default injectIntl(SharedLinkSection);

src/features/unified-share-modal/__tests__/SharedLinkSection.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import React from 'react';
22
import sinon from 'sinon';
33
import { ANYONE_IN_COMPANY, ANYONE_WITH_LINK, CAN_EDIT, CAN_VIEW_DOWNLOAD } from '../constants';
44

5-
import SharedLinkSection from '../SharedLinkSection';
5+
import { SharedLinkSectionBase as SharedLinkSection } from '../SharedLinkSection';
66

77
const sandbox = sinon.sandbox.create();
88

99
describe('features/unified-share-modal/SharedLinkSection', () => {
10-
const intl = { formatMessage: sandbox.spy() };
10+
const intl = { formatMessage: jest.fn().mockImplementation(message => message.defaultMessage) };
1111
const defaultItem = {
1212
grantedPermissions: {
1313
itemShare: true,

0 commit comments

Comments
 (0)