box-ui-elements 23.4.0-beta.16 → 23.4.0-beta.18
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/nav-button/BackButton.js +5 -8
- package/es/elements/common/nav-button/BackButton.js.flow +8 -18
- package/es/elements/common/nav-button/BackButton.js.map +1 -1
- package/{src/elements/common/types/SidebarNavigation.flow.js → es/elements/common/types/SidebarNavigation.js.flow} +9 -23
- package/es/elements/content-sidebar/versions/StaticVersionSidebar.js +6 -3
- package/es/elements/content-sidebar/versions/StaticVersionSidebar.js.flow +47 -42
- package/es/elements/content-sidebar/versions/StaticVersionSidebar.js.map +1 -1
- package/es/elements/content-sidebar/versions/VersionsGroup.js.flow +3 -0
- package/es/elements/content-sidebar/versions/VersionsGroup.js.map +1 -1
- package/es/elements/content-sidebar/versions/VersionsList.js +16 -8
- package/es/elements/content-sidebar/versions/VersionsList.js.flow +35 -17
- package/es/elements/content-sidebar/versions/VersionsList.js.map +1 -1
- package/es/elements/content-sidebar/versions/VersionsMenu.js.flow +3 -0
- package/es/elements/content-sidebar/versions/VersionsMenu.js.map +1 -1
- package/es/elements/content-sidebar/versions/VersionsSidebar.js +6 -3
- package/es/elements/content-sidebar/versions/VersionsSidebar.js.flow +48 -39
- package/es/elements/content-sidebar/versions/VersionsSidebar.js.map +1 -1
- package/es/src/test-utils/testing-library.d.ts +2 -1
- package/es/test-utils/testing-library.js +4 -1
- package/es/test-utils/testing-library.js.map +1 -1
- package/package.json +3 -3
- package/src/elements/common/nav-button/BackButton.js +8 -18
- package/src/elements/common/nav-button/__tests__/BackButton.test.js +36 -27
- package/{es/elements/common/types/SidebarNavigation.flow.js.flow → src/elements/common/types/SidebarNavigation.js.flow} +9 -23
- package/src/elements/content-sidebar/versions/StaticVersionSidebar.js +47 -42
- package/src/elements/content-sidebar/versions/VersionsGroup.js +3 -0
- package/src/elements/content-sidebar/versions/VersionsList.js +35 -17
- package/src/elements/content-sidebar/versions/VersionsMenu.js +3 -0
- package/src/elements/content-sidebar/versions/VersionsSidebar.js +48 -39
- package/src/elements/content-sidebar/versions/__tests__/StaticVersionSidebar.test.js +171 -0
- package/src/elements/content-sidebar/versions/__tests__/VersionsList.test.js +138 -13
- package/src/elements/content-sidebar/versions/__tests__/VersionsMenu.test.js +75 -23
- package/src/elements/content-sidebar/versions/__tests__/VersionsSidebar.test.js +147 -20
- package/src/test-utils/testing-library.tsx +4 -1
- package/es/elements/common/types/SidebarNavigation.flow.js +0 -14
- package/es/elements/common/types/SidebarNavigation.flow.js.map +0 -1
- package/src/elements/common/nav-button/__tests__/__snapshots__/BackButton.test.js.snap +0 -64
- package/src/elements/content-sidebar/versions/__tests__/__snapshots__/VersionsList.test.js.snap +0 -45
- package/src/elements/content-sidebar/versions/__tests__/__snapshots__/VersionsSidebar.test.js.snap +0 -92
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import { FormattedMessage } from 'react-intl';
|
|
9
|
+
import { Route } from 'react-router-dom';
|
|
9
10
|
import type { MessageDescriptor } from 'react-intl';
|
|
10
11
|
import InlineError from '../../../components/inline-error';
|
|
11
12
|
import messages from './messages';
|
|
@@ -36,47 +37,55 @@ const VersionsSidebar = ({ error, isLoading, parentName, versions, ...rest }: Pr
|
|
|
36
37
|
const showError = !!error;
|
|
37
38
|
|
|
38
39
|
return (
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
40
|
+
<Route>
|
|
41
|
+
{({ history }) => (
|
|
42
|
+
<SidebarContent
|
|
43
|
+
className="bcs-Versions"
|
|
44
|
+
data-resin-component="preview"
|
|
45
|
+
data-resin-feature="versions"
|
|
46
|
+
title={
|
|
47
|
+
<>
|
|
48
|
+
<BackButton data-resin-target="back" onClick={() => history.push(`/${parentName}`)} />
|
|
49
|
+
<FormattedMessage {...messages.versionsTitle} />
|
|
50
|
+
</>
|
|
51
|
+
}
|
|
52
|
+
>
|
|
53
|
+
<LoadingIndicatorWrapper
|
|
54
|
+
className="bcs-Versions-content"
|
|
55
|
+
crawlerPosition="top"
|
|
56
|
+
isLoading={isLoading}
|
|
57
|
+
>
|
|
58
|
+
{showError && (
|
|
59
|
+
<InlineError title={<FormattedMessage {...messages.versionServerError} />}>
|
|
60
|
+
<FormattedMessage {...error} />
|
|
61
|
+
</InlineError>
|
|
62
|
+
)}
|
|
56
63
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
{showEmpty && (
|
|
65
|
+
<div className="bcs-Versions-empty">
|
|
66
|
+
<FormattedMessage {...messages.versionsEmpty} />
|
|
67
|
+
</div>
|
|
68
|
+
)}
|
|
62
69
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
{showVersions && (
|
|
71
|
+
<div className="bcs-Versions-menu" data-testid="bcs-Versions-menu">
|
|
72
|
+
<VersionsMenu versions={versions} {...rest} />
|
|
73
|
+
</div>
|
|
74
|
+
)}
|
|
75
|
+
{showLimit && (
|
|
76
|
+
<div className="bcs-Versions-maxEntries" data-testid="max-versions">
|
|
77
|
+
<FormattedMessage
|
|
78
|
+
{...messages.versionMaxEntries}
|
|
79
|
+
values={{
|
|
80
|
+
maxVersions: MAX_VERSIONS,
|
|
81
|
+
}}
|
|
82
|
+
/>
|
|
83
|
+
</div>
|
|
84
|
+
)}
|
|
85
|
+
</LoadingIndicatorWrapper>
|
|
86
|
+
</SidebarContent>
|
|
87
|
+
)}
|
|
88
|
+
</Route>
|
|
80
89
|
);
|
|
81
90
|
};
|
|
82
91
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VersionsSidebar.js","names":["React","FormattedMessage","InlineError","messages","SidebarContent","VersionsMenu","BackButton","DEFAULT_FETCH_END","LoadingIndicatorWrapper","MAX_VERSIONS","VersionsSidebar","_ref","error","isLoading","parentName","versions","rest","_objectWithoutProperties","_excluded","showLimit","length","showVersions","showEmpty","showError","createElement","className","title","Fragment","
|
|
1
|
+
{"version":3,"file":"VersionsSidebar.js","names":["React","FormattedMessage","Route","InlineError","messages","SidebarContent","VersionsMenu","BackButton","DEFAULT_FETCH_END","LoadingIndicatorWrapper","MAX_VERSIONS","VersionsSidebar","_ref","error","isLoading","parentName","versions","rest","_objectWithoutProperties","_excluded","showLimit","length","showVersions","showEmpty","showError","createElement","history","className","title","Fragment","onClick","push","versionsTitle","crawlerPosition","versionServerError","versionsEmpty","_extends","versionMaxEntries","values","maxVersions"],"sources":["../../../../src/elements/content-sidebar/versions/VersionsSidebar.js"],"sourcesContent":["/**\n * @flow\n * @file Versions Sidebar component\n * @author Box\n */\n\nimport * as React from 'react';\nimport { FormattedMessage } from 'react-intl';\nimport { Route } from 'react-router-dom';\nimport type { MessageDescriptor } from 'react-intl';\nimport InlineError from '../../../components/inline-error';\nimport messages from './messages';\nimport SidebarContent from '../SidebarContent';\nimport VersionsMenu from './VersionsMenu';\nimport { BackButton } from '../../common/nav-button';\nimport { DEFAULT_FETCH_END } from '../../../constants';\nimport { LoadingIndicatorWrapper } from '../../../components/loading-indicator';\nimport type { BoxItemVersion } from '../../../common/types/core';\nimport './VersionsSidebar.scss';\n\nconst MAX_VERSIONS = DEFAULT_FETCH_END;\n\ntype Props = {\n error?: MessageDescriptor,\n fileId: string,\n isLoading: boolean,\n parentName: string,\n versionCount: number,\n versionLimit: number,\n versions: Array<BoxItemVersion>,\n};\n\nconst VersionsSidebar = ({ error, isLoading, parentName, versions, ...rest }: Props) => {\n const showLimit = versions.length >= MAX_VERSIONS;\n const showVersions = !!versions.length;\n const showEmpty = !isLoading && !showVersions;\n const showError = !!error;\n\n return (\n <Route>\n {({ history }) => (\n <SidebarContent\n className=\"bcs-Versions\"\n data-resin-component=\"preview\"\n data-resin-feature=\"versions\"\n title={\n <>\n <BackButton data-resin-target=\"back\" onClick={() => history.push(`/${parentName}`)} />\n <FormattedMessage {...messages.versionsTitle} />\n </>\n }\n >\n <LoadingIndicatorWrapper\n className=\"bcs-Versions-content\"\n crawlerPosition=\"top\"\n isLoading={isLoading}\n >\n {showError && (\n <InlineError title={<FormattedMessage {...messages.versionServerError} />}>\n <FormattedMessage {...error} />\n </InlineError>\n )}\n\n {showEmpty && (\n <div className=\"bcs-Versions-empty\">\n <FormattedMessage {...messages.versionsEmpty} />\n </div>\n )}\n\n {showVersions && (\n <div className=\"bcs-Versions-menu\" data-testid=\"bcs-Versions-menu\">\n <VersionsMenu versions={versions} {...rest} />\n </div>\n )}\n {showLimit && (\n <div className=\"bcs-Versions-maxEntries\" data-testid=\"max-versions\">\n <FormattedMessage\n {...messages.versionMaxEntries}\n values={{\n maxVersions: MAX_VERSIONS,\n }}\n />\n </div>\n )}\n </LoadingIndicatorWrapper>\n </SidebarContent>\n )}\n </Route>\n );\n};\n\nexport default VersionsSidebar;\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -3,5 +3,6 @@ type RenderConnectedOptions = RenderOptions & {
|
|
|
3
3
|
wrapperProps?: Record<string, unknown>;
|
|
4
4
|
};
|
|
5
5
|
declare const renderConnected: (element: any, options?: RenderConnectedOptions) => import("@testing-library/react").RenderResult<typeof import("@testing-library/dom/types/queries"), HTMLElement, HTMLElement>;
|
|
6
|
+
declare const createUserEvent: () => import("@testing-library/user-event").UserEvent;
|
|
6
7
|
export * from '@testing-library/react';
|
|
7
|
-
export { renderConnected as render };
|
|
8
|
+
export { renderConnected as render, createUserEvent as userEvent };
|
|
@@ -6,6 +6,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { render } from '@testing-library/react';
|
|
9
|
+
import userEventInit from '@testing-library/user-event';
|
|
9
10
|
|
|
10
11
|
// Data Providers
|
|
11
12
|
import { TooltipProvider } from '@box/blueprint-web';
|
|
@@ -23,6 +24,8 @@ const Wrapper = ({
|
|
|
23
24
|
const renderConnected = (element, options = {}) => render(element, _objectSpread({
|
|
24
25
|
wrapper: options.wrapper ? options.wrapper : props => /*#__PURE__*/React.createElement(Wrapper, _extends({}, props, options.wrapperProps))
|
|
25
26
|
}, options));
|
|
27
|
+
const createUserEvent = () => userEventInit.setup(); // factory function to create isolated userEvent instances
|
|
28
|
+
|
|
26
29
|
export * from '@testing-library/react';
|
|
27
|
-
export { renderConnected as render };
|
|
30
|
+
export { renderConnected as render, createUserEvent as userEvent };
|
|
28
31
|
//# sourceMappingURL=testing-library.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing-library.js","names":["React","render","TooltipProvider","IntlProvider","FeatureProvider","jest","unmock","Wrapper","children","features","createElement","locale","renderConnected","element","options","_objectSpread","wrapper","props","_extends","wrapperProps"],"sources":["../../src/test-utils/testing-library.tsx"],"sourcesContent":["import React from 'react';\nimport { render, type RenderOptions } from '@testing-library/react';\n\n// Data Providers\nimport { TooltipProvider } from '@box/blueprint-web';\nimport { IntlProvider } from 'react-intl';\nimport { FeatureProvider } from '../elements/common/feature-checking';\n\njest.unmock('react-intl');\n\nconst Wrapper = ({ children, features = {} }) => (\n <FeatureProvider features={features}>\n <TooltipProvider>\n <IntlProvider locale=\"en\">{children}</IntlProvider>\n </TooltipProvider>\n </FeatureProvider>\n);\n\ntype RenderConnectedOptions = RenderOptions & {\n wrapperProps?: Record<string, unknown>;\n};\n\nconst renderConnected = (element, options: RenderConnectedOptions = {}) =>\n render(element, {\n wrapper: options.wrapper ? options.wrapper : props => <Wrapper {...props} {...options.wrapperProps} />,\n ...options,\n });\n\nexport * from '@testing-library/react';\nexport { renderConnected as render };\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,QAA4B,wBAAwB;;
|
|
1
|
+
{"version":3,"file":"testing-library.js","names":["React","render","userEventInit","TooltipProvider","IntlProvider","FeatureProvider","jest","unmock","Wrapper","children","features","createElement","locale","renderConnected","element","options","_objectSpread","wrapper","props","_extends","wrapperProps","createUserEvent","setup","userEvent"],"sources":["../../src/test-utils/testing-library.tsx"],"sourcesContent":["import React from 'react';\nimport { render, type RenderOptions } from '@testing-library/react';\nimport userEventInit from '@testing-library/user-event';\n\n// Data Providers\nimport { TooltipProvider } from '@box/blueprint-web';\nimport { IntlProvider } from 'react-intl';\nimport { FeatureProvider } from '../elements/common/feature-checking';\n\njest.unmock('react-intl');\n\nconst Wrapper = ({ children, features = {} }) => (\n <FeatureProvider features={features}>\n <TooltipProvider>\n <IntlProvider locale=\"en\">{children}</IntlProvider>\n </TooltipProvider>\n </FeatureProvider>\n);\n\ntype RenderConnectedOptions = RenderOptions & {\n wrapperProps?: Record<string, unknown>;\n};\n\nconst renderConnected = (element, options: RenderConnectedOptions = {}) =>\n render(element, {\n wrapper: options.wrapper ? options.wrapper : props => <Wrapper {...props} {...options.wrapperProps} />,\n ...options,\n });\n\nconst createUserEvent = () => userEventInit.setup(); // factory function to create isolated userEvent instances\n\nexport * from '@testing-library/react';\nexport { renderConnected as render, createUserEvent as userEvent };\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,QAA4B,wBAAwB;AACnE,OAAOC,aAAa,MAAM,6BAA6B;;AAEvD;AACA,SAASC,eAAe,QAAQ,oBAAoB;AACpD,SAASC,YAAY,QAAQ,YAAY;AACzC,SAASC,eAAe,QAAQ,qCAAqC;AAErEC,IAAI,CAACC,MAAM,CAAC,YAAY,CAAC;AAEzB,MAAMC,OAAO,GAAGA,CAAC;EAAEC,QAAQ;EAAEC,QAAQ,GAAG,CAAC;AAAE,CAAC,kBACxCV,KAAA,CAAAW,aAAA,CAACN,eAAe;EAACK,QAAQ,EAAEA;AAAS,gBAChCV,KAAA,CAAAW,aAAA,CAACR,eAAe,qBACZH,KAAA,CAAAW,aAAA,CAACP,YAAY;EAACQ,MAAM,EAAC;AAAI,GAAEH,QAAuB,CACrC,CACJ,CACpB;AAMD,MAAMI,eAAe,GAAGA,CAACC,OAAO,EAAEC,OAA+B,GAAG,CAAC,CAAC,KAClEd,MAAM,CAACa,OAAO,EAAAE,aAAA;EACVC,OAAO,EAAEF,OAAO,CAACE,OAAO,GAAGF,OAAO,CAACE,OAAO,GAAGC,KAAK,iBAAIlB,KAAA,CAAAW,aAAA,CAACH,OAAO,EAAAW,QAAA,KAAKD,KAAK,EAAMH,OAAO,CAACK,YAAY,CAAG;AAAC,GACnGL,OAAO,CACb,CAAC;AAEN,MAAMM,eAAe,GAAGA,CAAA,KAAMnB,aAAa,CAACoB,KAAK,CAAC,CAAC,CAAC,CAAC;;AAErD,cAAc,wBAAwB;AACtC,SAAST,eAAe,IAAIZ,MAAM,EAAEoB,eAAe,IAAIE,SAAS","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "box-ui-elements",
|
|
3
|
-
"version": "23.4.0-beta.
|
|
3
|
+
"version": "23.4.0-beta.18",
|
|
4
4
|
"description": "Box UI Elements",
|
|
5
5
|
"author": "Box (https://www.box.com/)",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
"@box/frontend": "^11.0.1",
|
|
138
138
|
"@box/item-icon": "^0.9.83",
|
|
139
139
|
"@box/languages": "^1.0.0",
|
|
140
|
-
"@box/metadata-editor": "^0.
|
|
140
|
+
"@box/metadata-editor": "^0.115.0",
|
|
141
141
|
"@box/react-virtualized": "9.22.3-rc-box.9",
|
|
142
142
|
"@cfaester/enzyme-adapter-react-18": "^0.8.0",
|
|
143
143
|
"@chromatic-com/storybook": "^1.6.1",
|
|
@@ -306,7 +306,7 @@
|
|
|
306
306
|
"@box/cldr-data": ">=34.2.0",
|
|
307
307
|
"@box/combobox-with-api": "^0.34.9",
|
|
308
308
|
"@box/item-icon": "^0.9.83",
|
|
309
|
-
"@box/metadata-editor": "^0.
|
|
309
|
+
"@box/metadata-editor": "^0.115.0",
|
|
310
310
|
"@box/react-virtualized": "9.22.3-rc-box.9",
|
|
311
311
|
"@hapi/address": "^2.1.4",
|
|
312
312
|
"axios": "^0.30.0",
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
9
|
import { FormattedMessage } from 'react-intl';
|
|
10
|
-
import { Route, type Location } from 'react-router-dom';
|
|
11
10
|
import IconNavigateLeft from '../../../icons/general/IconNavigateLeft';
|
|
12
11
|
import messages from '../messages';
|
|
13
12
|
import PlainButton from '../../../components/plain-button';
|
|
@@ -15,25 +14,16 @@ import './BackButton.scss';
|
|
|
15
14
|
|
|
16
15
|
type Props = {
|
|
17
16
|
className?: string,
|
|
18
|
-
|
|
17
|
+
onClick: () => void,
|
|
19
18
|
};
|
|
20
19
|
|
|
21
|
-
const BackButton = ({ className,
|
|
22
|
-
<
|
|
23
|
-
{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
{...rest}
|
|
29
|
-
>
|
|
30
|
-
<IconNavigateLeft height={24} width={24} />
|
|
31
|
-
<span className="accessibility-hidden">
|
|
32
|
-
<FormattedMessage {...messages.back} />
|
|
33
|
-
</span>
|
|
34
|
-
</PlainButton>
|
|
35
|
-
)}
|
|
36
|
-
</Route>
|
|
20
|
+
const BackButton = ({ className, onClick, ...rest }: Props) => (
|
|
21
|
+
<PlainButton className={classNames('bdl-BackButton', className)} onClick={onClick} type="button" {...rest}>
|
|
22
|
+
<IconNavigateLeft height={24} width={24} />
|
|
23
|
+
<span className="accessibility-hidden">
|
|
24
|
+
<FormattedMessage {...messages.back} />
|
|
25
|
+
</span>
|
|
26
|
+
</PlainButton>
|
|
37
27
|
);
|
|
38
28
|
|
|
39
29
|
export default BackButton;
|
|
@@ -1,43 +1,52 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { mount } from 'enzyme';
|
|
2
|
+
import { render, screen, userEvent } from '../../../../test-utils/testing-library';
|
|
4
3
|
import { BackButton } from '..';
|
|
5
4
|
|
|
6
5
|
describe('elements/common/nav-button/BackButton', () => {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
</MemoryRouter>,
|
|
12
|
-
);
|
|
13
|
-
const getHistory = wrapper => wrapper.find(Router).prop('history');
|
|
14
|
-
|
|
15
|
-
test('should match its snapshot', () => {
|
|
16
|
-
const wrapper = getWrapper();
|
|
17
|
-
const button = wrapper.find(BackButton).first();
|
|
18
|
-
|
|
19
|
-
expect(button).toMatchSnapshot();
|
|
6
|
+
const mockOnClick = jest.fn();
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
mockOnClick.mockClear();
|
|
20
10
|
});
|
|
21
11
|
|
|
22
|
-
test('should
|
|
23
|
-
|
|
24
|
-
const history = getHistory(wrapper);
|
|
12
|
+
test('should render back button with navigation icon and accessible text', () => {
|
|
13
|
+
render(<BackButton onClick={mockOnClick} />);
|
|
25
14
|
|
|
26
|
-
|
|
15
|
+
const button = screen.getByRole('button');
|
|
16
|
+
expect(button).toBeInTheDocument();
|
|
17
|
+
expect(button).toHaveClass('bdl-BackButton');
|
|
27
18
|
|
|
28
|
-
|
|
19
|
+
expect(screen.getByText('Back')).toBeInTheDocument();
|
|
29
20
|
|
|
30
|
-
|
|
21
|
+
const icon = button.querySelector('svg');
|
|
22
|
+
expect(icon).toBeInTheDocument();
|
|
23
|
+
expect(icon).toHaveClass('icon-navigate-left');
|
|
31
24
|
});
|
|
32
25
|
|
|
33
|
-
test('should call
|
|
34
|
-
const
|
|
35
|
-
|
|
26
|
+
test('should call onClick handler when clicked', async () => {
|
|
27
|
+
const user = userEvent();
|
|
28
|
+
|
|
29
|
+
render(<BackButton onClick={mockOnClick} />);
|
|
36
30
|
|
|
37
|
-
|
|
31
|
+
const button = screen.getByRole('button');
|
|
32
|
+
await user.click(button);
|
|
33
|
+
|
|
34
|
+
expect(mockOnClick).toHaveBeenCalledTimes(1);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('should pass through additional props', () => {
|
|
38
|
+
render(<BackButton onClick={mockOnClick} data-testid="test-back-button" data-resin-target="back" />);
|
|
39
|
+
|
|
40
|
+
const button = screen.getByTestId('test-back-button');
|
|
41
|
+
expect(button).toBeInTheDocument();
|
|
42
|
+
expect(button).toHaveAttribute('data-resin-target', 'back');
|
|
43
|
+
});
|
|
38
44
|
|
|
39
|
-
|
|
45
|
+
test('should apply custom className alongside default class', () => {
|
|
46
|
+
render(<BackButton onClick={mockOnClick} className="custom-class" />);
|
|
40
47
|
|
|
41
|
-
|
|
48
|
+
const button = screen.getByRole('button');
|
|
49
|
+
expect(button).toHaveClass('bdl-BackButton');
|
|
50
|
+
expect(button).toHaveClass('custom-class');
|
|
42
51
|
});
|
|
43
52
|
});
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
|
|
3
|
+
// flow version is simplified compared to Type Script due to difficult to resolve problems with Union Types
|
|
4
|
+
// Type Script works better with Union Types
|
|
5
|
+
|
|
3
6
|
export const ViewType = Object.freeze({
|
|
4
7
|
BOXAI: 'boxai',
|
|
5
8
|
SKILLS: 'skills',
|
|
@@ -18,30 +21,13 @@ export const FeedEntryType = Object.freeze({
|
|
|
18
21
|
export type ViewTypeValues = $Values<typeof ViewType>;
|
|
19
22
|
export type FeedEntryTypeValues = $Values<typeof FeedEntryType>;
|
|
20
23
|
|
|
21
|
-
type
|
|
22
|
-
sidebar:
|
|
23
|
-
versionId
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
sidebar: 'activity',
|
|
28
|
-
activeFeedEntryType: 'annotations',
|
|
29
|
-
fileVersionId: string,
|
|
30
|
-
activeFeedEntryId: string,
|
|
24
|
+
export type SidebarNavigation = {
|
|
25
|
+
sidebar: ViewTypeValues,
|
|
26
|
+
versionId?: string,
|
|
27
|
+
activeFeedEntryType?: FeedEntryTypeValues,
|
|
28
|
+
activeFeedEntryId?: string,
|
|
29
|
+
fileVersionId?: string,
|
|
31
30
|
};
|
|
32
|
-
type ActivityCommentsSidebarView = {
|
|
33
|
-
sidebar: 'activity',
|
|
34
|
-
activeFeedEntryType: 'comments' | 'tasks',
|
|
35
|
-
activeFeedEntryId: string,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export type SidebarNavigation =
|
|
39
|
-
| {|
|
|
40
|
-
sidebar: ViewTypeValues,
|
|
41
|
-
|}
|
|
42
|
-
| VersionSidebarView
|
|
43
|
-
| ActivityCommentsSidebarView
|
|
44
|
-
| ActivityAnnotationsSidebarView;
|
|
45
31
|
|
|
46
32
|
export type InternalSidebarNavigation = SidebarNavigation & {
|
|
47
33
|
open: boolean,
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import { FormattedMessage } from 'react-intl';
|
|
9
|
+
import { Route } from 'react-router-dom';
|
|
9
10
|
|
|
10
11
|
import BoxDrive140 from '../../../illustration/BoxDrive140';
|
|
11
12
|
|
|
@@ -45,51 +46,55 @@ const StaticVersionsSidebar = ({ isLoading, onUpgradeClick, parentName }: Props)
|
|
|
45
46
|
});
|
|
46
47
|
|
|
47
48
|
return (
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
<h3 className="bcs-StaticVersionSidebar-title">
|
|
56
|
-
<>
|
|
57
|
-
<BackButton data-resin-target="back" to={`/${parentName}`} />
|
|
58
|
-
<FormattedMessage {...messages.versionsTitle} />
|
|
59
|
-
</>
|
|
60
|
-
</h3>
|
|
61
|
-
</div>
|
|
62
|
-
|
|
63
|
-
<div className="bcs-StaticVersionSidebar-content-wrapper">
|
|
64
|
-
<LoadingIndicatorWrapper
|
|
65
|
-
className="bcs-StaticVersionSidebar-content"
|
|
66
|
-
crawlerPosition="top"
|
|
67
|
-
isLoading={isLoading}
|
|
49
|
+
<Route>
|
|
50
|
+
{({ history }) => (
|
|
51
|
+
<div
|
|
52
|
+
className="bcs-StaticVersionSidebar"
|
|
53
|
+
role="tabpanel"
|
|
54
|
+
data-resin-component="preview"
|
|
55
|
+
data-resin-feature="versions"
|
|
68
56
|
>
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
57
|
+
<div className="bcs-StaticVersionSidebar-header">
|
|
58
|
+
<h3 className="bcs-StaticVersionSidebar-title">
|
|
59
|
+
<>
|
|
60
|
+
<BackButton data-resin-target="back" onClick={() => history.push(`/${parentName}`)} />
|
|
61
|
+
<FormattedMessage {...messages.versionsTitle} />
|
|
62
|
+
</>
|
|
63
|
+
</h3>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<div className="bcs-StaticVersionSidebar-content-wrapper">
|
|
67
|
+
<LoadingIndicatorWrapper
|
|
68
|
+
className="bcs-StaticVersionSidebar-content"
|
|
69
|
+
crawlerPosition="top"
|
|
70
|
+
isLoading={isLoading}
|
|
71
|
+
>
|
|
72
|
+
<VersionsMenu versions={versions} fileId="1" versionCount={3} versionLimit={3} />
|
|
73
|
+
</LoadingIndicatorWrapper>
|
|
74
|
+
</div>
|
|
72
75
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
76
|
+
<div className="bcs-StaticVersionSidebar-upsell-wrapper">
|
|
77
|
+
<div className="bcs-StaticVersionSidebar-upsell">
|
|
78
|
+
<BoxDrive140 className="bcs-StaticVersionSidebar-upsell-icon" />
|
|
79
|
+
<p className="bcs-StaticVersionSidebar-upsell-header">
|
|
80
|
+
<FormattedMessage {...messages.versionUpgradeLink} />
|
|
81
|
+
</p>
|
|
82
|
+
<p>
|
|
83
|
+
<FormattedMessage {...messages.versionUpsell} />
|
|
84
|
+
</p>
|
|
85
|
+
<PrimaryButton
|
|
86
|
+
className="bcs-StaticVersionSidebar-upsell-button"
|
|
87
|
+
data-resin-target="versioning_error_upgrade_cta"
|
|
88
|
+
onClick={onUpgradeClick}
|
|
89
|
+
type="button"
|
|
90
|
+
>
|
|
91
|
+
<FormattedMessage {...messages.upgradeButton} />
|
|
92
|
+
</PrimaryButton>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
90
95
|
</div>
|
|
91
|
-
|
|
92
|
-
</
|
|
96
|
+
)}
|
|
97
|
+
</Route>
|
|
93
98
|
);
|
|
94
99
|
};
|
|
95
100
|
|
|
@@ -7,11 +7,14 @@
|
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import VersionsList from './VersionsList';
|
|
9
9
|
import type { BoxItemVersion } from '../../../common/types/core';
|
|
10
|
+
import type { InternalSidebarNavigation } from '../../common/types/SidebarNavigation';
|
|
10
11
|
import './VersionsGroup.scss';
|
|
11
12
|
|
|
12
13
|
type Props = {
|
|
13
14
|
fileId: string,
|
|
14
15
|
heading: string,
|
|
16
|
+
internalSidebarNavigation?: InternalSidebarNavigation,
|
|
17
|
+
routerDisabled?: boolean,
|
|
15
18
|
versionCount: number,
|
|
16
19
|
versionLimit: number,
|
|
17
20
|
versions: Array<BoxItemVersion>,
|
|
@@ -8,33 +8,51 @@ import * as React from 'react';
|
|
|
8
8
|
import { Route } from 'react-router-dom';
|
|
9
9
|
import VersionsItem from './VersionsItem';
|
|
10
10
|
import type { BoxItemVersion } from '../../../common/types/core';
|
|
11
|
+
import type { InternalSidebarNavigation } from '../../common/types/SidebarNavigation';
|
|
11
12
|
import './VersionsList.scss';
|
|
12
13
|
|
|
13
14
|
type Props = {
|
|
14
15
|
currentId?: string,
|
|
15
16
|
fileId: string,
|
|
17
|
+
internalSidebarNavigation?: InternalSidebarNavigation,
|
|
18
|
+
routerDisabled?: boolean,
|
|
16
19
|
versionCount: number,
|
|
17
20
|
versionLimit: number,
|
|
18
21
|
versions: Array<BoxItemVersion>,
|
|
19
22
|
};
|
|
20
23
|
|
|
21
|
-
const VersionsList = ({ currentId, versions, ...rest }: Props) =>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
const VersionsList = ({ currentId, internalSidebarNavigation, routerDisabled = false, versions, ...rest }: Props) => {
|
|
25
|
+
const renderVersionItemWithoutRouter = (version: BoxItemVersion) => (
|
|
26
|
+
<VersionsItem
|
|
27
|
+
isCurrent={currentId === version.id}
|
|
28
|
+
isSelected={internalSidebarNavigation?.versionId === version.id}
|
|
29
|
+
version={version}
|
|
30
|
+
{...rest}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const renderVersionItemWithRouter = (version: BoxItemVersion) => (
|
|
35
|
+
<Route
|
|
36
|
+
render={({ match }) => (
|
|
37
|
+
<VersionsItem
|
|
38
|
+
isCurrent={currentId === version.id}
|
|
39
|
+
isSelected={match.params.versionId === version.id}
|
|
40
|
+
version={version}
|
|
41
|
+
{...rest}
|
|
34
42
|
/>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
)}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<ul className="bcs-VersionsList">
|
|
49
|
+
{versions.map(version => (
|
|
50
|
+
<li className="bcs-VersionsList-item" key={version.id}>
|
|
51
|
+
{routerDisabled ? renderVersionItemWithoutRouter(version) : renderVersionItemWithRouter(version)}
|
|
52
|
+
</li>
|
|
53
|
+
))}
|
|
54
|
+
</ul>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
39
57
|
|
|
40
58
|
export default VersionsList;
|
|
@@ -11,11 +11,14 @@ import * as util from '../../../utils/datetime';
|
|
|
11
11
|
import messages from './messages';
|
|
12
12
|
import VersionsGroup from './VersionsGroup';
|
|
13
13
|
import type { BoxItemVersion } from '../../../common/types/core';
|
|
14
|
+
import type { InternalSidebarNavigation } from '../../common/types/SidebarNavigation';
|
|
14
15
|
import './VersionsMenu.scss';
|
|
15
16
|
|
|
16
17
|
type Props = {
|
|
17
18
|
fileId: string,
|
|
18
19
|
intl: any,
|
|
20
|
+
internalSidebarNavigation?: InternalSidebarNavigation,
|
|
21
|
+
routerDisabled?: boolean,
|
|
19
22
|
versionCount: number,
|
|
20
23
|
versionLimit: number,
|
|
21
24
|
versions: Array<BoxItemVersion>,
|