box-ui-elements 23.4.0-beta.33 → 23.4.0-beta.34
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/common/types/SidebarNavigation.js +4 -2
- package/es/elements/common/types/SidebarNavigation.js.flow +7 -4
- package/es/elements/common/types/SidebarNavigation.js.map +1 -1
- package/es/elements/content-preview/PreviewNavigation.js +65 -2
- package/es/elements/content-preview/PreviewNavigation.js.flow +86 -2
- package/es/elements/content-preview/PreviewNavigation.js.map +1 -1
- package/es/elements/content-sidebar/ActivitySidebar.js +39 -7
- package/es/elements/content-sidebar/ActivitySidebar.js.flow +42 -6
- package/es/elements/content-sidebar/ActivitySidebar.js.map +1 -1
- package/es/src/elements/common/types/SidebarNavigation.d.ts +10 -4
- package/package.json +1 -1
- package/src/elements/common/types/SidebarNavigation.js.flow +7 -4
- package/src/elements/common/types/SidebarNavigation.ts +11 -3
- package/src/elements/content-preview/PreviewNavigation.js +86 -2
- package/src/elements/content-preview/__tests__/PreviewNavigation.test.js +202 -62
- package/src/elements/content-sidebar/ActivitySidebar.js +42 -6
- package/src/elements/content-sidebar/__tests__/ActivitySidebar.rtl.test.js +521 -0
- package/src/elements/content-sidebar/__tests__/ActivitySidebar.test.js +1 -123
- package/src/elements/content-sidebar/__tests__/AddTaskButton.test.js +6 -5
- package/src/elements/content-sidebar/versions/__tests__/StaticVersionSidebar.test.js +3 -5
- package/src/elements/content-preview/__tests__/__snapshots__/PreviewNavigation.test.js.snap +0 -361
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export let ViewType = /*#__PURE__*/function (ViewType) {
|
|
2
|
-
ViewType["BOXAI"] = "boxai";
|
|
3
2
|
ViewType["SKILLS"] = "skills";
|
|
4
|
-
ViewType["ACTIVITY"] = "activity";
|
|
5
3
|
ViewType["DETAILS"] = "details";
|
|
6
4
|
ViewType["METADATA"] = "metadata";
|
|
5
|
+
ViewType["METADATA_REDESIGN"] = "metadata_redesign";
|
|
6
|
+
ViewType["BOXAI"] = "boxai";
|
|
7
|
+
ViewType["ACTIVITY"] = "activity";
|
|
8
|
+
ViewType["VERSIONS"] = "versions";
|
|
7
9
|
ViewType["DOCGEN"] = "docgen";
|
|
8
10
|
return ViewType;
|
|
9
11
|
}({});
|
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
|
|
6
6
|
export const ViewType = Object.freeze({
|
|
7
7
|
BOXAI: 'boxai',
|
|
8
|
-
SKILLS: 'skills',
|
|
9
|
-
ACTIVITY: 'activity',
|
|
10
8
|
DETAILS: 'details',
|
|
11
9
|
METADATA: 'metadata',
|
|
10
|
+
METADATA_REDESIGN: 'metadata_redesign',
|
|
11
|
+
SKILLS: 'skills',
|
|
12
|
+
ACTIVITY: 'activity',
|
|
13
|
+
VERSIONS: 'versions',
|
|
12
14
|
DOCGEN: 'docgen',
|
|
13
15
|
});
|
|
14
16
|
|
|
@@ -22,11 +24,12 @@ export type ViewTypeValues = $Values<typeof ViewType>;
|
|
|
22
24
|
export type FeedEntryTypeValues = $Values<typeof FeedEntryType>;
|
|
23
25
|
|
|
24
26
|
export type SidebarNavigation = {
|
|
25
|
-
sidebar: ViewTypeValues,
|
|
26
|
-
versionId?: string,
|
|
27
27
|
activeFeedEntryType?: FeedEntryTypeValues,
|
|
28
28
|
activeFeedEntryId?: string,
|
|
29
29
|
fileVersionId?: string,
|
|
30
|
+
filteredTemplateIds?: string,
|
|
31
|
+
sidebar: ViewTypeValues,
|
|
32
|
+
versionId?: string,
|
|
30
33
|
};
|
|
31
34
|
|
|
32
35
|
export type InternalSidebarNavigation = SidebarNavigation & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SidebarNavigation.js","names":["ViewType","FeedEntryType"],"sources":["../../../../src/elements/common/types/SidebarNavigation.ts"],"sourcesContent":["export enum ViewType {\n
|
|
1
|
+
{"version":3,"file":"SidebarNavigation.js","names":["ViewType","FeedEntryType"],"sources":["../../../../src/elements/common/types/SidebarNavigation.ts"],"sourcesContent":["export enum ViewType {\n SKILLS = 'skills',\n DETAILS = 'details',\n METADATA = 'metadata',\n METADATA_REDESIGN = 'metadata_redesign',\n BOXAI = 'boxai',\n ACTIVITY = 'activity',\n VERSIONS = 'versions',\n DOCGEN = 'docgen',\n}\n\nexport enum FeedEntryType {\n ANNOTATIONS = 'annotations',\n COMMENTS = 'comments',\n TASKS = 'tasks',\n}\n\ntype VersionSidebarView = {\n sidebar: ViewType.ACTIVITY | ViewType.DETAILS;\n versionId: string;\n};\n\nexport type MetadataSidebarView = {\n sidebar: ViewType.METADATA | ViewType.METADATA_REDESIGN;\n filteredTemplateIds?: string;\n};\n\nexport type ActivityAnnotationsSidebarView = {\n sidebar: ViewType.ACTIVITY;\n activeFeedEntryType: FeedEntryType.ANNOTATIONS;\n fileVersionId: string;\n activeFeedEntryId?: string;\n};\ntype ActivityCommentsSidebarView = {\n sidebar: ViewType.ACTIVITY;\n activeFeedEntryType: FeedEntryType.COMMENTS | FeedEntryType.TASKS;\n activeFeedEntryId: string;\n};\n\nexport type SidebarNavigation =\n | {\n sidebar: ViewType;\n }\n | VersionSidebarView\n | MetadataSidebarView\n | ActivityCommentsSidebarView\n | ActivityAnnotationsSidebarView;\n\nexport type InternalSidebarNavigation = SidebarNavigation & {\n open?: boolean;\n};\n\nexport type SidebarNavigationHandler = (sidebar: SidebarNavigation, replace?: boolean) => void;\n\nexport type InternalSidebarNavigationHandler = (sidebar: InternalSidebarNavigation, replace?: boolean) => void;\n"],"mappings":"AAAA,WAAYA,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;AAWpB,WAAYC,aAAa,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA","ignoreList":[]}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
const _excluded = ["sidebar"];
|
|
2
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
3
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
1
4
|
/**
|
|
2
5
|
*
|
|
3
6
|
* @file Preview Navigation
|
|
@@ -12,7 +15,7 @@ import IconNavigateRight from '../../icons/general/IconNavigateRight';
|
|
|
12
15
|
import PlainButton from '../../components/plain-button/PlainButton';
|
|
13
16
|
import messages from '../common/messages';
|
|
14
17
|
import { SIDEBAR_VIEW_METADATA } from '../../constants';
|
|
15
|
-
const
|
|
18
|
+
const PreviewNavigationWithRouter = ({
|
|
16
19
|
collection = [],
|
|
17
20
|
currentIndex,
|
|
18
21
|
intl,
|
|
@@ -40,6 +43,7 @@ const PreviewNavigation = ({
|
|
|
40
43
|
history
|
|
41
44
|
}) => /*#__PURE__*/React.createElement(React.Fragment, null, hasLeftNavigation && /*#__PURE__*/React.createElement(PlainButton, {
|
|
42
45
|
className: "bcpr-navigate-left",
|
|
46
|
+
"data-testid": "preview-navigation-left",
|
|
43
47
|
onClick: () => {
|
|
44
48
|
goToActiveSidebarTab(match.params, history);
|
|
45
49
|
onNavigateLeft();
|
|
@@ -48,6 +52,7 @@ const PreviewNavigation = ({
|
|
|
48
52
|
type: "button"
|
|
49
53
|
}, /*#__PURE__*/React.createElement(IconNavigateLeft, null)), hasRightNavigation && /*#__PURE__*/React.createElement(PlainButton, {
|
|
50
54
|
className: "bcpr-navigate-right",
|
|
55
|
+
"data-testid": "preview-navigation-right",
|
|
51
56
|
onClick: () => {
|
|
52
57
|
goToActiveSidebarTab(match.params, history);
|
|
53
58
|
onNavigateRight();
|
|
@@ -56,6 +61,64 @@ const PreviewNavigation = ({
|
|
|
56
61
|
type: "button"
|
|
57
62
|
}, /*#__PURE__*/React.createElement(IconNavigateRight, null))));
|
|
58
63
|
};
|
|
59
|
-
|
|
64
|
+
const PreviewNavigationWithoutRouter = ({
|
|
65
|
+
collection = [],
|
|
66
|
+
currentIndex,
|
|
67
|
+
intl,
|
|
68
|
+
internalSidebarNavigation,
|
|
69
|
+
internalSidebarNavigationHandler,
|
|
70
|
+
onNavigateLeft,
|
|
71
|
+
onNavigateRight
|
|
72
|
+
}) => {
|
|
73
|
+
const hasLeftNavigation = collection.length > 1 && currentIndex > 0 && currentIndex < collection.length;
|
|
74
|
+
const hasRightNavigation = collection.length > 1 && currentIndex > -1 && currentIndex < collection.length - 1;
|
|
75
|
+
if (!hasLeftNavigation && !hasRightNavigation) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const handleInternalNavigation = () => {
|
|
79
|
+
if (internalSidebarNavigationHandler && internalSidebarNavigation && internalSidebarNavigation.sidebar) {
|
|
80
|
+
const {
|
|
81
|
+
sidebar
|
|
82
|
+
} = internalSidebarNavigation,
|
|
83
|
+
rest = _objectWithoutProperties(internalSidebarNavigation, _excluded);
|
|
84
|
+
const hasDeeplink = Object.keys(rest).length > 0;
|
|
85
|
+
if (hasDeeplink && sidebar === SIDEBAR_VIEW_METADATA) {
|
|
86
|
+
internalSidebarNavigationHandler(internalSidebarNavigation);
|
|
87
|
+
} else {
|
|
88
|
+
internalSidebarNavigationHandler({
|
|
89
|
+
sidebar
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, hasLeftNavigation && /*#__PURE__*/React.createElement(PlainButton, {
|
|
95
|
+
className: "bcpr-navigate-left",
|
|
96
|
+
"data-testid": "preview-navigation-left",
|
|
97
|
+
onClick: () => {
|
|
98
|
+
handleInternalNavigation();
|
|
99
|
+
onNavigateLeft();
|
|
100
|
+
},
|
|
101
|
+
title: intl.formatMessage(messages.previousFile),
|
|
102
|
+
type: "button"
|
|
103
|
+
}, /*#__PURE__*/React.createElement(IconNavigateLeft, null)), hasRightNavigation && /*#__PURE__*/React.createElement(PlainButton, {
|
|
104
|
+
className: "bcpr-navigate-right",
|
|
105
|
+
"data-testid": "preview-navigation-right",
|
|
106
|
+
onClick: () => {
|
|
107
|
+
handleInternalNavigation();
|
|
108
|
+
onNavigateRight();
|
|
109
|
+
},
|
|
110
|
+
title: intl.formatMessage(messages.nextFile),
|
|
111
|
+
type: "button"
|
|
112
|
+
}, /*#__PURE__*/React.createElement(IconNavigateRight, null)));
|
|
113
|
+
};
|
|
114
|
+
const PreviewNavigation = props => {
|
|
115
|
+
const {
|
|
116
|
+
routerDisabled = false
|
|
117
|
+
} = props;
|
|
118
|
+
if (routerDisabled) {
|
|
119
|
+
return /*#__PURE__*/React.createElement(PreviewNavigationWithoutRouter, props);
|
|
120
|
+
}
|
|
121
|
+
return /*#__PURE__*/React.createElement(PreviewNavigationWithRouter, props);
|
|
122
|
+
};
|
|
60
123
|
export default injectIntl(PreviewNavigation);
|
|
61
124
|
//# sourceMappingURL=PreviewNavigation.js.map
|
|
@@ -14,16 +14,26 @@ import PlainButton from '../../components/plain-button/PlainButton';
|
|
|
14
14
|
import messages from '../common/messages';
|
|
15
15
|
import type { BoxItem } from '../../common/types/core';
|
|
16
16
|
import { SIDEBAR_VIEW_METADATA } from '../../constants';
|
|
17
|
+
import type { InternalSidebarNavigation, InternalSidebarNavigationHandler } from '../common/types/SidebarNavigation';
|
|
17
18
|
|
|
18
19
|
type Props = {
|
|
19
20
|
collection: Array<string | BoxItem>,
|
|
20
21
|
currentIndex: number,
|
|
21
22
|
intl: IntlShape,
|
|
23
|
+
internalSidebarNavigation?: InternalSidebarNavigation,
|
|
24
|
+
internalSidebarNavigationHandler?: InternalSidebarNavigationHandler,
|
|
22
25
|
onNavigateLeft: Function,
|
|
23
26
|
onNavigateRight: Function,
|
|
27
|
+
routerDisabled?: boolean,
|
|
24
28
|
};
|
|
25
29
|
|
|
26
|
-
const
|
|
30
|
+
const PreviewNavigationWithRouter = ({
|
|
31
|
+
collection = [],
|
|
32
|
+
currentIndex,
|
|
33
|
+
intl,
|
|
34
|
+
onNavigateLeft,
|
|
35
|
+
onNavigateRight,
|
|
36
|
+
}: Props) => {
|
|
27
37
|
const hasLeftNavigation = collection.length > 1 && currentIndex > 0 && currentIndex < collection.length;
|
|
28
38
|
const hasRightNavigation = collection.length > 1 && currentIndex > -1 && currentIndex < collection.length - 1;
|
|
29
39
|
|
|
@@ -48,6 +58,7 @@ const PreviewNavigation = ({ collection = [], currentIndex, intl, onNavigateLeft
|
|
|
48
58
|
{hasLeftNavigation && (
|
|
49
59
|
<PlainButton
|
|
50
60
|
className="bcpr-navigate-left"
|
|
61
|
+
data-testid="preview-navigation-left"
|
|
51
62
|
onClick={() => {
|
|
52
63
|
goToActiveSidebarTab(match.params, history);
|
|
53
64
|
onNavigateLeft();
|
|
@@ -61,6 +72,7 @@ const PreviewNavigation = ({ collection = [], currentIndex, intl, onNavigateLeft
|
|
|
61
72
|
{hasRightNavigation && (
|
|
62
73
|
<PlainButton
|
|
63
74
|
className="bcpr-navigate-right"
|
|
75
|
+
data-testid="preview-navigation-right"
|
|
64
76
|
onClick={() => {
|
|
65
77
|
goToActiveSidebarTab(match.params, history);
|
|
66
78
|
onNavigateRight();
|
|
@@ -77,5 +89,77 @@ const PreviewNavigation = ({ collection = [], currentIndex, intl, onNavigateLeft
|
|
|
77
89
|
);
|
|
78
90
|
};
|
|
79
91
|
|
|
80
|
-
|
|
92
|
+
const PreviewNavigationWithoutRouter = ({
|
|
93
|
+
collection = [],
|
|
94
|
+
currentIndex,
|
|
95
|
+
intl,
|
|
96
|
+
internalSidebarNavigation,
|
|
97
|
+
internalSidebarNavigationHandler,
|
|
98
|
+
onNavigateLeft,
|
|
99
|
+
onNavigateRight,
|
|
100
|
+
}: Props) => {
|
|
101
|
+
const hasLeftNavigation = collection.length > 1 && currentIndex > 0 && currentIndex < collection.length;
|
|
102
|
+
const hasRightNavigation = collection.length > 1 && currentIndex > -1 && currentIndex < collection.length - 1;
|
|
103
|
+
|
|
104
|
+
if (!hasLeftNavigation && !hasRightNavigation) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const handleInternalNavigation = () => {
|
|
109
|
+
if (internalSidebarNavigationHandler && internalSidebarNavigation && internalSidebarNavigation.sidebar) {
|
|
110
|
+
const { sidebar, ...rest } = internalSidebarNavigation;
|
|
111
|
+
const hasDeeplink = Object.keys(rest).length > 0;
|
|
112
|
+
|
|
113
|
+
if (hasDeeplink && sidebar === SIDEBAR_VIEW_METADATA) {
|
|
114
|
+
internalSidebarNavigationHandler(internalSidebarNavigation);
|
|
115
|
+
} else {
|
|
116
|
+
internalSidebarNavigationHandler({ sidebar });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<>
|
|
123
|
+
{hasLeftNavigation && (
|
|
124
|
+
<PlainButton
|
|
125
|
+
className="bcpr-navigate-left"
|
|
126
|
+
data-testid="preview-navigation-left"
|
|
127
|
+
onClick={() => {
|
|
128
|
+
handleInternalNavigation();
|
|
129
|
+
onNavigateLeft();
|
|
130
|
+
}}
|
|
131
|
+
title={intl.formatMessage(messages.previousFile)}
|
|
132
|
+
type="button"
|
|
133
|
+
>
|
|
134
|
+
<IconNavigateLeft />
|
|
135
|
+
</PlainButton>
|
|
136
|
+
)}
|
|
137
|
+
{hasRightNavigation && (
|
|
138
|
+
<PlainButton
|
|
139
|
+
className="bcpr-navigate-right"
|
|
140
|
+
data-testid="preview-navigation-right"
|
|
141
|
+
onClick={() => {
|
|
142
|
+
handleInternalNavigation();
|
|
143
|
+
onNavigateRight();
|
|
144
|
+
}}
|
|
145
|
+
title={intl.formatMessage(messages.nextFile)}
|
|
146
|
+
type="button"
|
|
147
|
+
>
|
|
148
|
+
<IconNavigateRight />
|
|
149
|
+
</PlainButton>
|
|
150
|
+
)}
|
|
151
|
+
</>
|
|
152
|
+
);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const PreviewNavigation = (props: Props) => {
|
|
156
|
+
const { routerDisabled = false } = props;
|
|
157
|
+
|
|
158
|
+
if (routerDisabled) {
|
|
159
|
+
return <PreviewNavigationWithoutRouter {...props} />;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return <PreviewNavigationWithRouter {...props} />;
|
|
163
|
+
};
|
|
164
|
+
|
|
81
165
|
export default injectIntl(PreviewNavigation);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewNavigation.js","names":["React","injectIntl","Route","IconNavigateLeft","IconNavigateRight","PlainButton","messages","SIDEBAR_VIEW_METADATA","PreviewNavigation","collection","currentIndex","intl","onNavigateLeft","onNavigateRight","hasLeftNavigation","length","hasRightNavigation","goToActiveSidebarTab","routeParams","history","deeplink","activeTab","push","createElement","path","match","Fragment","className","onClick","params","title","formatMessage","previousFile","type","nextFile","PreviewNavigationComponent"],"sources":["../../../src/elements/content-preview/PreviewNavigation.js"],"sourcesContent":["/**\n * @flow\n * @file Preview Navigation\n * @author Box\n */\n\nimport * as React from 'react';\nimport { injectIntl } from 'react-intl';\nimport type { IntlShape } from 'react-intl';\nimport { Route } from 'react-router-dom';\nimport IconNavigateLeft from '../../icons/general/IconNavigateLeft';\nimport IconNavigateRight from '../../icons/general/IconNavigateRight';\nimport PlainButton from '../../components/plain-button/PlainButton';\nimport messages from '../common/messages';\nimport type { BoxItem } from '../../common/types/core';\nimport { SIDEBAR_VIEW_METADATA } from '../../constants';\n\ntype Props = {\n collection: Array<string | BoxItem>,\n currentIndex: number,\n intl: IntlShape,\n onNavigateLeft: Function,\n onNavigateRight: Function,\n};\n\nconst PreviewNavigation = ({ collection = [], currentIndex, intl, onNavigateLeft, onNavigateRight }: Props) => {\n const hasLeftNavigation = collection.length > 1 && currentIndex > 0 && currentIndex < collection.length;\n const hasRightNavigation = collection.length > 1 && currentIndex > -1 && currentIndex < collection.length - 1;\n\n if (!hasLeftNavigation && !hasRightNavigation) {\n return null;\n }\n\n const goToActiveSidebarTab = (routeParams, history) => {\n if (routeParams.deeplink) {\n if (routeParams.activeTab === SIDEBAR_VIEW_METADATA) {\n history.push(`/${routeParams.activeTab}/${routeParams.deeplink}/${routeParams[0]}`);\n } else {\n history.push(`/${routeParams.activeTab}`);\n }\n }\n };\n\n return (\n <Route path={['/:activeTab/:deeplink/*', '/']}>\n {({ match, history }) => (\n <>\n {hasLeftNavigation && (\n <PlainButton\n className=\"bcpr-navigate-left\"\n onClick={() => {\n goToActiveSidebarTab(match.params, history);\n onNavigateLeft();\n }}\n title={intl.formatMessage(messages.previousFile)}\n type=\"button\"\n >\n <IconNavigateLeft />\n </PlainButton>\n )}\n {hasRightNavigation && (\n <PlainButton\n className=\"bcpr-navigate-right\"\n onClick={() => {\n goToActiveSidebarTab(match.params, history);\n onNavigateRight();\n }}\n title={intl.formatMessage(messages.nextFile)}\n type=\"button\"\n >\n <IconNavigateRight />\n </PlainButton>\n )}\n </>\n )}\n </Route>\n );\n};\n\nexport { PreviewNavigation as PreviewNavigationComponent };\nexport default injectIntl(PreviewNavigation);\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,UAAU,QAAQ,YAAY;AAEvC,SAASC,KAAK,QAAQ,kBAAkB;AACxC,OAAOC,gBAAgB,MAAM,sCAAsC;AACnE,OAAOC,iBAAiB,MAAM,uCAAuC;AACrE,OAAOC,WAAW,MAAM,2CAA2C;AACnE,OAAOC,QAAQ,MAAM,oBAAoB;AAEzC,SAASC,qBAAqB,QA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M,EAAEV,OAAO,CAAC;MAC3CP,cAAc,CAAC,CAAC;IACpB,CAAE;IACFkB,KAAK,EAAEnB,IAAI,CAACoB,aAAa,CAACzB,QAAQ,CAAC0B,YAAY,CAAE;IACjDC,IAAI,EAAC;EAAQ,gBAEbjC,KAAA,CAAAuB,aAAA,CAACpB,gBAAgB,MAAE,CACV,CAChB,EACAa,kBAAkB,iBACfhB,KAAA,CAAAuB,aAAA,CAAClB,WAAW;IACRsB,SAAS,EAAC,qBAAqB;IAC/BC,OAAO,EAAEA,CAAA,KAAM;MACXX,oBAAoB,CAACQ,KAAK,CAACI,MAAM,EAAEV,OAAO,CAAC;MAC3CN,eAAe,CAAC,CAAC;IACrB,CAAE;IACFiB,KAAK,EAAEnB,IAAI,CAACoB,aAAa,CAACzB,QAAQ,CAAC4B,QAAQ,CAAE;IAC7CD,IAAI,EAAC;EAAQ,gBAEbjC,KAAA,CAAAuB,aAAA,CAACnB,iBAAiB,MAAE,CACX,CAEnB,CAEH,CAAC;AAEhB,CAAC;AAED,SAASI,iBAAiB,IAAI2B,0BAA0B;AACxD,eAAelC,UAAU,CAACO,iBAAiB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"PreviewNavigation.js","names":["React","injectIntl","Route","IconNavigateLeft","IconNavigateRight","PlainButton","messages","SIDEBAR_VIEW_METADATA","PreviewNavigationWithRouter","collection","currentIndex","intl","onNavigateLeft","onNavigateRight","hasLeftNavigation","length","hasRightNavigation","goToActiveSidebarTab","routeParams","history","deeplink","activeTab","push","createElement","path","match","Fragment","className","onClick","params","title","formatMessage","previousFile","type","nextFile","PreviewNavigationWithoutRouter","internalSidebarNavigation","internalSidebarNavigationHandler","handleInternalNavigation","sidebar","rest","_objectWithoutProperties","_excluded","hasDeeplink","Object","keys","PreviewNavigation","props","routerDisabled"],"sources":["../../../src/elements/content-preview/PreviewNavigation.js"],"sourcesContent":["/**\n * @flow\n * @file Preview Navigation\n * @author Box\n */\n\nimport * as React from 'react';\nimport { injectIntl } from 'react-intl';\nimport type { IntlShape } from 'react-intl';\nimport { Route } from 'react-router-dom';\nimport IconNavigateLeft from '../../icons/general/IconNavigateLeft';\nimport IconNavigateRight from '../../icons/general/IconNavigateRight';\nimport PlainButton from '../../components/plain-button/PlainButton';\nimport messages from '../common/messages';\nimport type { BoxItem } from '../../common/types/core';\nimport { SIDEBAR_VIEW_METADATA } from '../../constants';\nimport type { InternalSidebarNavigation, InternalSidebarNavigationHandler } from '../common/types/SidebarNavigation';\n\ntype Props = {\n collection: Array<string | BoxItem>,\n currentIndex: number,\n intl: IntlShape,\n internalSidebarNavigation?: InternalSidebarNavigation,\n internalSidebarNavigationHandler?: InternalSidebarNavigationHandler,\n onNavigateLeft: Function,\n onNavigateRight: Function,\n routerDisabled?: boolean,\n};\n\nconst PreviewNavigationWithRouter = ({\n collection = [],\n currentIndex,\n intl,\n onNavigateLeft,\n onNavigateRight,\n}: Props) => {\n const hasLeftNavigation = collection.length > 1 && currentIndex > 0 && currentIndex < collection.length;\n const hasRightNavigation = collection.length > 1 && currentIndex > -1 && currentIndex < collection.length - 1;\n\n if (!hasLeftNavigation && !hasRightNavigation) {\n return null;\n }\n\n const goToActiveSidebarTab = (routeParams, history) => {\n if (routeParams.deeplink) {\n if (routeParams.activeTab === SIDEBAR_VIEW_METADATA) {\n history.push(`/${routeParams.activeTab}/${routeParams.deeplink}/${routeParams[0]}`);\n } else {\n history.push(`/${routeParams.activeTab}`);\n }\n }\n };\n\n return (\n <Route path={['/:activeTab/:deeplink/*', '/']}>\n {({ match, history }) => (\n <>\n {hasLeftNavigation && (\n <PlainButton\n className=\"bcpr-navigate-left\"\n data-testid=\"preview-navigation-left\"\n onClick={() => {\n goToActiveSidebarTab(match.params, history);\n onNavigateLeft();\n }}\n title={intl.formatMessage(messages.previousFile)}\n type=\"button\"\n >\n <IconNavigateLeft />\n </PlainButton>\n )}\n {hasRightNavigation && (\n <PlainButton\n className=\"bcpr-navigate-right\"\n data-testid=\"preview-navigation-right\"\n onClick={() => {\n goToActiveSidebarTab(match.params, history);\n onNavigateRight();\n }}\n title={intl.formatMessage(messages.nextFile)}\n type=\"button\"\n >\n <IconNavigateRight />\n </PlainButton>\n )}\n </>\n )}\n </Route>\n );\n};\n\nconst PreviewNavigationWithoutRouter = ({\n collection = [],\n currentIndex,\n intl,\n internalSidebarNavigation,\n internalSidebarNavigationHandler,\n onNavigateLeft,\n onNavigateRight,\n}: Props) => {\n const hasLeftNavigation = collection.length > 1 && currentIndex > 0 && currentIndex < collection.length;\n const hasRightNavigation = collection.length > 1 && currentIndex > -1 && currentIndex < collection.length - 1;\n\n if (!hasLeftNavigation && !hasRightNavigation) {\n return null;\n }\n\n const handleInternalNavigation = () => {\n if (internalSidebarNavigationHandler && internalSidebarNavigation && internalSidebarNavigation.sidebar) {\n const { sidebar, ...rest } = internalSidebarNavigation;\n const hasDeeplink = Object.keys(rest).length > 0;\n\n if (hasDeeplink && sidebar === SIDEBAR_VIEW_METADATA) {\n internalSidebarNavigationHandler(internalSidebarNavigation);\n } else {\n internalSidebarNavigationHandler({ sidebar });\n }\n }\n };\n\n return (\n <>\n {hasLeftNavigation && (\n <PlainButton\n className=\"bcpr-navigate-left\"\n data-testid=\"preview-navigation-left\"\n onClick={() => {\n handleInternalNavigation();\n onNavigateLeft();\n }}\n title={intl.formatMessage(messages.previousFile)}\n type=\"button\"\n >\n <IconNavigateLeft />\n </PlainButton>\n )}\n {hasRightNavigation && (\n <PlainButton\n className=\"bcpr-navigate-right\"\n data-testid=\"preview-navigation-right\"\n onClick={() => {\n handleInternalNavigation();\n onNavigateRight();\n }}\n title={intl.formatMessage(messages.nextFile)}\n type=\"button\"\n >\n <IconNavigateRight />\n </PlainButton>\n )}\n </>\n );\n};\n\nconst PreviewNavigation = (props: Props) => {\n const { routerDisabled = false } = props;\n\n if (routerDisabled) {\n return <PreviewNavigationWithoutRouter {...props} />;\n }\n\n return <PreviewNavigationWithRouter {...props} />;\n};\n\nexport default injectIntl(PreviewNavigation);\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AC,qBAAqB;IAC/B,eAAY,0BAA0B;IACtCC,OAAO,EAAEA,CAAA,KAAM;MACXU,wBAAwB,CAAC,CAAC;MAC1BzB,eAAe,CAAC,CAAC;IACrB,CAAE;IACFiB,KAAK,EAAEnB,IAAI,CAACoB,aAAa,CAACzB,QAAQ,CAAC4B,QAAQ,CAAE;IAC7CD,IAAI,EAAC;EAAQ,gBAEbjC,KAAA,CAAAuB,aAAA,CAACnB,iBAAiB,MAAE,CACX,CAEnB,CAAC;AAEX,CAAC;AAED,MAAM0C,iBAAiB,GAAIC,KAAY,IAAK;EACxC,MAAM;IAAEC,cAAc,GAAG;EAAM,CAAC,GAAGD,KAAK;EAExC,IAAIC,cAAc,EAAE;IAChB,oBAAOhD,KAAA,CAAAuB,aAAA,CAACY,8BAA8B,EAAKY,KAAQ,CAAC;EACxD;EAEA,oBAAO/C,KAAA,CAAAuB,aAAA,CAACf,2BAA2B,EAAKuC,KAAQ,CAAC;AACrD,CAAC;AAED,eAAe9C,UAAU,CAAC6C,iBAAiB,CAAC","ignoreList":[]}
|
|
@@ -33,6 +33,7 @@ import { withFeatureConsumer, isFeatureEnabled } from '../common/feature-checkin
|
|
|
33
33
|
import { withLogger } from '../common/logger';
|
|
34
34
|
import { withRouterAndRef } from '../common/routing';
|
|
35
35
|
import ActivitySidebarFilter from './ActivitySidebarFilter';
|
|
36
|
+
import { ViewType, FeedEntryType } from '../common/types/SidebarNavigation';
|
|
36
37
|
import { ACTIVITY_FILTER_OPTION_ALL, ACTIVITY_FILTER_OPTION_RESOLVED, ACTIVITY_FILTER_OPTION_TASKS, ACTIVITY_FILTER_OPTION_UNRESOLVED, DEFAULT_COLLAB_DEBOUNCE, ERROR_CODE_FETCH_ACTIVITY, FEED_ITEM_TYPE_ANNOTATION, FEED_ITEM_TYPE_COMMENT, FEED_ITEM_TYPE_TASK, FEED_ITEM_TYPE_VERSION, ORIGIN_ACTIVITY_SIDEBAR, SIDEBAR_VIEW_ACTIVITY, TASK_COMPLETION_RULE_ALL, METRIC_TYPE_UAA_PARITY_METRIC } from '../../constants';
|
|
37
38
|
import './ActivitySidebar.scss';
|
|
38
39
|
export const activityFeedInlineError = {
|
|
@@ -339,7 +340,9 @@ class ActivitySidebar extends React.PureComponent {
|
|
|
339
340
|
activeFeedEntryId,
|
|
340
341
|
api,
|
|
341
342
|
file,
|
|
342
|
-
history
|
|
343
|
+
history,
|
|
344
|
+
internalSidebarNavigationHandler,
|
|
345
|
+
routerDisabled
|
|
343
346
|
} = this.props;
|
|
344
347
|
const {
|
|
345
348
|
feedItems
|
|
@@ -353,7 +356,13 @@ class ActivitySidebar extends React.PureComponent {
|
|
|
353
356
|
// Detect if replies are being hidden and activeFeedEntryId belongs to a reply
|
|
354
357
|
// that is in currently being updated parent, in order to disable active item
|
|
355
358
|
if (activeFeedEntryId && replies.length === 1 && feedItems.some(item => item.id === id && item === this.getCommentFeedItemByReplyId(feedItems, activeFeedEntryId))) {
|
|
356
|
-
|
|
359
|
+
if (routerDisabled && internalSidebarNavigationHandler) {
|
|
360
|
+
internalSidebarNavigationHandler({
|
|
361
|
+
sidebar: ViewType.ACTIVITY
|
|
362
|
+
}, true);
|
|
363
|
+
} else {
|
|
364
|
+
history.replace(this.getActiveCommentPath());
|
|
365
|
+
}
|
|
357
366
|
}
|
|
358
367
|
feedAPI.updateFeedItem({
|
|
359
368
|
replies
|
|
@@ -827,16 +836,33 @@ class ActivitySidebar extends React.PureComponent {
|
|
|
827
836
|
getAnnotationsMatchPath,
|
|
828
837
|
getAnnotationsPath,
|
|
829
838
|
history,
|
|
839
|
+
internalSidebarNavigation,
|
|
840
|
+
internalSidebarNavigationHandler,
|
|
830
841
|
location,
|
|
831
|
-
onAnnotationSelect
|
|
842
|
+
onAnnotationSelect,
|
|
843
|
+
routerDisabled
|
|
832
844
|
} = this.props;
|
|
833
845
|
const annotationFileVersionId = getProp(file_version, 'id');
|
|
834
846
|
const currentFileVersionId = getProp(file, 'file_version.id');
|
|
835
|
-
|
|
836
|
-
|
|
847
|
+
let selectedFileVersionId = currentFileVersionId;
|
|
848
|
+
if (routerDisabled && internalSidebarNavigation) {
|
|
849
|
+
selectedFileVersionId = getProp(internalSidebarNavigation, 'fileVersionId', currentFileVersionId);
|
|
850
|
+
} else {
|
|
851
|
+
const match = getAnnotationsMatchPath(location);
|
|
852
|
+
selectedFileVersionId = getProp(match, 'params.fileVersionId', currentFileVersionId);
|
|
853
|
+
}
|
|
837
854
|
emitActiveAnnotationChangeEvent(nextActiveAnnotationId);
|
|
838
855
|
if (annotationFileVersionId && annotationFileVersionId !== selectedFileVersionId) {
|
|
839
|
-
|
|
856
|
+
if (routerDisabled && internalSidebarNavigationHandler) {
|
|
857
|
+
internalSidebarNavigationHandler({
|
|
858
|
+
sidebar: ViewType.ACTIVITY,
|
|
859
|
+
activeFeedEntryId: nextActiveAnnotationId,
|
|
860
|
+
activeFeedEntryType: FeedEntryType.ANNOTATIONS,
|
|
861
|
+
fileVersionId: annotationFileVersionId
|
|
862
|
+
});
|
|
863
|
+
} else {
|
|
864
|
+
history.push(getAnnotationsPath(annotationFileVersionId, nextActiveAnnotationId));
|
|
865
|
+
}
|
|
840
866
|
}
|
|
841
867
|
onAnnotationSelect(annotation);
|
|
842
868
|
});
|
|
@@ -873,7 +899,10 @@ class ActivitySidebar extends React.PureComponent {
|
|
|
873
899
|
_defineProperty(this, "renderAddTaskButton", () => {
|
|
874
900
|
const {
|
|
875
901
|
isDisabled,
|
|
876
|
-
hasTasks
|
|
902
|
+
hasTasks,
|
|
903
|
+
internalSidebarNavigation,
|
|
904
|
+
internalSidebarNavigationHandler,
|
|
905
|
+
routerDisabled
|
|
877
906
|
} = this.props;
|
|
878
907
|
const {
|
|
879
908
|
approverSelectorContacts
|
|
@@ -888,8 +917,11 @@ class ActivitySidebar extends React.PureComponent {
|
|
|
888
917
|
return null;
|
|
889
918
|
}
|
|
890
919
|
return /*#__PURE__*/React.createElement(AddTaskButton, {
|
|
920
|
+
internalSidebarNavigation: internalSidebarNavigation,
|
|
921
|
+
internalSidebarNavigationHandler: internalSidebarNavigationHandler,
|
|
891
922
|
isDisabled: isDisabled,
|
|
892
923
|
onTaskModalClose: onTaskModalClose,
|
|
924
|
+
routerDisabled: routerDisabled,
|
|
893
925
|
taskFormProps: {
|
|
894
926
|
approvers: [],
|
|
895
927
|
approverSelectorContacts,
|
|
@@ -28,6 +28,7 @@ import { withFeatureConsumer, isFeatureEnabled } from '../common/feature-checkin
|
|
|
28
28
|
import { withLogger } from '../common/logger';
|
|
29
29
|
import { withRouterAndRef } from '../common/routing';
|
|
30
30
|
import ActivitySidebarFilter from './ActivitySidebarFilter';
|
|
31
|
+
import { ViewType, FeedEntryType } from '../common/types/SidebarNavigation';
|
|
31
32
|
import {
|
|
32
33
|
ACTIVITY_FILTER_OPTION_ALL,
|
|
33
34
|
ACTIVITY_FILTER_OPTION_RESOLVED,
|
|
@@ -76,6 +77,7 @@ import type { WithAnnotatorContextProps } from '../common/annotator-context';
|
|
|
76
77
|
import './ActivitySidebar.scss';
|
|
77
78
|
|
|
78
79
|
import type { OnAnnotationEdit, OnAnnotationStatusChange } from './activity-feed/comment/types';
|
|
80
|
+
import type { InternalSidebarNavigation, InternalSidebarNavigationHandler } from '../common/types/SidebarNavigation';
|
|
79
81
|
|
|
80
82
|
type ExternalProps = {
|
|
81
83
|
activeFeedEntryId?: string,
|
|
@@ -86,6 +88,8 @@ type ExternalProps = {
|
|
|
86
88
|
hasReplies?: boolean,
|
|
87
89
|
hasTasks?: boolean,
|
|
88
90
|
hasVersions?: boolean,
|
|
91
|
+
internalSidebarNavigation?: InternalSidebarNavigation,
|
|
92
|
+
internalSidebarNavigationHandler?: InternalSidebarNavigationHandler,
|
|
89
93
|
onCommentCreate: Function,
|
|
90
94
|
onCommentDelete: (comment: Comment) => any,
|
|
91
95
|
onCommentUpdate: () => any,
|
|
@@ -94,6 +98,7 @@ type ExternalProps = {
|
|
|
94
98
|
onTaskDelete: (id: string) => any,
|
|
95
99
|
onTaskUpdate: () => any,
|
|
96
100
|
onTaskView: (id: string, isCreator: boolean) => any,
|
|
101
|
+
routerDisabled?: boolean,
|
|
97
102
|
} & ErrorContextProps &
|
|
98
103
|
WithAnnotatorContextProps;
|
|
99
104
|
|
|
@@ -547,7 +552,7 @@ class ActivitySidebar extends React.PureComponent<Props, State> {
|
|
|
547
552
|
* @return {void}
|
|
548
553
|
*/
|
|
549
554
|
updateReplies = (id: string, replies: Array<Comment>) => {
|
|
550
|
-
const { activeFeedEntryId, api, file, history } = this.props;
|
|
555
|
+
const { activeFeedEntryId, api, file, history, internalSidebarNavigationHandler, routerDisabled } = this.props;
|
|
551
556
|
const { feedItems } = this.state;
|
|
552
557
|
|
|
553
558
|
if (!feedItems) {
|
|
@@ -567,7 +572,16 @@ class ActivitySidebar extends React.PureComponent<Props, State> {
|
|
|
567
572
|
item.id === id && item === this.getCommentFeedItemByReplyId(feedItems, activeFeedEntryId),
|
|
568
573
|
)
|
|
569
574
|
) {
|
|
570
|
-
|
|
575
|
+
if (routerDisabled && internalSidebarNavigationHandler) {
|
|
576
|
+
internalSidebarNavigationHandler(
|
|
577
|
+
{
|
|
578
|
+
sidebar: ViewType.ACTIVITY,
|
|
579
|
+
},
|
|
580
|
+
true,
|
|
581
|
+
);
|
|
582
|
+
} else {
|
|
583
|
+
history.replace(this.getActiveCommentPath());
|
|
584
|
+
}
|
|
571
585
|
}
|
|
572
586
|
|
|
573
587
|
feedAPI.updateFeedItem({ replies }, id);
|
|
@@ -1108,18 +1122,36 @@ class ActivitySidebar extends React.PureComponent<Props, State> {
|
|
|
1108
1122
|
getAnnotationsMatchPath,
|
|
1109
1123
|
getAnnotationsPath,
|
|
1110
1124
|
history,
|
|
1125
|
+
internalSidebarNavigation,
|
|
1126
|
+
internalSidebarNavigationHandler,
|
|
1111
1127
|
location,
|
|
1112
1128
|
onAnnotationSelect,
|
|
1129
|
+
routerDisabled,
|
|
1113
1130
|
} = this.props;
|
|
1114
1131
|
const annotationFileVersionId = getProp(file_version, 'id');
|
|
1115
1132
|
const currentFileVersionId = getProp(file, 'file_version.id');
|
|
1116
|
-
|
|
1117
|
-
|
|
1133
|
+
|
|
1134
|
+
let selectedFileVersionId = currentFileVersionId;
|
|
1135
|
+
if (routerDisabled && internalSidebarNavigation) {
|
|
1136
|
+
selectedFileVersionId = getProp(internalSidebarNavigation, 'fileVersionId', currentFileVersionId);
|
|
1137
|
+
} else {
|
|
1138
|
+
const match = getAnnotationsMatchPath(location);
|
|
1139
|
+
selectedFileVersionId = getProp(match, 'params.fileVersionId', currentFileVersionId);
|
|
1140
|
+
}
|
|
1118
1141
|
|
|
1119
1142
|
emitActiveAnnotationChangeEvent(nextActiveAnnotationId);
|
|
1120
1143
|
|
|
1121
1144
|
if (annotationFileVersionId && annotationFileVersionId !== selectedFileVersionId) {
|
|
1122
|
-
|
|
1145
|
+
if (routerDisabled && internalSidebarNavigationHandler) {
|
|
1146
|
+
internalSidebarNavigationHandler({
|
|
1147
|
+
sidebar: ViewType.ACTIVITY,
|
|
1148
|
+
activeFeedEntryId: nextActiveAnnotationId,
|
|
1149
|
+
activeFeedEntryType: FeedEntryType.ANNOTATIONS,
|
|
1150
|
+
fileVersionId: annotationFileVersionId,
|
|
1151
|
+
});
|
|
1152
|
+
} else {
|
|
1153
|
+
history.push(getAnnotationsPath(annotationFileVersionId, nextActiveAnnotationId));
|
|
1154
|
+
}
|
|
1123
1155
|
}
|
|
1124
1156
|
|
|
1125
1157
|
onAnnotationSelect(annotation);
|
|
@@ -1161,7 +1193,8 @@ class ActivitySidebar extends React.PureComponent<Props, State> {
|
|
|
1161
1193
|
}
|
|
1162
1194
|
|
|
1163
1195
|
renderAddTaskButton = () => {
|
|
1164
|
-
const { isDisabled, hasTasks } =
|
|
1196
|
+
const { isDisabled, hasTasks, internalSidebarNavigation, internalSidebarNavigationHandler, routerDisabled } =
|
|
1197
|
+
this.props;
|
|
1165
1198
|
const { approverSelectorContacts } = this.state;
|
|
1166
1199
|
const { getApprover, getAvatarUrl, createTask, onTaskModalClose } = this;
|
|
1167
1200
|
|
|
@@ -1171,8 +1204,11 @@ class ActivitySidebar extends React.PureComponent<Props, State> {
|
|
|
1171
1204
|
|
|
1172
1205
|
return (
|
|
1173
1206
|
<AddTaskButton
|
|
1207
|
+
internalSidebarNavigation={internalSidebarNavigation}
|
|
1208
|
+
internalSidebarNavigationHandler={internalSidebarNavigationHandler}
|
|
1174
1209
|
isDisabled={isDisabled}
|
|
1175
1210
|
onTaskModalClose={onTaskModalClose}
|
|
1211
|
+
routerDisabled={routerDisabled}
|
|
1176
1212
|
taskFormProps={{
|
|
1177
1213
|
approvers: [],
|
|
1178
1214
|
approverSelectorContacts,
|