Skip to content

Commit ba22807

Browse files
revert(annotation-activity): hide AnnotationActivityLink (#3120)
Revert "feat(annotation-activity): hide AnnotationActivityLink (#3089)" This reverts commit dc3642e.
1 parent f78e36b commit ba22807

File tree

13 files changed

+127
-187
lines changed

13 files changed

+127
-187
lines changed

src/elements/content-sidebar/ActivitySidebar.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,6 @@ class ActivitySidebar extends React.PureComponent<Props, State> {
957957
elementId,
958958
file,
959959
hasReplies,
960-
hasVersions,
961960
isDisabled = false,
962961
onVersionHistoryClick,
963962
getUserProfileUrl,
@@ -989,7 +988,6 @@ class ActivitySidebar extends React.PureComponent<Props, State> {
989988
getMentionWithQuery={this.getMention}
990989
getUserProfileUrl={getUserProfileUrl}
991990
hasReplies={hasReplies}
992-
hasVersions={hasVersions}
993991
isDisabled={isDisabled}
994992
mentionSelectorContacts={mentionSelectorContacts}
995993
contactsLoaded={contactsLoaded}

src/elements/content-sidebar/__tests__/__snapshots__/ActivitySidebar.test.js.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ exports[`elements/content-sidebar/ActivitySidebar render() should render the act
5151
getAvatarUrl={[Function]}
5252
getMentionWithQuery={[Function]}
5353
hasReplies={false}
54-
hasVersions={true}
5554
isDisabled={false}
5655
onAnnotationDelete={[Function]}
5756
onAnnotationEdit={[Function]}

src/elements/content-sidebar/activity-feed/activity-feed/ActiveState.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ type Props = {
4646
getMentionWithQuery?: Function,
4747
getUserProfileUrl?: GetProfileUrlCallback,
4848
hasReplies?: boolean,
49-
hasVersions?: boolean,
5049
items: FeedItems,
5150
mentionSelectorContacts?: SelectorItems<>,
5251
onAnnotationDelete?: ({ id: string, permissions: AnnotationPermission }) => void,
@@ -92,7 +91,6 @@ const ActiveState = ({
9291
currentFileVersionId,
9392
currentUser,
9493
hasReplies = false,
95-
hasVersions,
9694
items,
9795
mentionSelectorContacts,
9896
getMentionWithQuery,
@@ -272,7 +270,6 @@ const ActiveState = ({
272270
getAvatarUrl={getAvatarUrl}
273271
getUserProfileUrl={getUserProfileUrl}
274272
getMentionWithQuery={getMentionWithQuery}
275-
hasVersions={hasVersions}
276273
isCurrentVersion={currentFileVersionId === itemFileVersionId}
277274
item={item}
278275
mentionSelectorContacts={mentionSelectorContacts}

src/elements/content-sidebar/activity-feed/activity-feed/ActivityFeed.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ type Props = {
4545
getMentionWithQuery?: Function,
4646
getUserProfileUrl?: GetProfileUrlCallback,
4747
hasReplies?: boolean,
48-
hasVersions?: boolean,
4948
isDisabled?: boolean,
5049
mentionSelectorContacts?: SelectorItems<User>,
5150
onAnnotationDelete?: ({ id: string, permissions: AnnotationPermission }) => void,
@@ -237,7 +236,6 @@ class ActivityFeed extends React.Component<Props, State> {
237236
getMentionWithQuery,
238237
getUserProfileUrl,
239238
hasReplies,
240-
hasVersions,
241239
isDisabled,
242240
mentionSelectorContacts,
243241
contactsLoaded,
@@ -321,7 +319,6 @@ class ActivityFeed extends React.Component<Props, State> {
321319
getMentionWithQuery={getMentionWithQuery}
322320
getUserProfileUrl={getUserProfileUrl}
323321
hasReplies={hasReplies}
324-
hasVersions={hasVersions}
325322
isDisabled={isDisabled}
326323
items={collapseFeedState(feedItems)}
327324
mentionSelectorContacts={mentionSelectorContacts}

src/elements/content-sidebar/activity-feed/annotations/AnnotationActivity.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ type Props = {
3030
getAvatarUrl: GetAvatarUrlCallback,
3131
getMentionWithQuery?: (searchStr: string) => void,
3232
getUserProfileUrl?: GetProfileUrlCallback,
33-
hasVersions?: boolean,
34-
isCurrentVersion?: boolean,
33+
isCurrentVersion: boolean,
3534
item: Annotation,
3635
mentionSelectorContacts?: SelectorItems<User>,
3736
onDelete?: ({ id: string, permissions: AnnotationPermission }) => any,
@@ -46,7 +45,6 @@ const AnnotationActivity = ({
4645
getAvatarUrl,
4746
getMentionWithQuery,
4847
getUserProfileUrl,
49-
hasVersions,
5048
isCurrentVersion,
5149
mentionSelectorContacts,
5250
onDelete = noop,
@@ -104,9 +102,12 @@ const AnnotationActivity = ({
104102

105103
const createdAtTimestamp = new Date(created_at).getTime();
106104
const createdByUser = created_by || PLACEHOLDER_USER;
107-
105+
const linkMessage = isCurrentVersion ? messages.annotationActivityPageItem : messages.annotationActivityVersionLink;
106+
const linkValue = isCurrentVersion ? target.location.value : getProp(file_version, 'version_number');
108107
const message = (description && description.message) || '';
109-
108+
const activityLinkMessage = isFileVersionUnavailable
109+
? messages.annotationActivityVersionUnavailable
110+
: { ...linkMessage, values: { number: linkValue } };
110111
const tetherProps = {
111112
attachment: 'top right',
112113
className: 'bcs-AnnotationActivity-deleteConfirmationModal',
@@ -148,12 +149,10 @@ const AnnotationActivity = ({
148149
<AnnotationActivityLink
149150
className="bcs-AnnotationActivity-link"
150151
data-resin-target="annotationLink"
151-
fileVersion={getProp(file_version, 'version_number')}
152152
id={id}
153-
isCurrentVersion={isCurrentVersion}
154-
locationValue={target.location.value}
153+
isDisabled={isFileVersionUnavailable}
154+
message={activityLinkMessage}
155155
onClick={handleSelect}
156-
shouldHideLink={!hasVersions}
157156
/>
158157
</div>
159158
<ActivityStatus status={status} />

src/elements/content-sidebar/activity-feed/annotations/AnnotationActivity.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@
4242
.bcs-AnnotationActivity-timestamp {
4343
display: flex;
4444
white-space: nowrap;
45+
46+
.bcs-ActivityTimestamp {
47+
&::after {
48+
margin-right: 8px;
49+
margin-left: 8px;
50+
color: $bdl-gray-50;
51+
content: '\2022';
52+
}
53+
}
4554
}
4655

4756
// override for activity feed defaults

src/elements/content-sidebar/activity-feed/annotations/AnnotationActivityLink.scss

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66
color: $bdl-box-blue;
77
font-weight: bold;
88

9-
&::before {
10-
margin-right: 2 * $bdl-grid-unit;
11-
margin-left: 2 * $bdl-grid-unit;
12-
color: $bdl-gray-50;
13-
content: '\2022';
14-
}
15-
169
&[aria-disabled='true'] {
1710
color: $bdl-gray-62;
1811
}

src/elements/content-sidebar/activity-feed/annotations/AnnotationActivityLink.tsx

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,29 @@ import noop from 'lodash/noop';
44
import { injectIntl, MessageDescriptor, WrappedComponentProps } from 'react-intl';
55
import PlainButton from '../../../../components/plain-button';
66
import { ButtonType } from '../../../../components/button';
7-
import messages from './messages';
87
import './AnnotationActivityLink.scss';
98

109
type MessageDescriptorWithValues = {
11-
values?: { number: string };
10+
values?: Record<string, number>;
1211
} & MessageDescriptor;
1312
export interface AnnotationActivityLinkProps extends WrappedComponentProps {
1413
className?: string;
15-
fileVersion: string;
1614
id: string;
17-
isCurrentVersion?: boolean;
18-
locationValue: string;
15+
isDisabled: boolean;
16+
message: MessageDescriptorWithValues;
1917
onClick: (id: string) => void;
20-
shouldHideLink: boolean;
2118
}
2219

23-
const AnnotationActivityLink: React.FC<AnnotationActivityLinkProps> = ({
20+
const AnnotationActivityLink = ({
2421
className,
2522
id,
26-
fileVersion,
2723
intl,
28-
isCurrentVersion,
29-
locationValue,
24+
isDisabled = false,
25+
message,
3026
onClick = noop,
31-
shouldHideLink,
3227
...rest
33-
}: AnnotationActivityLinkProps) => {
34-
if (shouldHideLink) {
35-
return null;
36-
}
37-
38-
const getMessage = (): MessageDescriptorWithValues => {
39-
const linkMessage = isCurrentVersion
40-
? messages.annotationActivityPageItem
41-
: messages.annotationActivityVersionLink;
42-
const linkValue = isCurrentVersion ? locationValue : fileVersion;
43-
return !fileVersion
44-
? messages.annotationActivityVersionUnavailable
45-
: { ...linkMessage, values: { number: linkValue } };
46-
};
47-
48-
const { values, ...messageDescriptor } = getMessage();
28+
}: AnnotationActivityLinkProps): JSX.Element => {
29+
const { values, ...messageDescriptor } = message;
4930
const translatedMessage = intl.formatMessage(messageDescriptor, values);
5031

5132
const handleClick = (event: React.SyntheticEvent<HTMLButtonElement>) => {
@@ -57,7 +38,7 @@ const AnnotationActivityLink: React.FC<AnnotationActivityLinkProps> = ({
5738
};
5839

5940
const handleMouseDown = (event: React.MouseEvent<HTMLButtonElement>) => {
60-
if (!fileVersion) {
41+
if (isDisabled) {
6142
return;
6243
}
6344

@@ -71,7 +52,7 @@ const AnnotationActivityLink: React.FC<AnnotationActivityLinkProps> = ({
7152
<PlainButton
7253
className={classNames('bcs-AnnotationActivityLink', className)}
7354
data-testid="bcs-AnnotationActivity-link"
74-
isDisabled={!fileVersion}
55+
isDisabled={isDisabled}
7556
onClick={handleClick}
7657
onMouseDown={handleMouseDown}
7758
title={translatedMessage}

src/elements/content-sidebar/activity-feed/annotations/__tests__/AnnotationActivity.test.js

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import AnnotationActivityMenu from '../AnnotationActivityMenu';
66
import CommentForm from '../../comment-form/CommentForm';
77
import DeleteConfirmation from '../../common/delete-confirmation';
88
import Media from '../../../../../components/media';
9+
import messages from '../messages';
910
import SelectableActivityCard from '../../SelectableActivityCard';
1011

1112
jest.mock('../../Avatar', () => () => 'Avatar');
@@ -38,7 +39,6 @@ describe('elements/content-sidebar/ActivityFeed/annotations/AnnotationActivity',
3839
const mockActivity = {
3940
currentUser,
4041
handlers: allHandlers,
41-
hasVersions: true,
4242
isCurrentVersion: true,
4343
item: mockAnnotation,
4444
mentionSelectorContacts,
@@ -84,10 +84,10 @@ describe('elements/content-sidebar/ActivityFeed/annotations/AnnotationActivity',
8484
expect(wrapper.find('ActivityTimestamp').prop('date')).toEqual(unixTime);
8585
expect(wrapper.find('AnnotationActivityLink').props()).toMatchObject({
8686
'data-resin-target': 'annotationLink',
87-
isCurrentVersion: true,
88-
fileVersion: mockAnnotation.file_version.version_number,
89-
locationValue: mockAnnotation.target.location.value,
90-
shouldHideLink: false,
87+
message: {
88+
...messages.annotationActivityPageItem,
89+
values: { number: 1 },
90+
},
9191
});
9292
expect(wrapper.exists(AnnotationActivityMenu)).toBe(true);
9393
expect(wrapper.find('ForwardRef(withFeatureConsumer(ActivityMessage))').prop('tagged_message')).toEqual(
@@ -127,23 +127,28 @@ describe('elements/content-sidebar/ActivityFeed/annotations/AnnotationActivity',
127127
expect(wrapper.exists('CommentForm')).toBe(false);
128128
});
129129

130-
test('should render commenter as a link', () => {
131-
const wrapper = getWrapper();
132-
expect(wrapper.find('UserLink').prop('name')).toEqual(mockActivity.item.created_by.name);
133-
});
130+
test('should correctly render annotation activity of another file version', () => {
131+
const wrapper = getWrapper({ isCurrentVersion: false });
134132

135-
test('should hide AnnotationActivityLink if hasVersions is false', () => {
136-
const wrapper = getWrapper({ hasVersions: false });
137-
expect(wrapper.find('AnnotationActivityLink').props()).toMatchObject({
138-
shouldHideLink: true,
133+
expect(wrapper.find('AnnotationActivityLink').prop('message')).toEqual({
134+
...messages.annotationActivityVersionLink,
135+
values: { number: '2' },
139136
});
140137
});
141138

142-
test('should show AnnotationActivityLink if hasVersions is true', () => {
143-
const wrapper = getWrapper({ hasVersions: true });
144-
expect(wrapper.find('AnnotationActivityLink').props()).toMatchObject({
145-
shouldHideLink: false,
139+
test('should render version unavailable if file version is null', () => {
140+
const wrapper = getWrapper({ item: { ...mockAnnotation, file_version: null } });
141+
const activityLink = wrapper.find('AnnotationActivityLink');
142+
143+
expect(activityLink.prop('message')).toEqual({
144+
...messages.annotationActivityVersionUnavailable,
146145
});
146+
expect(activityLink.prop('isDisabled')).toBe(true);
147+
});
148+
149+
test('should render commenter as a link', () => {
150+
const wrapper = getWrapper();
151+
expect(wrapper.find('UserLink').prop('name')).toEqual(mockActivity.item.created_by.name);
147152
});
148153

149154
test('should not show actions menu when annotation activity is pending', () => {

0 commit comments

Comments
 (0)