box-ui-elements 23.4.0-beta.36 → 23.4.0-beta.37
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/dist/explorer.js +1 -1
- package/dist/preview.js +1 -1
- package/dist/sidebar.js +1 -1
- package/es/elements/content-preview/PreviewNavigation.js +0 -2
- package/es/elements/content-preview/PreviewNavigation.js.flow +0 -2
- package/es/elements/content-preview/PreviewNavigation.js.map +1 -1
- package/es/elements/content-sidebar/versions/VersionsSidebarContainer.js +29 -7
- package/es/elements/content-sidebar/versions/VersionsSidebarContainer.js.flow +44 -5
- package/es/elements/content-sidebar/versions/VersionsSidebarContainer.js.map +1 -1
- package/es/elements/content-sidebar/withSidebarAnnotations.js +141 -35
- package/es/elements/content-sidebar/withSidebarAnnotations.js.flow +199 -37
- package/es/elements/content-sidebar/withSidebarAnnotations.js.map +1 -1
- package/i18n/bn-IN.js +1 -1
- package/i18n/bn-IN.properties +4 -0
- package/i18n/da-DK.js +1 -1
- package/i18n/da-DK.properties +4 -0
- package/i18n/de-DE.js +1 -1
- package/i18n/de-DE.properties +4 -0
- package/i18n/en-AU.js +1 -1
- package/i18n/en-AU.properties +4 -0
- package/i18n/en-CA.js +1 -1
- package/i18n/en-CA.properties +4 -0
- package/i18n/en-GB.js +1 -1
- package/i18n/en-GB.properties +4 -0
- package/i18n/es-419.js +1 -1
- package/i18n/es-419.properties +4 -0
- package/i18n/es-ES.js +1 -1
- package/i18n/es-ES.properties +4 -0
- package/i18n/fi-FI.js +1 -1
- package/i18n/fi-FI.properties +4 -0
- package/i18n/fr-CA.js +1 -1
- package/i18n/fr-CA.properties +4 -0
- package/i18n/fr-FR.js +1 -1
- package/i18n/fr-FR.properties +4 -0
- package/i18n/hi-IN.js +1 -1
- package/i18n/hi-IN.properties +4 -0
- package/i18n/it-IT.js +1 -1
- package/i18n/it-IT.properties +4 -0
- package/i18n/ja-JP.js +1 -1
- package/i18n/ja-JP.properties +4 -0
- package/i18n/ko-KR.js +1 -1
- package/i18n/ko-KR.properties +4 -0
- package/i18n/nb-NO.js +1 -1
- package/i18n/nb-NO.properties +4 -0
- package/i18n/nl-NL.js +1 -1
- package/i18n/nl-NL.properties +4 -0
- package/i18n/pl-PL.js +1 -1
- package/i18n/pl-PL.properties +4 -0
- package/i18n/pt-BR.js +1 -1
- package/i18n/pt-BR.properties +4 -0
- package/i18n/ru-RU.js +1 -1
- package/i18n/ru-RU.properties +4 -0
- package/i18n/sv-SE.js +1 -1
- package/i18n/sv-SE.properties +4 -0
- package/i18n/tr-TR.js +1 -1
- package/i18n/tr-TR.properties +4 -0
- package/i18n/zh-CN.js +1 -1
- package/i18n/zh-CN.properties +4 -0
- package/i18n/zh-TW.js +1 -1
- package/i18n/zh-TW.properties +4 -0
- package/package.json +1 -1
- package/src/elements/content-preview/PreviewNavigation.js +0 -2
- package/src/elements/content-preview/__tests__/PreviewNavigation.test.js +12 -12
- package/src/elements/content-sidebar/__tests__/withSidebarAnnotations.rtl.test.js +1152 -0
- package/src/elements/content-sidebar/versions/VersionsSidebarContainer.js +44 -5
- package/src/elements/content-sidebar/versions/__tests__/VersionsSidebarContainer.test.js +200 -43
- package/src/elements/content-sidebar/versions/__tests__/__snapshots__/VersionsSidebarContainer.test.js.snap +2 -2
- package/src/elements/content-sidebar/withSidebarAnnotations.js +199 -37
- package/src/elements/content-sidebar/__tests__/withSidebarAnnotations.test.js +0 -626
|
@@ -7,14 +7,23 @@ import { FEED_ITEM_TYPE_VERSION } from '../../constants';
|
|
|
7
7
|
import { getBadUserError } from '../../utils/error';
|
|
8
8
|
import type { WithAnnotatorContextProps } from '../common/annotator-context';
|
|
9
9
|
import type { BoxItem, User } from '../../common/types/core';
|
|
10
|
+
import {
|
|
11
|
+
ViewType,
|
|
12
|
+
FeedEntryType,
|
|
13
|
+
type InternalSidebarNavigation,
|
|
14
|
+
type InternalSidebarNavigationHandler,
|
|
15
|
+
} from '../common/types/SidebarNavigation';
|
|
10
16
|
|
|
11
17
|
type Props = {
|
|
12
18
|
...ContextRouter,
|
|
13
19
|
currentUser?: User,
|
|
14
20
|
file: BoxItem,
|
|
15
21
|
fileId: string,
|
|
22
|
+
internalSidebarNavigation?: InternalSidebarNavigation,
|
|
23
|
+
internalSidebarNavigationHandler?: InternalSidebarNavigationHandler,
|
|
16
24
|
isOpen: boolean,
|
|
17
25
|
onVersionChange: Function,
|
|
26
|
+
routerDisabled?: boolean,
|
|
18
27
|
} & WithAnnotatorContextProps;
|
|
19
28
|
|
|
20
29
|
type SidebarPanelsRefType = {
|
|
@@ -44,31 +53,130 @@ export default function withSidebarAnnotations(
|
|
|
44
53
|
this.redirectDeeplinkedAnnotation();
|
|
45
54
|
}
|
|
46
55
|
|
|
56
|
+
getInternalNavigationMatch = (
|
|
57
|
+
navigation: InternalSidebarNavigation,
|
|
58
|
+
): { params: { annotationId?: string, fileVersionId: string } } | null => {
|
|
59
|
+
if (
|
|
60
|
+
!('activeFeedEntryType' in navigation) ||
|
|
61
|
+
navigation.activeFeedEntryType !== FeedEntryType.ANNOTATIONS ||
|
|
62
|
+
!navigation.fileVersionId
|
|
63
|
+
) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Only include annotationId if it's defined (mirrors router behavior where missing optional params are omitted)
|
|
68
|
+
const params =
|
|
69
|
+
navigation.activeFeedEntryId !== undefined
|
|
70
|
+
? {
|
|
71
|
+
fileVersionId: navigation.fileVersionId,
|
|
72
|
+
annotationId: navigation.activeFeedEntryId,
|
|
73
|
+
}
|
|
74
|
+
: {
|
|
75
|
+
fileVersionId: navigation.fileVersionId,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return { params };
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
getInternalAnnotationsNavigation = (
|
|
82
|
+
fileVersionId?: string,
|
|
83
|
+
annotationId?: string | null,
|
|
84
|
+
): InternalSidebarNavigation => {
|
|
85
|
+
if (!fileVersionId) {
|
|
86
|
+
return { sidebar: ViewType.ACTIVITY };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
sidebar: ViewType.ACTIVITY,
|
|
91
|
+
activeFeedEntryType: FeedEntryType.ANNOTATIONS,
|
|
92
|
+
activeFeedEntryId: annotationId || undefined,
|
|
93
|
+
fileVersionId,
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
|
|
47
97
|
redirectDeeplinkedAnnotation = () => {
|
|
48
|
-
const {
|
|
49
|
-
|
|
50
|
-
|
|
98
|
+
const {
|
|
99
|
+
file,
|
|
100
|
+
getAnnotationsPath,
|
|
101
|
+
getAnnotationsMatchPath,
|
|
102
|
+
history,
|
|
103
|
+
internalSidebarNavigation,
|
|
104
|
+
internalSidebarNavigationHandler,
|
|
105
|
+
location,
|
|
106
|
+
routerDisabled,
|
|
107
|
+
} = this.props;
|
|
108
|
+
|
|
51
109
|
const currentFileVersionId = getProp(file, 'file_version.id');
|
|
52
|
-
const fileVersionId = getProp(match, 'params.fileVersionId');
|
|
53
110
|
|
|
54
|
-
if (
|
|
55
|
-
|
|
111
|
+
if (routerDisabled && internalSidebarNavigation && internalSidebarNavigationHandler) {
|
|
112
|
+
// Use internal navigation when router is disabled
|
|
113
|
+
const match = this.getInternalNavigationMatch(internalSidebarNavigation);
|
|
114
|
+
const annotationId = getProp(match, 'params.annotationId');
|
|
115
|
+
const fileVersionId = getProp(match, 'params.fileVersionId');
|
|
116
|
+
|
|
117
|
+
if (fileVersionId && fileVersionId !== currentFileVersionId) {
|
|
118
|
+
const correctedNavigation = this.getInternalAnnotationsNavigation(
|
|
119
|
+
currentFileVersionId,
|
|
120
|
+
annotationId,
|
|
121
|
+
);
|
|
122
|
+
internalSidebarNavigationHandler(correctedNavigation, true);
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
// Use router-based navigation
|
|
126
|
+
const match = getAnnotationsMatchPath(location);
|
|
127
|
+
const annotationId = getProp(match, 'params.annotationId');
|
|
128
|
+
const fileVersionId = getProp(match, 'params.fileVersionId');
|
|
129
|
+
|
|
130
|
+
if (fileVersionId && fileVersionId !== currentFileVersionId) {
|
|
131
|
+
history.replace(getAnnotationsPath(currentFileVersionId, annotationId));
|
|
132
|
+
}
|
|
56
133
|
}
|
|
57
134
|
};
|
|
58
135
|
|
|
59
136
|
componentDidUpdate(prevProps: Props) {
|
|
60
|
-
const {
|
|
61
|
-
|
|
137
|
+
const {
|
|
138
|
+
annotatorState,
|
|
139
|
+
fileId,
|
|
140
|
+
getAnnotationsMatchPath,
|
|
141
|
+
internalSidebarNavigation,
|
|
142
|
+
location,
|
|
143
|
+
onVersionChange,
|
|
144
|
+
routerDisabled,
|
|
145
|
+
}: Props = this.props;
|
|
146
|
+
const {
|
|
147
|
+
annotatorState: prevAnnotatorState,
|
|
148
|
+
fileId: prevFileId,
|
|
149
|
+
internalSidebarNavigation: prevInternalSidebarNavigation,
|
|
150
|
+
location: prevLocation,
|
|
151
|
+
}: Props = prevProps;
|
|
62
152
|
const { action, activeAnnotationId, annotation } = annotatorState;
|
|
63
153
|
const { activeAnnotationId: prevActiveAnnotationId, annotation: prevAnnotation } = prevAnnotatorState;
|
|
64
154
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
155
|
+
let fileVersionId;
|
|
156
|
+
let prevFileVersionId;
|
|
157
|
+
let match;
|
|
158
|
+
|
|
159
|
+
if (routerDisabled && internalSidebarNavigation) {
|
|
160
|
+
// Use internal navigation when router is disabled
|
|
161
|
+
match = this.getInternalNavigationMatch(internalSidebarNavigation);
|
|
162
|
+
const prevMatch = prevInternalSidebarNavigation
|
|
163
|
+
? this.getInternalNavigationMatch(prevInternalSidebarNavigation)
|
|
164
|
+
: null;
|
|
165
|
+
|
|
166
|
+
fileVersionId = getProp(match, 'params.fileVersionId');
|
|
167
|
+
prevFileVersionId = getProp(prevMatch, 'params.fileVersionId');
|
|
168
|
+
} else {
|
|
169
|
+
// Use router-based navigation
|
|
170
|
+
match = getAnnotationsMatchPath(location);
|
|
171
|
+
const prevMatch = getAnnotationsMatchPath(prevLocation);
|
|
172
|
+
|
|
173
|
+
fileVersionId = getProp(match, 'params.fileVersionId');
|
|
174
|
+
prevFileVersionId = getProp(prevMatch, 'params.fileVersionId');
|
|
175
|
+
}
|
|
176
|
+
|
|
69
177
|
const isAnnotationsPath = !!match;
|
|
70
178
|
const isTransitioningToAnnotationPath = activeAnnotationId && !isAnnotationsPath;
|
|
71
|
-
const
|
|
179
|
+
const hasActiveAnnotationChanged = prevActiveAnnotationId !== activeAnnotationId;
|
|
72
180
|
|
|
73
181
|
if (action === 'reply_create_start' || action === 'reply_create_end') {
|
|
74
182
|
this.addAnnotationReply();
|
|
@@ -275,19 +383,39 @@ export default function withSidebarAnnotations(
|
|
|
275
383
|
getAnnotationsMatchPath,
|
|
276
384
|
getAnnotationsPath,
|
|
277
385
|
history,
|
|
386
|
+
internalSidebarNavigation,
|
|
387
|
+
internalSidebarNavigationHandler,
|
|
278
388
|
location,
|
|
389
|
+
routerDisabled,
|
|
279
390
|
} = this.props;
|
|
280
|
-
|
|
391
|
+
|
|
281
392
|
const currentFileVersionId = getProp(file, 'file_version.id');
|
|
282
393
|
const defaultFileVersionId = activeAnnotationFileVersionId || currentFileVersionId;
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
394
|
+
|
|
395
|
+
if (routerDisabled && internalSidebarNavigation && internalSidebarNavigationHandler) {
|
|
396
|
+
// Use internal navigation when router is disabled
|
|
397
|
+
const match = this.getInternalNavigationMatch(internalSidebarNavigation);
|
|
398
|
+
const fileVersionId = getProp(match, 'params.fileVersionId', defaultFileVersionId);
|
|
399
|
+
const newNavigationState = activeAnnotationId ? { open: true } : {};
|
|
400
|
+
|
|
401
|
+
// Update the navigation and open state if transitioning to an active annotation id, force the sidebar open
|
|
402
|
+
const updatedNavigation = {
|
|
403
|
+
...this.getInternalAnnotationsNavigation(fileVersionId, activeAnnotationId),
|
|
404
|
+
...newNavigationState,
|
|
405
|
+
};
|
|
406
|
+
internalSidebarNavigationHandler(updatedNavigation);
|
|
407
|
+
} else {
|
|
408
|
+
// Use router-based navigation
|
|
409
|
+
const match = getAnnotationsMatchPath(location);
|
|
410
|
+
const fileVersionId = getProp(match, 'params.fileVersionId', defaultFileVersionId);
|
|
411
|
+
const newLocationState = activeAnnotationId ? { open: true } : location.state;
|
|
412
|
+
|
|
413
|
+
// Update the location pathname and open state if transitioning to an active annotation id, force the sidebar open
|
|
414
|
+
history.push({
|
|
415
|
+
pathname: getAnnotationsPath(fileVersionId, activeAnnotationId),
|
|
416
|
+
state: newLocationState,
|
|
417
|
+
});
|
|
418
|
+
}
|
|
291
419
|
};
|
|
292
420
|
|
|
293
421
|
updateActiveVersion = () => {
|
|
@@ -298,33 +426,67 @@ export default function withSidebarAnnotations(
|
|
|
298
426
|
getAnnotationsMatchPath,
|
|
299
427
|
getAnnotationsPath,
|
|
300
428
|
history,
|
|
429
|
+
internalSidebarNavigation,
|
|
430
|
+
internalSidebarNavigationHandler,
|
|
301
431
|
location,
|
|
302
432
|
onVersionChange,
|
|
433
|
+
routerDisabled,
|
|
303
434
|
} = this.props;
|
|
435
|
+
|
|
304
436
|
const feedAPI = api.getFeedAPI(false);
|
|
305
|
-
const match = getAnnotationsMatchPath(location);
|
|
306
437
|
const currentFileVersionId = getProp(file, 'file_version.id');
|
|
307
|
-
const fileVersionId = getProp(match, 'params.fileVersionId');
|
|
308
438
|
const { items: feedItems = [] } = feedAPI.getCachedItems(fileId) || {};
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
439
|
+
|
|
440
|
+
if (routerDisabled && internalSidebarNavigation && internalSidebarNavigationHandler) {
|
|
441
|
+
// Use internal navigation when router is disabled
|
|
442
|
+
const match = this.getInternalNavigationMatch(internalSidebarNavigation);
|
|
443
|
+
const fileVersionId = getProp(match, 'params.fileVersionId');
|
|
444
|
+
const version = feedItems
|
|
445
|
+
.filter(item => item.type === FEED_ITEM_TYPE_VERSION)
|
|
446
|
+
.find(item => item.id === fileVersionId);
|
|
447
|
+
|
|
448
|
+
if (version) {
|
|
449
|
+
onVersionChange(version, {
|
|
450
|
+
currentVersionId: currentFileVersionId,
|
|
451
|
+
updateVersionToCurrent: () => {
|
|
452
|
+
const currentVersionNavigation =
|
|
453
|
+
this.getInternalAnnotationsNavigation(currentFileVersionId);
|
|
454
|
+
internalSidebarNavigationHandler(currentVersionNavigation);
|
|
455
|
+
},
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
} else {
|
|
459
|
+
// Use router-based navigation
|
|
460
|
+
const match = getAnnotationsMatchPath(location);
|
|
461
|
+
const fileVersionId = getProp(match, 'params.fileVersionId');
|
|
462
|
+
const version = feedItems
|
|
463
|
+
.filter(item => item.type === FEED_ITEM_TYPE_VERSION)
|
|
464
|
+
.find(item => item.id === fileVersionId);
|
|
465
|
+
|
|
466
|
+
if (version) {
|
|
467
|
+
onVersionChange(version, {
|
|
468
|
+
currentVersionId: currentFileVersionId,
|
|
469
|
+
updateVersionToCurrent: () => history.push(getAnnotationsPath(currentFileVersionId)),
|
|
470
|
+
});
|
|
471
|
+
}
|
|
318
472
|
}
|
|
319
473
|
};
|
|
320
474
|
|
|
321
475
|
refreshActivitySidebar = () => {
|
|
322
|
-
const { isOpen, location } = this.props;
|
|
323
|
-
|
|
324
|
-
const pathname = getProp(location, 'pathname', '');
|
|
325
|
-
const isActivity = matchPath(pathname, '/activity');
|
|
476
|
+
const { internalSidebarNavigation, isOpen, location, routerDisabled } = this.props;
|
|
326
477
|
const { current } = this.sidebarPanels;
|
|
327
478
|
|
|
479
|
+
let isActivity = false;
|
|
480
|
+
|
|
481
|
+
if (routerDisabled && internalSidebarNavigation) {
|
|
482
|
+
// Check if current navigation is pointing to activity sidebar
|
|
483
|
+
isActivity = internalSidebarNavigation.sidebar === ViewType.ACTIVITY;
|
|
484
|
+
} else {
|
|
485
|
+
// Use router-based check
|
|
486
|
+
const pathname = getProp(location, 'pathname', '');
|
|
487
|
+
isActivity = !!matchPath(pathname, '/activity');
|
|
488
|
+
}
|
|
489
|
+
|
|
328
490
|
// If the activity sidebar is currently open, then force it to refresh with the updated data
|
|
329
491
|
if (current && isActivity && isOpen) {
|
|
330
492
|
current.refresh(false);
|