box-ui-elements 23.4.0-beta.22 → 23.4.0-beta.24
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/openwith.js +1 -1
- package/dist/picker.js +1 -1
- package/dist/preview.js +1 -1
- package/dist/sharing.js +1 -1
- package/dist/sidebar.js +1 -1
- package/dist/uploader.js +1 -1
- package/es/api/uploads/BaseUpload.js +4 -0
- package/es/api/uploads/BaseUpload.js.flow +5 -1
- package/es/api/uploads/BaseUpload.js.map +1 -1
- package/es/api/uploads/MultiputUpload.js +7 -0
- package/es/api/uploads/MultiputUpload.js.flow +11 -6
- package/es/api/uploads/MultiputUpload.js.map +1 -1
- package/es/api/uploads/PlainUpload.js +2 -1
- package/es/api/uploads/PlainUpload.js.flow +3 -2
- package/es/api/uploads/PlainUpload.js.map +1 -1
- package/es/components/flyout/OverlayHeader.js +6 -3
- package/es/components/flyout/OverlayHeader.js.map +1 -1
- package/es/elements/common/nav-router/NavRouter.js +7 -3
- package/es/elements/common/nav-router/NavRouter.js.flow +10 -1
- package/es/elements/common/nav-router/NavRouter.js.map +1 -1
- package/es/elements/common/nav-router/types.js.map +1 -1
- package/es/elements/common/nav-router/withNavRouter.js +10 -1
- package/es/elements/common/nav-router/withNavRouter.js.flow +5 -0
- package/es/elements/common/nav-router/withNavRouter.js.map +1 -1
- package/es/elements/common/routing/withRouterAndRef.js +17 -3
- package/es/elements/common/routing/withRouterAndRef.js.flow +11 -3
- package/es/elements/common/routing/withRouterAndRef.js.map +1 -1
- package/es/elements/content-explorer/stories/tests/ContentExplorer-visual.stories.js +22 -13
- package/es/elements/content-explorer/stories/tests/ContentExplorer-visual.stories.js.flow +30 -17
- package/es/elements/content-explorer/stories/tests/ContentExplorer-visual.stories.js.map +1 -1
- package/es/elements/content-sidebar/ContentSidebar.js +3 -1
- package/es/elements/content-sidebar/ContentSidebar.js.flow +2 -1
- package/es/elements/content-sidebar/ContentSidebar.js.map +1 -1
- package/es/elements/content-sidebar/SidebarToggle.js +27 -9
- package/es/elements/content-sidebar/SidebarToggle.js.flow +29 -6
- package/es/elements/content-sidebar/SidebarToggle.js.map +1 -1
- package/es/elements/content-sidebar/stories/tests/MetadataSidebarRedesign-visual.stories.js +12 -1
- package/es/elements/content-sidebar/stories/tests/MetadataSidebarRedesign-visual.stories.js.map +1 -1
- package/es/elements/content-uploader/ContentUploader.js +7 -3
- package/es/elements/content-uploader/ContentUploader.js.map +1 -1
- package/es/elements/content-uploader/ItemAction.js +8 -3
- package/es/elements/content-uploader/ItemAction.js.map +1 -1
- package/es/features/header-flyout/HeaderFlyout.js +6 -3
- package/es/features/header-flyout/HeaderFlyout.js.flow +15 -2
- package/es/features/header-flyout/HeaderFlyout.js.map +1 -1
- package/es/src/components/flyout/OverlayHeader.d.ts +3 -1
- package/es/src/elements/common/nav-router/NavRouter.d.ts +3 -1
- package/es/src/elements/common/nav-router/types.d.ts +2 -0
- package/es/src/elements/content-uploader/ContentUploader.d.ts +1 -1
- package/package.json +1 -1
- package/src/api/uploads/BaseUpload.js +5 -1
- package/src/api/uploads/MultiputUpload.js +11 -6
- package/src/api/uploads/PlainUpload.js +3 -2
- package/src/api/uploads/__tests__/BaseUpload.test.js +14 -0
- package/src/components/flyout/OverlayHeader.tsx +7 -3
- package/src/components/flyout/__tests__/OverlayHeader.test.js +25 -0
- package/src/elements/common/nav-router/NavRouter.js.flow +10 -1
- package/src/elements/common/nav-router/NavRouter.tsx +9 -3
- package/src/elements/common/nav-router/__tests__/withNavRouter.test.tsx +34 -20
- package/src/elements/common/nav-router/types.ts +2 -0
- package/src/elements/common/nav-router/withNavRouter.js.flow +5 -0
- package/src/elements/common/nav-router/withNavRouter.tsx +9 -1
- package/src/elements/common/routing/__tests__/withRouterAndRef.test.js +64 -12
- package/src/elements/common/routing/withRouterAndRef.js +11 -3
- package/src/elements/content-explorer/stories/tests/ContentExplorer-visual.stories.js +30 -17
- package/src/elements/content-sidebar/ContentSidebar.js +2 -1
- package/src/elements/content-sidebar/SidebarToggle.js +29 -6
- package/src/elements/content-sidebar/__tests__/SidebarToggle.test.js +74 -10
- package/src/elements/content-sidebar/stories/tests/MetadataSidebarRedesign-visual.stories.tsx +14 -1
- package/src/elements/content-uploader/ContentUploader.tsx +7 -3
- package/src/elements/content-uploader/ItemAction.tsx +8 -2
- package/src/features/header-flyout/HeaderFlyout.js +15 -2
- package/src/features/header-flyout/__tests__/__snapshots__/HeaderFlyout.test.js.snap +9 -3
- package/src/elements/content-sidebar/__tests__/__snapshots__/SidebarToggle.test.js.snap +0 -19
|
@@ -116,7 +116,7 @@ class PlainUpload extends BaseUpload {
|
|
|
116
116
|
* @param {Function} [options.errorCallback] - Function to call with errors
|
|
117
117
|
* @param {Function} [options.progressCallback] - Function to call with progress
|
|
118
118
|
* @param {Function} [options.conflictCallback] - Function to call on conflicting file names
|
|
119
|
-
* @param {boolean} [overwrite] - Should upload overwrite file with same name
|
|
119
|
+
* @param {boolean|'error'} [overwrite] - Should upload overwrite file with same name, throw error, or call conflictCallback to rename
|
|
120
120
|
* @return {void}
|
|
121
121
|
*/
|
|
122
122
|
upload({
|
|
@@ -128,6 +128,7 @@ class PlainUpload extends BaseUpload {
|
|
|
128
128
|
errorCallback = noop,
|
|
129
129
|
progressCallback = noop,
|
|
130
130
|
conflictCallback,
|
|
131
|
+
// $FlowFixMe
|
|
131
132
|
overwrite = true,
|
|
132
133
|
}: {
|
|
133
134
|
conflictCallback?: Function,
|
|
@@ -136,7 +137,7 @@ class PlainUpload extends BaseUpload {
|
|
|
136
137
|
fileDescription: ?string,
|
|
137
138
|
fileId: ?string,
|
|
138
139
|
folderId: string,
|
|
139
|
-
overwrite: boolean,
|
|
140
|
+
overwrite: boolean | 'error',
|
|
140
141
|
progressCallback: Function,
|
|
141
142
|
successCallback: Function,
|
|
142
143
|
}): void {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlainUpload.js","names":["noop","digest","getFileLastModifiedAsISONoMSIfPossible","BaseUpload","CONTENT_MD5_HEADER","PlainUpload","constructor","args","_defineProperty","data","entries","isDestroyed","successCallback","event","progressCallback","uploadUrl","upload_url","getBaseUploadUrl","fileId","replace","attributes","JSON","stringify","name","fileName","parent","id","folderId","description","fileDescription","content_modified_at","file","options","url","headers","successHandler","uploadSuccessHandler","errorHandler","preflightErrorHandler","progressHandler","uploadProgressHandler","sha1","computeSHA1","xhr","uploadFile","upload","errorCallback","conflictCallback","overwrite","makePreflightRequest","cancel","clearTimeout","retryTimeout","destroy","reader","window","FileReader","buffer","readFile","hashBuffer","hashArray","Array","from","Uint8Array","map","b","toString","slice","join","e"],"sources":["../../../src/api/uploads/PlainUpload.js"],"sourcesContent":["/**\n * @flow\n * @file Helper for the plain Box Upload API\n * @author Box\n */\n\nimport noop from 'lodash/noop';\nimport { digest } from '../../utils/webcrypto';\nimport { getFileLastModifiedAsISONoMSIfPossible } from '../../utils/uploads';\nimport BaseUpload from './BaseUpload';\nimport type { BoxItem } from '../../common/types/core';\n\nconst CONTENT_MD5_HEADER = 'Content-MD5';\n\nclass PlainUpload extends BaseUpload {\n successCallback: Function;\n\n progressCallback: Function;\n\n /**\n * Handles an upload success response\n *\n * @param {Object} data - Upload success data\n * @return {void}\n */\n uploadSuccessHandler = ({ data }: Object): void => {\n const { entries }: { entries: BoxItem[] } = data;\n if (this.isDestroyed()) {\n return;\n }\n\n if (typeof this.successCallback === 'function') {\n // Response entries are the successfully created Box File objects\n this.successCallback(entries);\n }\n };\n\n /**\n * Handles an upload progress event\n *\n * @param {Object} event - Progress event\n * @return {void}\n */\n uploadProgressHandler = (event: ProgressEvent): void => {\n if (this.isDestroyed()) {\n return;\n }\n\n if (typeof this.progressCallback === 'function') {\n this.progressCallback(event);\n }\n };\n\n /**\n * Uploads a file. If a file ID is supplied, use the Upload File\n * Version API to replace the file.\n *\n * @param {Object} - Request options\n * @param {boolean} [options.url] - Upload URL to use\n * @return {Promise} Async function promise\n */\n preflightSuccessHandler = async ({ data }: { data: { upload_url?: string } }): Promise<any> => {\n if (this.isDestroyed()) {\n return;\n }\n\n // Use provided upload URL if passed in, otherwise construct\n let uploadUrl = data.upload_url;\n if (!uploadUrl) {\n uploadUrl = `${this.getBaseUploadUrl()}/files/content`;\n\n if (this.fileId) {\n uploadUrl = uploadUrl.replace('content', `${this.fileId}/content`);\n }\n }\n\n const attributes = JSON.stringify({\n name: this.fileName,\n parent: { id: this.folderId },\n description: this.fileDescription,\n content_modified_at: getFileLastModifiedAsISONoMSIfPossible(this.file),\n });\n\n const options = {\n url: uploadUrl,\n data: {\n attributes,\n file: this.file,\n },\n headers: {},\n successHandler: this.uploadSuccessHandler,\n errorHandler: this.preflightErrorHandler,\n progressHandler: this.uploadProgressHandler,\n };\n\n // Calculate SHA1 for file consistency check\n const sha1 = await this.computeSHA1(this.file);\n if (sha1) {\n options.headers = {\n [CONTENT_MD5_HEADER]: sha1,\n };\n }\n\n this.xhr.uploadFile(options);\n };\n\n /**\n * Uploads a file. If there is a conflict and overwrite is true, replace the file.\n * Otherwise, re-upload with a different name.\n *\n * @param {Object} options - Upload options\n * @param {string} options.folderId - untyped folder id\n * @param {string} [options.fileId] - Untyped file id (e.g. no \"file_\" prefix)\n * @param {File} options.file - File blob object\n * @param {Function} [options.successCallback] - Function to call with response\n * @param {Function} [options.errorCallback] - Function to call with errors\n * @param {Function} [options.progressCallback] - Function to call with progress\n * @param {Function} [options.conflictCallback] - Function to call on conflicting file names\n * @param {boolean} [overwrite] - Should upload overwrite file with same name\n * @return {void}\n */\n upload({\n folderId,\n fileId,\n file,\n fileDescription,\n successCallback = noop,\n errorCallback = noop,\n progressCallback = noop,\n conflictCallback,\n overwrite = true,\n }: {\n conflictCallback?: Function,\n errorCallback: Function,\n file: File,\n fileDescription: ?string,\n fileId: ?string,\n folderId: string,\n overwrite: boolean,\n progressCallback: Function,\n successCallback: Function,\n }): void {\n if (this.isDestroyed()) {\n return;\n }\n\n // Save references\n this.folderId = folderId;\n this.fileId = fileId;\n this.file = file;\n this.fileDescription = fileDescription;\n this.fileName = this.file.name;\n this.successCallback = successCallback;\n this.errorCallback = errorCallback;\n this.progressCallback = progressCallback;\n this.overwrite = overwrite;\n this.conflictCallback = conflictCallback;\n\n this.makePreflightRequest();\n }\n\n /**\n * Cancels upload of a file.\n *\n * @return {void}\n */\n cancel() {\n if (this.isDestroyed()) {\n return;\n }\n\n clearTimeout(this.retryTimeout);\n this.destroy();\n }\n\n /**\n * Calculates SHA1 of a file\n *\n * @param {File} file\n * @return {Promise} Promise that resolves with SHA1 digest\n */\n async computeSHA1(file: File): Promise<any> {\n let sha1 = '';\n\n try {\n // Adapted from https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest\n const reader = new window.FileReader();\n const { buffer } = await this.readFile(reader, file);\n const hashBuffer: ArrayBuffer = await digest('SHA-1', buffer);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n sha1 = hashArray.map(b => `00${b.toString(16)}`.slice(-2)).join('');\n } catch (e) {\n // Return empty sha1 if hashing fails\n }\n\n return sha1;\n }\n}\n\nexport default PlainUpload;\n"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,IAAI,MAAM,aAAa;AAC9B,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,sCAAsC,QAAQ,qBAAqB;AAC5E,OAAOC,UAAU,MAAM,cAAc;AAGrC,MAAMC,kBAAkB,GAAG,aAAa;AAExC,MAAMC,WAAW,SAASF,UAAU,CAAC;EAAAG,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAKjC;AACJ;AACA;AACA;AACA;AACA;IALIC,eAAA,+BAMuB,CAAC;MAAEC;IAAa,CAAC,KAAW;MAC/C,MAAM;QAAEC;MAAgC,CAAC,GAAGD,IAAI;MAChD,IAAI,IAAI,CAACE,WAAW,CAAC,CAAC,EAAE;QACpB;MACJ;MAEA,IAAI,OAAO,IAAI,CAACC,eAAe,KAAK,UAAU,EAAE;QA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,EAAE;MACpB;IACJ;IAEAwC,YAAY,CAAC,IAAI,CAACC,YAAY,CAAC;IAC/B,IAAI,CAACC,OAAO,CAAC,CAAC;EAClB;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACI,MAAMX,WAAWA,CAACX,IAAU,EAAgB;IACxC,IAAIU,IAAI,GAAG,EAAE;IAEb,IAAI;MACA;MACA,MAAMa,MAAM,GAAG,IAAIC,MAAM,CAACC,UAAU,CAAC,CAAC;MACtC,MAAM;QAAEC;MAAO,CAAC,GAAG,MAAM,IAAI,CAACC,QAAQ,CAACJ,MAAM,EAAEvB,IAAI,CAAC;MACpD,MAAM4B,UAAuB,GAAG,MAAM1D,MAAM,CAAC,OAAO,EAAEwD,MAAM,CAAC;MAC7D,MAAMG,SAAS,GAAGC,KAAK,CAACC,IAAI,CAAC,IAAIC,UAAU,CAACJ,UAAU,CAAC,CAAC;MACxDlB,IAAI,GAAGmB,SAAS,CAACI,GAAG,CAACC,CAAC,IAAI,KAAKA,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,EAAE,CAAC;IACvE,CAAC,CAAC,OAAOC,CAAC,EAAE;MACR;IAAA;IAGJ,OAAO5B,IAAI;EACf;AACJ;AAEA,eAAepC,WAAW","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"PlainUpload.js","names":["noop","digest","getFileLastModifiedAsISONoMSIfPossible","BaseUpload","CONTENT_MD5_HEADER","PlainUpload","constructor","args","_defineProperty","data","entries","isDestroyed","successCallback","event","progressCallback","uploadUrl","upload_url","getBaseUploadUrl","fileId","replace","attributes","JSON","stringify","name","fileName","parent","id","folderId","description","fileDescription","content_modified_at","file","options","url","headers","successHandler","uploadSuccessHandler","errorHandler","preflightErrorHandler","progressHandler","uploadProgressHandler","sha1","computeSHA1","xhr","uploadFile","upload","errorCallback","conflictCallback","overwrite","makePreflightRequest","cancel","clearTimeout","retryTimeout","destroy","reader","window","FileReader","buffer","readFile","hashBuffer","hashArray","Array","from","Uint8Array","map","b","toString","slice","join","e"],"sources":["../../../src/api/uploads/PlainUpload.js"],"sourcesContent":["/**\n * @flow\n * @file Helper for the plain Box Upload API\n * @author Box\n */\n\nimport noop from 'lodash/noop';\nimport { digest } from '../../utils/webcrypto';\nimport { getFileLastModifiedAsISONoMSIfPossible } from '../../utils/uploads';\nimport BaseUpload from './BaseUpload';\nimport type { BoxItem } from '../../common/types/core';\n\nconst CONTENT_MD5_HEADER = 'Content-MD5';\n\nclass PlainUpload extends BaseUpload {\n successCallback: Function;\n\n progressCallback: Function;\n\n /**\n * Handles an upload success response\n *\n * @param {Object} data - Upload success data\n * @return {void}\n */\n uploadSuccessHandler = ({ data }: Object): void => {\n const { entries }: { entries: BoxItem[] } = data;\n if (this.isDestroyed()) {\n return;\n }\n\n if (typeof this.successCallback === 'function') {\n // Response entries are the successfully created Box File objects\n this.successCallback(entries);\n }\n };\n\n /**\n * Handles an upload progress event\n *\n * @param {Object} event - Progress event\n * @return {void}\n */\n uploadProgressHandler = (event: ProgressEvent): void => {\n if (this.isDestroyed()) {\n return;\n }\n\n if (typeof this.progressCallback === 'function') {\n this.progressCallback(event);\n }\n };\n\n /**\n * Uploads a file. If a file ID is supplied, use the Upload File\n * Version API to replace the file.\n *\n * @param {Object} - Request options\n * @param {boolean} [options.url] - Upload URL to use\n * @return {Promise} Async function promise\n */\n preflightSuccessHandler = async ({ data }: { data: { upload_url?: string } }): Promise<any> => {\n if (this.isDestroyed()) {\n return;\n }\n\n // Use provided upload URL if passed in, otherwise construct\n let uploadUrl = data.upload_url;\n if (!uploadUrl) {\n uploadUrl = `${this.getBaseUploadUrl()}/files/content`;\n\n if (this.fileId) {\n uploadUrl = uploadUrl.replace('content', `${this.fileId}/content`);\n }\n }\n\n const attributes = JSON.stringify({\n name: this.fileName,\n parent: { id: this.folderId },\n description: this.fileDescription,\n content_modified_at: getFileLastModifiedAsISONoMSIfPossible(this.file),\n });\n\n const options = {\n url: uploadUrl,\n data: {\n attributes,\n file: this.file,\n },\n headers: {},\n successHandler: this.uploadSuccessHandler,\n errorHandler: this.preflightErrorHandler,\n progressHandler: this.uploadProgressHandler,\n };\n\n // Calculate SHA1 for file consistency check\n const sha1 = await this.computeSHA1(this.file);\n if (sha1) {\n options.headers = {\n [CONTENT_MD5_HEADER]: sha1,\n };\n }\n\n this.xhr.uploadFile(options);\n };\n\n /**\n * Uploads a file. If there is a conflict and overwrite is true, replace the file.\n * Otherwise, re-upload with a different name.\n *\n * @param {Object} options - Upload options\n * @param {string} options.folderId - untyped folder id\n * @param {string} [options.fileId] - Untyped file id (e.g. no \"file_\" prefix)\n * @param {File} options.file - File blob object\n * @param {Function} [options.successCallback] - Function to call with response\n * @param {Function} [options.errorCallback] - Function to call with errors\n * @param {Function} [options.progressCallback] - Function to call with progress\n * @param {Function} [options.conflictCallback] - Function to call on conflicting file names\n * @param {boolean|'error'} [overwrite] - Should upload overwrite file with same name, throw error, or call conflictCallback to rename\n * @return {void}\n */\n upload({\n folderId,\n fileId,\n file,\n fileDescription,\n successCallback = noop,\n errorCallback = noop,\n progressCallback = noop,\n conflictCallback,\n // $FlowFixMe\n overwrite = true,\n }: {\n conflictCallback?: Function,\n errorCallback: Function,\n file: File,\n fileDescription: ?string,\n fileId: ?string,\n folderId: string,\n overwrite: boolean | 'error',\n progressCallback: Function,\n successCallback: Function,\n }): void {\n if (this.isDestroyed()) {\n return;\n }\n\n // Save references\n this.folderId = folderId;\n this.fileId = fileId;\n this.file = file;\n this.fileDescription = fileDescription;\n this.fileName = this.file.name;\n this.successCallback = successCallback;\n this.errorCallback = errorCallback;\n this.progressCallback = progressCallback;\n this.overwrite = overwrite;\n this.conflictCallback = conflictCallback;\n\n this.makePreflightRequest();\n }\n\n /**\n * Cancels upload of a file.\n *\n * @return {void}\n */\n cancel() {\n if (this.isDestroyed()) {\n return;\n }\n\n clearTimeout(this.retryTimeout);\n this.destroy();\n }\n\n /**\n * Calculates SHA1 of a file\n *\n * @param {File} file\n * @return {Promise} Promise that resolves with SHA1 digest\n */\n async computeSHA1(file: File): Promise<any> {\n let sha1 = '';\n\n try {\n // Adapted from https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest\n const reader = new window.FileReader();\n const { buffer } = await this.readFile(reader, file);\n const hashBuffer: ArrayBuffer = await digest('SHA-1', buffer);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n sha1 = hashArray.map(b => `00${b.toString(16)}`.slice(-2)).join('');\n } catch (e) {\n // Return empty sha1 if hashing fails\n }\n\n return sha1;\n }\n}\n\nexport default PlainUpload;\n"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,IAAI,MAAM,aAAa;AAC9B,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,sCAAsC,QAAQ,qBAAqB;AAC5E,OAAOC,UAAU,MAAM,cAAc;AAGrC,MAAMC,kBAAkB,GAAG,aAAa;AAExC,MAAMC,WAAW,SAASF,UAAU,CAAC;EAAAG,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAKjC;AACJ;AACA;AACA;AACA;AACA;IALIC,eAAA,+BAMuB,CAAC;MAAEC;IAAa,CAAC,KAAW;MAC/C,MAAM;QAAEC;MAAgC,CAAC,GAAGD,IAAI;MAChD,IAAI,IAAI,CAACE,WAAW,CAAC,CAAC,EAAE;QACpB;MACJ;MAEA,IAAI,OAAO,IAAI,CAACC,eAAe,KAAK,UAAU,EAAE;QAC5C;QACA,IAAI,CAACA,eAAe,CAACF,OAAO,CAAC;MACjC;IACJ,CAAC;IAED;AACJ;AACA;AACA;AACA;AACA;IALIF,eAAA,gCAMyBK,KAAoB,IAAW;MACpD,IAAI,IAAI,CAACF,WAAW,CAAC,CAAC,EAAE;QACpB;MACJ;MAEA,IAAI,OAAO,IAAI,CAACG,gBAAgB,KAAK,UAAU,EAAE;QAC7C,IAAI,CAACA,gBAAgB,CAACD,KAAK,CAAC;MAChC;IAC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AAM;QAAEC;MAAO,CAAC,GAAG,MAAM,IAAI,CAACC,QAAQ,CAACJ,MAAM,EAAEvB,IAAI,CAAC;MACpD,MAAM4B,UAAuB,GAAG,MAAM1D,MAAM,CAAC,OAAO,EAAEwD,MAAM,CAAC;MAC7D,MAAMG,SAAS,GAAGC,KAAK,CAACC,IAAI,CAAC,IAAIC,UAAU,CAACJ,UAAU,CAAC,CAAC;MACxDlB,IAAI,GAAGmB,SAAS,CAACI,GAAG,CAACC,CAAC,IAAI,KAAKA,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,EAAE,CAAC;IACvE,CAAC,CAAC,OAAOC,CAAC,EAAE;MACR;IAAA;IAGJ,OAAO5B,IAAI;EACf;AACJ;AAEA,eAAepC,WAAW","ignoreList":[]}
|
|
@@ -6,11 +6,14 @@ import FlyoutContext from './FlyoutContext';
|
|
|
6
6
|
import './OverlayHeader.scss';
|
|
7
7
|
const OverlayHeader = ({
|
|
8
8
|
children,
|
|
9
|
-
className
|
|
9
|
+
className,
|
|
10
|
+
isOverlayHeaderActionEnabled = false
|
|
10
11
|
}) => {
|
|
11
12
|
const handleClick = event => {
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
if (!isOverlayHeaderActionEnabled) {
|
|
14
|
+
event.preventDefault();
|
|
15
|
+
event.stopPropagation();
|
|
16
|
+
}
|
|
14
17
|
};
|
|
15
18
|
// @ts-ignore TODO: figure out why this is giving a TS error
|
|
16
19
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OverlayHeader.js","names":["React","classNames","CloseButton","FlyoutContext","OverlayHeader","children","className","handleClick","event","preventDefault","stopPropagation","closeOverlay","useContext","createElement","onClick","role"],"sources":["../../../src/components/flyout/OverlayHeader.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport classNames from 'classnames';\nimport CloseButton from '../close-button/CloseButton';\n// @ts-ignore flow\nimport FlyoutContext from './FlyoutContext';\n\nimport './OverlayHeader.scss';\n\nexport interface OverlayHeaderProps {\n /** Components to render in the header */\n children?: React.ReactNode;\n /** Set className to the overlay header */\n className?: string;\n}\n\nconst OverlayHeader = ({ children, className }: OverlayHeaderProps) => {\n const handleClick = (event: React.SyntheticEvent<HTMLDivElement>): void => {\n event.preventDefault();\n
|
|
1
|
+
{"version":3,"file":"OverlayHeader.js","names":["React","classNames","CloseButton","FlyoutContext","OverlayHeader","children","className","isOverlayHeaderActionEnabled","handleClick","event","preventDefault","stopPropagation","closeOverlay","useContext","createElement","onClick","role"],"sources":["../../../src/components/flyout/OverlayHeader.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport classNames from 'classnames';\nimport CloseButton from '../close-button/CloseButton';\n// @ts-ignore flow\nimport FlyoutContext from './FlyoutContext';\n\nimport './OverlayHeader.scss';\n\nexport interface OverlayHeaderProps {\n /** Components to render in the header */\n children?: React.ReactNode;\n /** Set className to the overlay header */\n className?: string;\n /** Are OverlayHeader actions enabled */\n isOverlayHeaderActionEnabled?: boolean;\n}\n\nconst OverlayHeader = ({ children, className, isOverlayHeaderActionEnabled = false }: OverlayHeaderProps) => {\n const handleClick = (event: React.SyntheticEvent<HTMLDivElement>): void => {\n if (!isOverlayHeaderActionEnabled) {\n event.preventDefault();\n event.stopPropagation();\n }\n };\n // @ts-ignore TODO: figure out why this is giving a TS error\n const { closeOverlay } = React.useContext(FlyoutContext);\n\n return (\n <div\n className={classNames('bdl-OverlayHeader', className)}\n data-testid=\"bdl-OverlayHeader\"\n onClick={handleClick}\n role=\"presentation\"\n >\n <div className=\"bdl-OverlayHeader-content\">{children}</div>\n <CloseButton onClick={closeOverlay} />\n </div>\n );\n};\n\nexport default OverlayHeader;\n"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,WAAW,MAAM,6BAA6B;AACrD;AACA,OAAOC,aAAa,MAAM,iBAAiB;AAE3C,OAAO,sBAAsB;AAW7B,MAAMC,aAAa,GAAGA,CAAC;EAAEC,QAAQ;EAAEC,SAAS;EAAEC,4BAA4B,GAAG;AAA0B,CAAC,KAAK;EACzG,MAAMC,WAAW,GAAIC,KAA2C,IAAW;IACvE,IAAI,CAACF,4BAA4B,EAAE;MAC/BE,KAAK,CAACC,cAAc,CAAC,CAAC;MACtBD,KAAK,CAACE,eAAe,CAAC,CAAC;IAC3B;EACJ,CAAC;EACD;EACA,MAAM;IAAEC;EAAa,CAAC,GAAGZ,KAAK,CAACa,UAAU,CAACV,aAAa,CAAC;EAExD,oBACIH,KAAA,CAAAc,aAAA;IACIR,SAAS,EAAEL,UAAU,CAAC,mBAAmB,EAAEK,SAAS,CAAE;IACtD,eAAY,mBAAmB;IAC/BS,OAAO,EAAEP,WAAY;IACrBQ,IAAI,EAAC;EAAc,gBAEnBhB,KAAA,CAAAc,aAAA;IAAKR,SAAS,EAAC;EAA2B,GAAED,QAAc,CAAC,eAC3DL,KAAA,CAAAc,aAAA,CAACZ,WAAW;IAACa,OAAO,EAAEH;EAAa,CAAE,CACpC,CAAC;AAEd,CAAC;AAED,eAAeR,aAAa","ignoreList":[]}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
const _excluded = ["children", "history"];
|
|
1
|
+
const _excluded = ["children", "features", "history"];
|
|
2
2
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
3
3
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { MemoryRouter, Router } from 'react-router';
|
|
6
|
+
import { isFeatureEnabled } from '../feature-checking';
|
|
6
7
|
const NavRouter = _ref => {
|
|
7
8
|
let {
|
|
8
9
|
children,
|
|
10
|
+
features,
|
|
9
11
|
history
|
|
10
12
|
} = _ref,
|
|
11
13
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
14
|
+
const isRouterDisabled = isFeatureEnabled(features, 'routerDisabled.value');
|
|
15
|
+
if (isRouterDisabled) {
|
|
16
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
17
|
+
}
|
|
12
18
|
if (history) {
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
14
|
-
// @ts-ignore
|
|
15
19
|
return /*#__PURE__*/React.createElement(Router, {
|
|
16
20
|
history: history
|
|
17
21
|
}, children);
|
|
@@ -6,13 +6,22 @@
|
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { MemoryRouter, Router } from 'react-router-dom';
|
|
8
8
|
import type { RouterHistory } from 'react-router-dom';
|
|
9
|
+
import { isFeatureEnabled, type FeatureConfig } from '../feature-checking';
|
|
9
10
|
|
|
10
11
|
type Props = {
|
|
11
12
|
children: React.Node,
|
|
13
|
+
features?: FeatureConfig,
|
|
12
14
|
history?: RouterHistory,
|
|
15
|
+
initialEntries?: Array<any>,
|
|
13
16
|
};
|
|
14
17
|
|
|
15
|
-
const NavRouter = ({ children, history, ...rest }: Props) => {
|
|
18
|
+
const NavRouter = ({ children, features, history, ...rest }: Props) => {
|
|
19
|
+
const isRouterDisabled = isFeatureEnabled(features, 'routerDisabled.value');
|
|
20
|
+
|
|
21
|
+
if (isRouterDisabled) {
|
|
22
|
+
return <>{children}</>;
|
|
23
|
+
}
|
|
24
|
+
|
|
16
25
|
if (history) {
|
|
17
26
|
return <Router history={history}>{children}</Router>;
|
|
18
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavRouter.js","names":["React","MemoryRouter","Router","NavRouter","_ref","children","history","rest","_objectWithoutProperties","_excluded","createElement"],"sources":["../../../../src/elements/common/nav-router/NavRouter.tsx"],"sourcesContent":["import * as React from 'react';\nimport { MemoryRouter, Router } from 'react-router';\nimport { History } from 'history';\n\ntype Props = {\n children: React.ReactNode;\n history?: History;\n initialEntries?: History.LocationDescriptor[];\n};\n\nconst NavRouter = ({ children, history, ...rest }: Props) => {\n if (
|
|
1
|
+
{"version":3,"file":"NavRouter.js","names":["React","MemoryRouter","Router","isFeatureEnabled","NavRouter","_ref","children","features","history","rest","_objectWithoutProperties","_excluded","isRouterDisabled","createElement","Fragment"],"sources":["../../../../src/elements/common/nav-router/NavRouter.tsx"],"sourcesContent":["import * as React from 'react';\nimport { MemoryRouter, Router } from 'react-router';\nimport { History } from 'history';\nimport { isFeatureEnabled, type FeatureConfig } from '../feature-checking';\n\ntype Props = {\n children: React.ReactNode;\n features?: FeatureConfig;\n history?: History;\n initialEntries?: History.LocationDescriptor[];\n};\n\nconst NavRouter = ({ children, features, history, ...rest }: Props) => {\n const isRouterDisabled = isFeatureEnabled(features, 'routerDisabled.value');\n \n if (isRouterDisabled) {\n return <>{children}</>;\n }\n\n if (history) {\n return <Router history={history}>{children}</Router>;\n }\n\n return <MemoryRouter {...rest}>{children}</MemoryRouter>;\n};\n\nexport default NavRouter;\n"],"mappings":";;;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,YAAY,EAAEC,MAAM,QAAQ,cAAc;AAEnD,SAASC,gBAAgB,QAA4B,qBAAqB;AAS1E,MAAMC,SAAS,GAAGC,IAAA,IAAqD;EAAA,IAApD;MAAEC,QAAQ;MAAEC,QAAQ;MAAEC;IAAwB,CAAC,GAAAH,IAAA;IAAbI,IAAI,GAAAC,wBAAA,CAAAL,IAAA,EAAAM,SAAA;EACrD,MAAMC,gBAAgB,GAAGT,gBAAgB,CAACI,QAAQ,EAAE,sBAAsB,CAAC;EAE3E,IAAIK,gBAAgB,EAAE;IAClB,oBAAOZ,KAAA,CAAAa,aAAA,CAAAb,KAAA,CAAAc,QAAA,QAAGR,QAAW,CAAC;EAC1B;EAEA,IAAIE,OAAO,EAAE;IACT,oBAAOR,KAAA,CAAAa,aAAA,CAACX,MAAM;MAACM,OAAO,EAAEA;IAAQ,GAAEF,QAAiB,CAAC;EACxD;EAEA,oBAAON,KAAA,CAAAa,aAAA,CAACZ,YAAY,EAAKQ,IAAI,EAAGH,QAAuB,CAAC;AAC5D,CAAC;AAED,eAAeF,SAAS","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/elements/common/nav-router/types.ts"],"sourcesContent":["import { History } from 'history';\n\nexport type WithNavRouterProps = {\n history?: History;\n initialEntries?: History.LocationDescriptor[];\n};\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/elements/common/nav-router/types.ts"],"sourcesContent":["import { History } from 'history';\nimport { FeatureConfig } from '../feature-checking';\n\nexport type WithNavRouterProps = {\n features?: FeatureConfig;\n history?: History;\n initialEntries?: History.LocationDescriptor[];\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -3,6 +3,7 @@ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i
|
|
|
3
3
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import NavRouter from './NavRouter';
|
|
6
|
+
import { isFeatureEnabled } from '../feature-checking';
|
|
6
7
|
const withNavRouter = Component => {
|
|
7
8
|
function WithNavRouter(_ref) {
|
|
8
9
|
let {
|
|
@@ -10,9 +11,17 @@ const withNavRouter = Component => {
|
|
|
10
11
|
initialEntries
|
|
11
12
|
} = _ref,
|
|
12
13
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
14
|
+
const {
|
|
15
|
+
features
|
|
16
|
+
} = rest;
|
|
17
|
+
const isRouterDisabled = isFeatureEnabled(features, 'routerDisabled.value');
|
|
18
|
+
if (isRouterDisabled) {
|
|
19
|
+
return /*#__PURE__*/React.createElement(Component, rest);
|
|
20
|
+
}
|
|
13
21
|
return /*#__PURE__*/React.createElement(NavRouter, {
|
|
14
22
|
history: history,
|
|
15
|
-
initialEntries: initialEntries
|
|
23
|
+
initialEntries: initialEntries,
|
|
24
|
+
features: features
|
|
16
25
|
}, /*#__PURE__*/React.createElement(Component, rest));
|
|
17
26
|
}
|
|
18
27
|
WithNavRouter.displayName = `withNavRouter(${Component.displayName || Component.name || 'Component'}`;
|
|
@@ -6,9 +6,14 @@
|
|
|
6
6
|
|
|
7
7
|
import React from "react";
|
|
8
8
|
import { History } from "history";
|
|
9
|
+
import { type FeatureConfig } from '../feature-checking';
|
|
9
10
|
import NavRouter from "./NavRouter";
|
|
11
|
+
|
|
10
12
|
export type WithNavRouterProps = {
|
|
13
|
+
features?: FeatureConfig,
|
|
11
14
|
history?: History,
|
|
15
|
+
initialEntries?: Array<any>,
|
|
12
16
|
...
|
|
13
17
|
};
|
|
18
|
+
|
|
14
19
|
declare export var withNavRouter: any; // /* NO PRINT IMPLEMENTED: ArrowFunction */ any
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withNavRouter.js","names":["React","NavRouter","withNavRouter","Component","WithNavRouter","_ref","history","initialEntries","rest","_objectWithoutProperties","_excluded","createElement","displayName","name"],"sources":["../../../../src/elements/common/nav-router/withNavRouter.tsx"],"sourcesContent":["import * as React from 'react';\nimport NavRouter from './NavRouter';\nimport { WithNavRouterProps } from './types';\n\nconst withNavRouter = <P extends object>(Component: React.ComponentType<P>): React.FC<P & WithNavRouterProps> => {\n function WithNavRouter({ history, initialEntries, ...rest }: P & WithNavRouterProps) {\n return (\n <NavRouter history={history} initialEntries={initialEntries}>\n <Component {...(rest as P)} />\n </NavRouter>\n );\n }\n\n WithNavRouter.displayName = `withNavRouter(${Component.displayName || Component.name || 'Component'}`;\n\n return WithNavRouter;\n};\n\nexport default withNavRouter;\n"],"mappings":";;;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,OAAOC,SAAS,MAAM,aAAa;
|
|
1
|
+
{"version":3,"file":"withNavRouter.js","names":["React","NavRouter","isFeatureEnabled","withNavRouter","Component","WithNavRouter","_ref","history","initialEntries","rest","_objectWithoutProperties","_excluded","features","isRouterDisabled","createElement","displayName","name"],"sources":["../../../../src/elements/common/nav-router/withNavRouter.tsx"],"sourcesContent":["import * as React from 'react';\nimport NavRouter from './NavRouter';\nimport { WithNavRouterProps } from './types';\nimport { isFeatureEnabled } from '../feature-checking';\n\nconst withNavRouter = <P extends object>(Component: React.ComponentType<P>): React.FC<P & WithNavRouterProps> => {\n function WithNavRouter({ history, initialEntries, ...rest }: P & WithNavRouterProps) {\n const { features } = rest;\n const isRouterDisabled = isFeatureEnabled(features, 'routerDisabled.value');\n \n if (isRouterDisabled) {\n return <Component {...(rest as P)} />;\n }\n\n return (\n <NavRouter history={history} initialEntries={initialEntries} features={features}>\n <Component {...(rest as P)} />\n </NavRouter>\n );\n }\n\n WithNavRouter.displayName = `withNavRouter(${Component.displayName || Component.name || 'Component'}`;\n\n return WithNavRouter;\n};\n\nexport default withNavRouter;\n"],"mappings":";;;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,OAAOC,SAAS,MAAM,aAAa;AAEnC,SAASC,gBAAgB,QAAQ,qBAAqB;AAEtD,MAAMC,aAAa,GAAsBC,SAAiC,IAAuC;EAC7G,SAASC,aAAaA,CAAAC,IAAA,EAA+D;IAAA,IAA9D;QAAEC,OAAO;QAAEC;MAAgD,CAAC,GAAAF,IAAA;MAA9BG,IAAI,GAAAC,wBAAA,CAAAJ,IAAA,EAAAK,SAAA;IACrD,MAAM;MAAEC;IAAS,CAAC,GAAGH,IAAI;IACzB,MAAMI,gBAAgB,GAAGX,gBAAgB,CAACU,QAAQ,EAAE,sBAAsB,CAAC;IAE3E,IAAIC,gBAAgB,EAAE;MAClB,oBAAOb,KAAA,CAAAc,aAAA,CAACV,SAAS,EAAMK,IAAa,CAAC;IACzC;IAEA,oBACIT,KAAA,CAAAc,aAAA,CAACb,SAAS;MAACM,OAAO,EAAEA,OAAQ;MAACC,cAAc,EAAEA,cAAe;MAACI,QAAQ,EAAEA;IAAS,gBAC5EZ,KAAA,CAAAc,aAAA,CAACV,SAAS,EAAMK,IAAa,CACtB,CAAC;EAEpB;EAEAJ,aAAa,CAACU,WAAW,GAAG,iBAAiBX,SAAS,CAACW,WAAW,IAAIX,SAAS,CAACY,IAAI,IAAI,WAAW,EAAE;EAErG,OAAOX,aAAa;AACxB,CAAC;AAED,eAAeF,aAAa","ignoreList":[]}
|
|
@@ -5,9 +5,23 @@ import { Route } from 'react-router-dom';
|
|
|
5
5
|
// Basically a workaround for the fact that react-router's withRouter cannot forward ref's through
|
|
6
6
|
// functional components. Use this instead to gain the benefits of withRouter but also ref forwarding
|
|
7
7
|
export default function withRouterAndRef(Wrapped) {
|
|
8
|
-
const WithRouterAndRef = /*#__PURE__*/React.forwardRef((props, ref) =>
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const WithRouterAndRef = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
9
|
+
const {
|
|
10
|
+
routerDisabled
|
|
11
|
+
} = props;
|
|
12
|
+
|
|
13
|
+
// If router is disabled, return component directly without Route wrapper
|
|
14
|
+
if (routerDisabled) {
|
|
15
|
+
return /*#__PURE__*/React.createElement(Wrapped, _extends({
|
|
16
|
+
ref: ref
|
|
17
|
+
}, props));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Default behavior: wrap with Route to get router props
|
|
21
|
+
return /*#__PURE__*/React.createElement(Route, null, routeProps => /*#__PURE__*/React.createElement(Wrapped, _extends({
|
|
22
|
+
ref: ref
|
|
23
|
+
}, routeProps, props)));
|
|
24
|
+
});
|
|
11
25
|
const name = Wrapped.displayName || Wrapped.name || 'Component';
|
|
12
26
|
WithRouterAndRef.displayName = `withRouterAndRef(${name})`;
|
|
13
27
|
return WithRouterAndRef;
|
|
@@ -5,9 +5,17 @@ import { Route } from 'react-router-dom';
|
|
|
5
5
|
// Basically a workaround for the fact that react-router's withRouter cannot forward ref's through
|
|
6
6
|
// functional components. Use this instead to gain the benefits of withRouter but also ref forwarding
|
|
7
7
|
export default function withRouterAndRef(Wrapped: React.ComponentType<any>) {
|
|
8
|
-
const WithRouterAndRef = React.forwardRef<Object, React.Ref<any>>((props, ref) =>
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const WithRouterAndRef = React.forwardRef<Object, React.Ref<any>>((props, ref) => {
|
|
9
|
+
const { routerDisabled } = props;
|
|
10
|
+
|
|
11
|
+
// If router is disabled, return component directly without Route wrapper
|
|
12
|
+
if (routerDisabled) {
|
|
13
|
+
return <Wrapped ref={ref} {...props} />;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Default behavior: wrap with Route to get router props
|
|
17
|
+
return <Route>{routeProps => <Wrapped ref={ref} {...routeProps} {...props} />}</Route>;
|
|
18
|
+
});
|
|
11
19
|
const name = Wrapped.displayName || Wrapped.name || 'Component';
|
|
12
20
|
WithRouterAndRef.displayName = `withRouterAndRef(${name})`;
|
|
13
21
|
return WithRouterAndRef;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withRouterAndRef.js","names":["React","Route","withRouterAndRef","Wrapped","WithRouterAndRef","forwardRef","props","ref","
|
|
1
|
+
{"version":3,"file":"withRouterAndRef.js","names":["React","Route","withRouterAndRef","Wrapped","WithRouterAndRef","forwardRef","props","ref","routerDisabled","createElement","_extends","routeProps","name","displayName"],"sources":["../../../../src/elements/common/routing/withRouterAndRef.js"],"sourcesContent":["// @flow\nimport * as React from 'react';\nimport { Route } from 'react-router-dom';\n\n// Basically a workaround for the fact that react-router's withRouter cannot forward ref's through\n// functional components. Use this instead to gain the benefits of withRouter but also ref forwarding\nexport default function withRouterAndRef(Wrapped: React.ComponentType<any>) {\n const WithRouterAndRef = React.forwardRef<Object, React.Ref<any>>((props, ref) => {\n const { routerDisabled } = props;\n \n // If router is disabled, return component directly without Route wrapper\n if (routerDisabled) {\n return <Wrapped ref={ref} {...props} />;\n }\n \n // Default behavior: wrap with Route to get router props\n return <Route>{routeProps => <Wrapped ref={ref} {...routeProps} {...props} />}</Route>;\n });\n const name = Wrapped.displayName || Wrapped.name || 'Component';\n WithRouterAndRef.displayName = `withRouterAndRef(${name})`;\n return WithRouterAndRef;\n}\n"],"mappings":";AACA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,KAAK,QAAQ,kBAAkB;;AAExC;AACA;AACA,eAAe,SAASC,gBAAgBA,CAACC,OAAiC,EAAE;EACxE,MAAMC,gBAAgB,gBAAGJ,KAAK,CAACK,UAAU,CAAyB,CAACC,KAAK,EAAEC,GAAG,KAAK;IAC9E,MAAM;MAAEC;IAAe,CAAC,GAAGF,KAAK;;IAEhC;IACA,IAAIE,cAAc,EAAE;MAChB,oBAAOR,KAAA,CAAAS,aAAA,CAACN,OAAO,EAAAO,QAAA;QAACH,GAAG,EAAEA;MAAI,GAAKD,KAAK,CAAG,CAAC;IAC3C;;IAEA;IACA,oBAAON,KAAA,CAAAS,aAAA,CAACR,KAAK,QAAEU,UAAU,iBAAIX,KAAA,CAAAS,aAAA,CAACN,OAAO,EAAAO,QAAA;MAACH,GAAG,EAAEA;IAAI,GAAKI,UAAU,EAAML,KAAK,CAAG,CAAS,CAAC;EAC1F,CAAC,CAAC;EACF,MAAMM,IAAI,GAAGT,OAAO,CAACU,WAAW,IAAIV,OAAO,CAACS,IAAI,IAAI,WAAW;EAC/DR,gBAAgB,CAACS,WAAW,GAAG,oBAAoBD,IAAI,GAAG;EAC1D,OAAOR,gBAAgB;AAC3B","ignoreList":[]}
|
|
@@ -4,6 +4,7 @@ import ContentExplorer from '../../ContentExplorer';
|
|
|
4
4
|
import { mockEmptyRootFolder, mockRootFolder } from '../../../common/__mocks__/mockRootFolder';
|
|
5
5
|
import mockSubfolder from '../../../common/__mocks__/mockSubfolder';
|
|
6
6
|
import mockRecentItems from '../../../common/__mocks__/mockRecentItems';
|
|
7
|
+
import { mockUserRequest } from '../../../common/__mocks__/mockRequests';
|
|
7
8
|
import { DEFAULT_HOSTNAME_API } from '../../../../constants';
|
|
8
9
|
export const basic = {
|
|
9
10
|
play: async ({
|
|
@@ -224,10 +225,30 @@ export const closeCreateFolderDialog = {
|
|
|
224
225
|
// },
|
|
225
226
|
// };
|
|
226
227
|
|
|
228
|
+
const defaultHandlers = [http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/69083462919`, () => {
|
|
229
|
+
return HttpResponse.json(mockRootFolder);
|
|
230
|
+
}), http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/73426618530`, () => {
|
|
231
|
+
return HttpResponse.json(mockSubfolder);
|
|
232
|
+
}), http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/74729718131`, () => {
|
|
233
|
+
return HttpResponse.json(mockEmptyRootFolder);
|
|
234
|
+
}), http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/191354690948`, () => {
|
|
235
|
+
return new HttpResponse('Internal Server Error', {
|
|
236
|
+
status: 500
|
|
237
|
+
});
|
|
238
|
+
}), http.get(`${DEFAULT_HOSTNAME_API}/2.0/recent_items`, () => {
|
|
239
|
+
return HttpResponse.json(mockRecentItems);
|
|
240
|
+
})];
|
|
227
241
|
export const emptyState = {
|
|
228
242
|
args: {
|
|
229
243
|
rootFolderId: '74729718131'
|
|
230
244
|
},
|
|
245
|
+
parameters: {
|
|
246
|
+
msw: {
|
|
247
|
+
handlers: [...defaultHandlers, http.get(mockUserRequest.url, () => {
|
|
248
|
+
return HttpResponse.json(mockUserRequest.response);
|
|
249
|
+
})]
|
|
250
|
+
}
|
|
251
|
+
},
|
|
231
252
|
play: async ({
|
|
232
253
|
canvasElement
|
|
233
254
|
}) => {
|
|
@@ -270,19 +291,7 @@ export default {
|
|
|
270
291
|
},
|
|
271
292
|
parameters: {
|
|
272
293
|
msw: {
|
|
273
|
-
handlers:
|
|
274
|
-
return HttpResponse.json(mockRootFolder);
|
|
275
|
-
}), http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/73426618530`, () => {
|
|
276
|
-
return HttpResponse.json(mockSubfolder);
|
|
277
|
-
}), http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/74729718131`, () => {
|
|
278
|
-
return HttpResponse.json(mockEmptyRootFolder);
|
|
279
|
-
}), http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/191354690948`, () => {
|
|
280
|
-
return new HttpResponse('Internal Server Error', {
|
|
281
|
-
status: 500
|
|
282
|
-
});
|
|
283
|
-
}), http.get(`${DEFAULT_HOSTNAME_API}/2.0/recent_items`, () => {
|
|
284
|
-
return HttpResponse.json(mockRecentItems);
|
|
285
|
-
})]
|
|
294
|
+
handlers: defaultHandlers
|
|
286
295
|
}
|
|
287
296
|
}
|
|
288
297
|
};
|
|
@@ -5,6 +5,7 @@ import ContentExplorer from '../../ContentExplorer';
|
|
|
5
5
|
import { mockEmptyRootFolder, mockRootFolder } from '../../../common/__mocks__/mockRootFolder';
|
|
6
6
|
import mockSubfolder from '../../../common/__mocks__/mockSubfolder';
|
|
7
7
|
import mockRecentItems from '../../../common/__mocks__/mockRecentItems';
|
|
8
|
+
import { mockUserRequest } from '../../../common/__mocks__/mockRequests';
|
|
8
9
|
|
|
9
10
|
import { DEFAULT_HOSTNAME_API } from '../../../../constants';
|
|
10
11
|
|
|
@@ -227,10 +228,38 @@ export const closeCreateFolderDialog = {
|
|
|
227
228
|
// },
|
|
228
229
|
// };
|
|
229
230
|
|
|
231
|
+
const defaultHandlers = [
|
|
232
|
+
http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/69083462919`, () => {
|
|
233
|
+
return HttpResponse.json(mockRootFolder);
|
|
234
|
+
}),
|
|
235
|
+
http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/73426618530`, () => {
|
|
236
|
+
return HttpResponse.json(mockSubfolder);
|
|
237
|
+
}),
|
|
238
|
+
http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/74729718131`, () => {
|
|
239
|
+
return HttpResponse.json(mockEmptyRootFolder);
|
|
240
|
+
}),
|
|
241
|
+
http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/191354690948`, () => {
|
|
242
|
+
return new HttpResponse('Internal Server Error', { status: 500 });
|
|
243
|
+
}),
|
|
244
|
+
http.get(`${DEFAULT_HOSTNAME_API}/2.0/recent_items`, () => {
|
|
245
|
+
return HttpResponse.json(mockRecentItems);
|
|
246
|
+
}),
|
|
247
|
+
];
|
|
248
|
+
|
|
230
249
|
export const emptyState = {
|
|
231
250
|
args: {
|
|
232
251
|
rootFolderId: '74729718131',
|
|
233
252
|
},
|
|
253
|
+
parameters: {
|
|
254
|
+
msw: {
|
|
255
|
+
handlers: [
|
|
256
|
+
...defaultHandlers,
|
|
257
|
+
http.get(mockUserRequest.url, () => {
|
|
258
|
+
return HttpResponse.json(mockUserRequest.response);
|
|
259
|
+
}),
|
|
260
|
+
],
|
|
261
|
+
},
|
|
262
|
+
},
|
|
234
263
|
play: async ({ canvasElement }) => {
|
|
235
264
|
const canvas = within(canvasElement);
|
|
236
265
|
await waitFor(() => {
|
|
@@ -271,23 +300,7 @@ export default {
|
|
|
271
300
|
},
|
|
272
301
|
parameters: {
|
|
273
302
|
msw: {
|
|
274
|
-
handlers:
|
|
275
|
-
http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/69083462919`, () => {
|
|
276
|
-
return HttpResponse.json(mockRootFolder);
|
|
277
|
-
}),
|
|
278
|
-
http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/73426618530`, () => {
|
|
279
|
-
return HttpResponse.json(mockSubfolder);
|
|
280
|
-
}),
|
|
281
|
-
http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/74729718131`, () => {
|
|
282
|
-
return HttpResponse.json(mockEmptyRootFolder);
|
|
283
|
-
}),
|
|
284
|
-
http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/191354690948`, () => {
|
|
285
|
-
return new HttpResponse('Internal Server Error', { status: 500 });
|
|
286
|
-
}),
|
|
287
|
-
http.get(`${DEFAULT_HOSTNAME_API}/2.0/recent_items`, () => {
|
|
288
|
-
return HttpResponse.json(mockRecentItems);
|
|
289
|
-
}),
|
|
290
|
-
],
|
|
303
|
+
handlers: defaultHandlers,
|
|
291
304
|
},
|
|
292
305
|
},
|
|
293
306
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentExplorer-visual.stories.js","names":["http","HttpResponse","expect","screen","userEvent","waitFor","within","ContentExplorer","mockEmptyRootFolder","mockRootFolder","mockSubfolder","mockRecentItems","DEFAULT_HOSTNAME_API","basic","play","canvasElement","canvas","folder","findByText","toBeInTheDocument","getByText","openExistingFolder","subFolder","click","openCreateFolderDialog","addButton","findByRole","name","dropdown","newFolderButton","closeCreateFolderDialog","cancelButton","queryByText","not","emptyState","args","rootFolderId","errorEmptyState","withTheming","title","component","features","global","FEATURE_FLAGS","FOLDER_ID","token","TOKEN","parameters","msw","handlers","get","json","status"],"sources":["../../../../../src/elements/content-explorer/stories/tests/ContentExplorer-visual.stories.js"],"sourcesContent":["import { http, HttpResponse } from 'msw';\nimport { expect, screen, userEvent, waitFor, within } from '@storybook/test';\n\nimport ContentExplorer from '../../ContentExplorer';\nimport { mockEmptyRootFolder, mockRootFolder } from '../../../common/__mocks__/mockRootFolder';\nimport mockSubfolder from '../../../common/__mocks__/mockSubfolder';\nimport mockRecentItems from '../../../common/__mocks__/mockRecentItems';\n\nimport { DEFAULT_HOSTNAME_API } from '../../../../constants';\n\nexport const basic = {\n play: async ({ canvasElement }) => {\n const canvas = within(canvasElement);\n await waitFor(async () => {\n const folder = await canvas.findByText('An Ordered Folder');\n expect(folder).toBeInTheDocument();\n expect(canvas.getByText('Apr 16, 2019 by Preview')).toBeInTheDocument();\n\n expect(canvas.getByText('Archive')).toBeInTheDocument();\n expect(canvas.getByText('Dec 16, 2020 by Preview')).toBeInTheDocument();\n\n expect(canvas.getByText('Archived Folder')).toBeInTheDocument();\n expect(canvas.getByText('Dec 17, 2020 by Preview')).toBeInTheDocument();\n\n expect(canvas.getByText('Book Sample.pdf')).toBeInTheDocument();\n expect(canvas.getByText('Dec 8, 2022 by Preview')).toBeInTheDocument();\n });\n },\n};\n\nexport const openExistingFolder = {\n play: async ({ canvasElement }) => {\n const canvas = within(canvasElement);\n\n const subFolder = await canvas.findByText('An Ordered Folder');\n await userEvent.click(subFolder);\n\n expect(await canvas.findByText('Audio.mp3')).toBeInTheDocument();\n },\n};\n\nexport const openCreateFolderDialog = {\n play: async ({ canvasElement }) => {\n const canvas = within(canvasElement);\n\n const addButton = await canvas.findByRole('button', { name: 'Add' });\n await userEvent.click(addButton);\n\n const dropdown = await screen.findByRole('menu');\n const newFolderButton = await within(dropdown).findByRole('menuitem', { name: 'New Folder' });\n expect(newFolderButton).toBeInTheDocument();\n await userEvent.click(newFolderButton);\n\n expect(await screen.findByText('Please enter a name.')).toBeInTheDocument();\n },\n};\n\nexport const closeCreateFolderDialog = {\n play: async ({ canvasElement }) => {\n const canvas = within(canvasElement);\n\n const addButton = await canvas.findByRole('button', { name: 'Add' });\n await userEvent.click(addButton);\n\n const dropdown = await screen.findByRole('menu');\n const newFolderButton = await within(dropdown).findByRole('menuitem', { name: 'New Folder' });\n expect(newFolderButton).toBeInTheDocument();\n await userEvent.click(newFolderButton);\n\n expect(await screen.findByText('Please enter a name.')).toBeInTheDocument();\n\n const cancelButton = screen.getByText('Cancel');\n await userEvent.click(cancelButton);\n\n await waitFor(() => {\n expect(screen.queryByText('Please enter a name.')).not.toBeInTheDocument();\n });\n },\n};\n\n// export const openDeleteConfirmationDialog = {\n// play: async ({ canvasElement }) => {\n// const canvas = within(canvasElement);\n\n// await waitFor(async () => {\n// await canvas.findByRole('grid', { name: 'List view' });\n\n// const moreOptionsButton = await canvas.findAllByRole('button', { name: 'More options' });\n// await userEvent.hover(moreOptionsButton[0]);\n// await userEvent.click(moreOptionsButton[0]);\n\n// const deleteButton = await screen.findByRole('menuitem', { name: 'Delete' });\n// await userEvent.hover(deleteButton);\n// await userEvent.click(deleteButton);\n// });\n\n// expect(\n// await screen.findByText('Are you sure you want to delete An Ordered Folder and all its contents?'),\n// ).toBeInTheDocument();\n// },\n// };\n\n// export const closeDeleteConfirmationDialog = {\n// play: async ({ canvasElement }) => {\n// const canvas = within(canvasElement);\n\n// await waitFor(async () => {\n// await canvas.findByRole('grid', { name: 'List view' });\n\n// const moreOptionsButton = await canvas.findAllByRole('button', { name: 'More options' });\n// await userEvent.hover(moreOptionsButton[0]);\n// await userEvent.click(moreOptionsButton[0]);\n\n// const deleteButton = await screen.findByRole('menuitem', { name: 'Delete' });\n// await userEvent.hover(deleteButton);\n// await userEvent.click(deleteButton);\n// });\n\n// expect(\n// await screen.findByText('Are you sure you want to delete An Ordered Folder and all its contents?'),\n// ).toBeInTheDocument();\n\n// const cancelButton = screen.getByText('Cancel');\n// await userEvent.click(cancelButton);\n\n// await waitFor(() => {\n// expect(\n// screen.queryByText('Are you sure you want to delete An Ordered Folder and all its contents?'),\n// ).not.toBeInTheDocument();\n// });\n// },\n// };\n\n// export const openRenameDialog = {\n// play: async ({ canvasElement }) => {\n// const canvas = within(canvasElement);\n\n// await waitFor(async () => {\n// await canvas.findByRole('grid', { name: 'List view' });\n\n// const moreOptionsButton = await canvas.findAllByRole('button', { name: 'More options' });\n// await userEvent.hover(moreOptionsButton[0]);\n// await userEvent.click(moreOptionsButton[0]);\n\n// const renameButton = await screen.findByRole('menuitem', { name: 'Rename' });\n// await userEvent.hover(renameButton);\n// await userEvent.click(renameButton);\n// });\n\n// expect(await screen.findByText('Please enter a new name for An Ordered Folder:')).toBeInTheDocument();\n// },\n// };\n\n// export const closeRenameDialog = {\n// play: async ({ canvasElement }) => {\n// const canvas = within(canvasElement);\n\n// await waitFor(async () => {\n// await canvas.findByRole('grid', { name: 'List view' });\n\n// const moreOptionsButton = await canvas.findAllByRole('button', { name: 'More options' });\n// await userEvent.hover(moreOptionsButton[0]);\n// await userEvent.click(moreOptionsButton[0]);\n\n// const renameButton = await screen.findByRole('menuitem', { name: 'Rename' });\n// await userEvent.hover(renameButton);\n// await userEvent.click(renameButton);\n// });\n\n// expect(await screen.findByText('Please enter a new name for An Ordered Folder:')).toBeInTheDocument();\n// const cancelButton = screen.getByText('Cancel');\n// await userEvent.click(cancelButton);\n\n// await waitFor(() => {\n// expect(screen.queryByText('Please enter a new name for An Ordered Folder:')).not.toBeInTheDocument();\n// });\n// },\n// };\n\n// export const openShareDialog = {\n// play: async ({ canvasElement }) => {\n// const canvas = within(canvasElement);\n\n// await waitFor(async () => {\n// await canvas.findByRole('grid', { name: 'List view' });\n\n// const moreOptionsButton = await canvas.findAllByRole('button', { name: 'More options' });\n// await userEvent.hover(moreOptionsButton[0]);\n// await userEvent.click(moreOptionsButton[0]);\n\n// const shareButton = await screen.findByRole('menuitem', { name: 'Share' });\n// await userEvent.hover(shareButton);\n// await userEvent.click(shareButton);\n// });\n\n// expect(await screen.findByText('Shared Link:')).toBeInTheDocument();\n\n// const inputElement = screen.getByDisplayValue('https://example.com/share-link');\n// expect(inputElement).toBeInTheDocument();\n// },\n// };\n\n// export const closeShareDialog = {\n// play: async ({ canvasElement }) => {\n// const canvas = within(canvasElement);\n\n// await waitFor(async () => {\n// await canvas.findByRole('grid', { name: 'List view' });\n\n// const moreOptionsButton = await canvas.findAllByRole('button', { name: 'More options' });\n// await userEvent.click(moreOptionsButton[0]);\n\n// const shareButton = await screen.findByRole('menuitem', { name: 'Share' });\n// await userEvent.hover(shareButton);\n// await userEvent.click(shareButton);\n// });\n\n// expect(await screen.findByText('Shared Link:')).toBeInTheDocument();\n// const closeButton = screen.getByText('Close');\n// await userEvent.click(closeButton);\n\n// await waitFor(() => {\n// expect(screen.queryByText('Shared Link:')).not.toBeInTheDocument();\n// });\n// const inputElement = screen.queryByDisplayValue('https://example.com/share-link');\n// expect(inputElement).not.toBeInTheDocument();\n// },\n// };\n\nexport const emptyState = {\n args: {\n rootFolderId: '74729718131',\n },\n play: async ({ canvasElement }) => {\n const canvas = within(canvasElement);\n await waitFor(() => {\n expect(canvas.getByText('There are no items in this folder.')).toBeInTheDocument();\n });\n },\n};\n\nexport const errorEmptyState = {\n args: {\n rootFolderId: '191354690948',\n },\n play: async ({ canvasElement }) => {\n const canvas = within(canvasElement);\n await waitFor(() => {\n expect(canvas.getByText('A network error has occurred while trying to load.')).toBeInTheDocument();\n });\n },\n};\n\nexport const withTheming = {\n play: async ({ canvasElement }) => {\n const canvas = within(canvasElement);\n\n await waitFor(async () => {\n expect(await canvas.getByText('Preview Test Folder')).toBeInTheDocument();\n });\n },\n};\n\nexport default {\n title: 'Elements/ContentExplorer/tests/ContentExplorer/visual',\n component: ContentExplorer,\n args: {\n features: global.FEATURE_FLAGS,\n rootFolderId: global.FOLDER_ID,\n token: global.TOKEN,\n },\n parameters: {\n msw: {\n handlers: [\n http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/69083462919`, () => {\n return HttpResponse.json(mockRootFolder);\n }),\n http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/73426618530`, () => {\n return HttpResponse.json(mockSubfolder);\n }),\n http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/74729718131`, () => {\n return HttpResponse.json(mockEmptyRootFolder);\n }),\n http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/191354690948`, () => {\n return new HttpResponse('Internal Server Error', { status: 500 });\n }),\n http.get(`${DEFAULT_HOSTNAME_API}/2.0/recent_items`, () => {\n return HttpResponse.json(mockRecentItems);\n }),\n ],\n },\n },\n};\n"],"mappings":"AAAA,SAASA,IAAI,EAAEC,YAAY,QAAQ,KAAK;AACxC,SAASC,MAAM,EAAEC,MAAM,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,iBAAiB;AAE5E,OAAOC,eAAe,MAAM,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oB,KAAK,EAAE,uDAAuD;EAC9DC,SAAS,EAAEjC,eAAe;EAC1B4B,IAAI,EAAE;IACFM,QAAQ,EAAEC,MAAM,CAACC,aAAa;IAC9BP,YAAY,EAAEM,MAAM,CAACE,SAAS;IAC9BC,KAAK,EAAEH,MAAM,CAACI;EAClB,CAAC;EACDC,UAAU,EAAE;IACRC,GAAG,EAAE;MACDC,QAAQ,EAAE,CACNjD,IAAI,CAACkD,GAAG,CAAC,GAAGtC,oBAAoB,0BAA0B,EAAE,MAAM;QAC9D,OAAOX,YAAY,CAACkD,IAAI,CAAC1C,cAAc,CAAC;MAC5C,CAAC,CAAC,EACFT,IAAI,CAACkD,GAAG,CAAC,GAAGtC,oBAAoB,0BAA0B,EAAE,MAAM;QAC9D,OAAOX,YAAY,CAACkD,IAAI,CAACzC,aAAa,CAAC;MAC3C,CAAC,CAAC,EACFV,IAAI,CAACkD,GAAG,CAAC,GAAGtC,oBAAoB,0BAA0B,EAAE,MAAM;QAC9D,OAAOX,YAAY,CAACkD,IAAI,CAAC3C,mBAAmB,CAAC;MACjD,CAAC,CAAC,EACFR,IAAI,CAACkD,GAAG,CAAC,GAAGtC,oBAAoB,2BAA2B,EAAE,MAAM;QAC/D,OAAO,IAAIX,YAAY,CAAC,uBAAuB,EAAE;UAAEmD,MAAM,EAAE;QAAI,CAAC,CAAC;MACrE,CAAC,CAAC,EACFpD,IAAI,CAACkD,GAAG,CAAC,GAAGtC,oBAAoB,mBAAmB,EAAE,MAAM;QACvD,OAAOX,YAAY,CAACkD,IAAI,CAACxC,eAAe,CAAC;MAC7C,CAAC,CAAC;IAEV;EACJ;AACJ,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ContentExplorer-visual.stories.js","names":["http","HttpResponse","expect","screen","userEvent","waitFor","within","ContentExplorer","mockEmptyRootFolder","mockRootFolder","mockSubfolder","mockRecentItems","mockUserRequest","DEFAULT_HOSTNAME_API","basic","play","canvasElement","canvas","folder","findByText","toBeInTheDocument","getByText","openExistingFolder","subFolder","click","openCreateFolderDialog","addButton","findByRole","name","dropdown","newFolderButton","closeCreateFolderDialog","cancelButton","queryByText","not","defaultHandlers","get","json","status","emptyState","args","rootFolderId","parameters","msw","handlers","url","response","errorEmptyState","withTheming","title","component","features","global","FEATURE_FLAGS","FOLDER_ID","token","TOKEN"],"sources":["../../../../../src/elements/content-explorer/stories/tests/ContentExplorer-visual.stories.js"],"sourcesContent":["import { http, HttpResponse } from 'msw';\nimport { expect, screen, userEvent, waitFor, within } from '@storybook/test';\n\nimport ContentExplorer from '../../ContentExplorer';\nimport { mockEmptyRootFolder, mockRootFolder } from '../../../common/__mocks__/mockRootFolder';\nimport mockSubfolder from '../../../common/__mocks__/mockSubfolder';\nimport mockRecentItems from '../../../common/__mocks__/mockRecentItems';\nimport { mockUserRequest } from '../../../common/__mocks__/mockRequests';\n\nimport { DEFAULT_HOSTNAME_API } from '../../../../constants';\n\nexport const basic = {\n play: async ({ canvasElement }) => {\n const canvas = within(canvasElement);\n await waitFor(async () => {\n const folder = await canvas.findByText('An Ordered Folder');\n expect(folder).toBeInTheDocument();\n expect(canvas.getByText('Apr 16, 2019 by Preview')).toBeInTheDocument();\n\n expect(canvas.getByText('Archive')).toBeInTheDocument();\n expect(canvas.getByText('Dec 16, 2020 by Preview')).toBeInTheDocument();\n\n expect(canvas.getByText('Archived Folder')).toBeInTheDocument();\n expect(canvas.getByText('Dec 17, 2020 by Preview')).toBeInTheDocument();\n\n expect(canvas.getByText('Book Sample.pdf')).toBeInTheDocument();\n expect(canvas.getByText('Dec 8, 2022 by Preview')).toBeInTheDocument();\n });\n },\n};\n\nexport const openExistingFolder = {\n play: async ({ canvasElement }) => {\n const canvas = within(canvasElement);\n\n const subFolder = await canvas.findByText('An Ordered Folder');\n await userEvent.click(subFolder);\n\n expect(await canvas.findByText('Audio.mp3')).toBeInTheDocument();\n },\n};\n\nexport const openCreateFolderDialog = {\n play: async ({ canvasElement }) => {\n const canvas = within(canvasElement);\n\n const addButton = await canvas.findByRole('button', { name: 'Add' });\n await userEvent.click(addButton);\n\n const dropdown = await screen.findByRole('menu');\n const newFolderButton = await within(dropdown).findByRole('menuitem', { name: 'New Folder' });\n expect(newFolderButton).toBeInTheDocument();\n await userEvent.click(newFolderButton);\n\n expect(await screen.findByText('Please enter a name.')).toBeInTheDocument();\n },\n};\n\nexport const closeCreateFolderDialog = {\n play: async ({ canvasElement }) => {\n const canvas = within(canvasElement);\n\n const addButton = await canvas.findByRole('button', { name: 'Add' });\n await userEvent.click(addButton);\n\n const dropdown = await screen.findByRole('menu');\n const newFolderButton = await within(dropdown).findByRole('menuitem', { name: 'New Folder' });\n expect(newFolderButton).toBeInTheDocument();\n await userEvent.click(newFolderButton);\n\n expect(await screen.findByText('Please enter a name.')).toBeInTheDocument();\n\n const cancelButton = screen.getByText('Cancel');\n await userEvent.click(cancelButton);\n\n await waitFor(() => {\n expect(screen.queryByText('Please enter a name.')).not.toBeInTheDocument();\n });\n },\n};\n\n// export const openDeleteConfirmationDialog = {\n// play: async ({ canvasElement }) => {\n// const canvas = within(canvasElement);\n\n// await waitFor(async () => {\n// await canvas.findByRole('grid', { name: 'List view' });\n\n// const moreOptionsButton = await canvas.findAllByRole('button', { name: 'More options' });\n// await userEvent.hover(moreOptionsButton[0]);\n// await userEvent.click(moreOptionsButton[0]);\n\n// const deleteButton = await screen.findByRole('menuitem', { name: 'Delete' });\n// await userEvent.hover(deleteButton);\n// await userEvent.click(deleteButton);\n// });\n\n// expect(\n// await screen.findByText('Are you sure you want to delete An Ordered Folder and all its contents?'),\n// ).toBeInTheDocument();\n// },\n// };\n\n// export const closeDeleteConfirmationDialog = {\n// play: async ({ canvasElement }) => {\n// const canvas = within(canvasElement);\n\n// await waitFor(async () => {\n// await canvas.findByRole('grid', { name: 'List view' });\n\n// const moreOptionsButton = await canvas.findAllByRole('button', { name: 'More options' });\n// await userEvent.hover(moreOptionsButton[0]);\n// await userEvent.click(moreOptionsButton[0]);\n\n// const deleteButton = await screen.findByRole('menuitem', { name: 'Delete' });\n// await userEvent.hover(deleteButton);\n// await userEvent.click(deleteButton);\n// });\n\n// expect(\n// await screen.findByText('Are you sure you want to delete An Ordered Folder and all its contents?'),\n// ).toBeInTheDocument();\n\n// const cancelButton = screen.getByText('Cancel');\n// await userEvent.click(cancelButton);\n\n// await waitFor(() => {\n// expect(\n// screen.queryByText('Are you sure you want to delete An Ordered Folder and all its contents?'),\n// ).not.toBeInTheDocument();\n// });\n// },\n// };\n\n// export const openRenameDialog = {\n// play: async ({ canvasElement }) => {\n// const canvas = within(canvasElement);\n\n// await waitFor(async () => {\n// await canvas.findByRole('grid', { name: 'List view' });\n\n// const moreOptionsButton = await canvas.findAllByRole('button', { name: 'More options' });\n// await userEvent.hover(moreOptionsButton[0]);\n// await userEvent.click(moreOptionsButton[0]);\n\n// const renameButton = await screen.findByRole('menuitem', { name: 'Rename' });\n// await userEvent.hover(renameButton);\n// await userEvent.click(renameButton);\n// });\n\n// expect(await screen.findByText('Please enter a new name for An Ordered Folder:')).toBeInTheDocument();\n// },\n// };\n\n// export const closeRenameDialog = {\n// play: async ({ canvasElement }) => {\n// const canvas = within(canvasElement);\n\n// await waitFor(async () => {\n// await canvas.findByRole('grid', { name: 'List view' });\n\n// const moreOptionsButton = await canvas.findAllByRole('button', { name: 'More options' });\n// await userEvent.hover(moreOptionsButton[0]);\n// await userEvent.click(moreOptionsButton[0]);\n\n// const renameButton = await screen.findByRole('menuitem', { name: 'Rename' });\n// await userEvent.hover(renameButton);\n// await userEvent.click(renameButton);\n// });\n\n// expect(await screen.findByText('Please enter a new name for An Ordered Folder:')).toBeInTheDocument();\n// const cancelButton = screen.getByText('Cancel');\n// await userEvent.click(cancelButton);\n\n// await waitFor(() => {\n// expect(screen.queryByText('Please enter a new name for An Ordered Folder:')).not.toBeInTheDocument();\n// });\n// },\n// };\n\n// export const openShareDialog = {\n// play: async ({ canvasElement }) => {\n// const canvas = within(canvasElement);\n\n// await waitFor(async () => {\n// await canvas.findByRole('grid', { name: 'List view' });\n\n// const moreOptionsButton = await canvas.findAllByRole('button', { name: 'More options' });\n// await userEvent.hover(moreOptionsButton[0]);\n// await userEvent.click(moreOptionsButton[0]);\n\n// const shareButton = await screen.findByRole('menuitem', { name: 'Share' });\n// await userEvent.hover(shareButton);\n// await userEvent.click(shareButton);\n// });\n\n// expect(await screen.findByText('Shared Link:')).toBeInTheDocument();\n\n// const inputElement = screen.getByDisplayValue('https://example.com/share-link');\n// expect(inputElement).toBeInTheDocument();\n// },\n// };\n\n// export const closeShareDialog = {\n// play: async ({ canvasElement }) => {\n// const canvas = within(canvasElement);\n\n// await waitFor(async () => {\n// await canvas.findByRole('grid', { name: 'List view' });\n\n// const moreOptionsButton = await canvas.findAllByRole('button', { name: 'More options' });\n// await userEvent.click(moreOptionsButton[0]);\n\n// const shareButton = await screen.findByRole('menuitem', { name: 'Share' });\n// await userEvent.hover(shareButton);\n// await userEvent.click(shareButton);\n// });\n\n// expect(await screen.findByText('Shared Link:')).toBeInTheDocument();\n// const closeButton = screen.getByText('Close');\n// await userEvent.click(closeButton);\n\n// await waitFor(() => {\n// expect(screen.queryByText('Shared Link:')).not.toBeInTheDocument();\n// });\n// const inputElement = screen.queryByDisplayValue('https://example.com/share-link');\n// expect(inputElement).not.toBeInTheDocument();\n// },\n// };\n\nconst defaultHandlers = [\n http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/69083462919`, () => {\n return HttpResponse.json(mockRootFolder);\n }),\n http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/73426618530`, () => {\n return HttpResponse.json(mockSubfolder);\n }),\n http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/74729718131`, () => {\n return HttpResponse.json(mockEmptyRootFolder);\n }),\n http.get(`${DEFAULT_HOSTNAME_API}/2.0/folders/191354690948`, () => {\n return new HttpResponse('Internal Server Error', { status: 500 });\n }),\n http.get(`${DEFAULT_HOSTNAME_API}/2.0/recent_items`, () => {\n return HttpResponse.json(mockRecentItems);\n }),\n];\n\nexport const emptyState = {\n args: {\n rootFolderId: '74729718131',\n },\n parameters: {\n msw: {\n handlers: [\n ...defaultHandlers,\n http.get(mockUserRequest.url, () => {\n return HttpResponse.json(mockUserRequest.response);\n }),\n ],\n },\n },\n play: async ({ canvasElement }) => {\n const canvas = within(canvasElement);\n await waitFor(() => {\n expect(canvas.getByText('There are no items in this folder.')).toBeInTheDocument();\n });\n },\n};\n\nexport const errorEmptyState = {\n args: {\n rootFolderId: '191354690948',\n },\n play: async ({ canvasElement }) => {\n const canvas = within(canvasElement);\n await waitFor(() => {\n expect(canvas.getByText('A network error has occurred while trying to load.')).toBeInTheDocument();\n });\n },\n};\n\nexport const withTheming = {\n play: async ({ canvasElement }) => {\n const canvas = within(canvasElement);\n\n await waitFor(async () => {\n expect(await canvas.getByText('Preview Test Folder')).toBeInTheDocument();\n });\n },\n};\n\nexport default {\n title: 'Elements/ContentExplorer/tests/ContentExplorer/visual',\n component: ContentExplorer,\n args: {\n features: global.FEATURE_FLAGS,\n rootFolderId: global.FOLDER_ID,\n token: global.TOKEN,\n },\n parameters: {\n msw: {\n handlers: defaultHandlers,\n },\n },\n};\n"],"mappings":"AAAA,SAASA,IAAI,EAAEC,YAAY,QAAQ,KAAK;AACxC,SAASC,MAAM,EAAEC,MAAM,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,iBAAiB;AAE5E,OAAOC,eAAe,MAAM,uBAAuB;AACnD,SAASC,mBAAmB,EAAEC,cAAc,QAAQ,0CAA0C;AAC9F,OAAOC,aAAa,MAAM,yCAAyC;AACnE,OAAOC,eAAe,MAAM,2CAA2C;AACvE,SAASC,eAAe,QAAQ,wCAAwC;AAExE,SAASC,oBAAoB,QAAQ,uBAAuB;AAE5D,OAAO,MAAMC,KAAK,GAAG;EACjBC,IAAI,EAAE,MAAAA,CAAO;IAAEC;EAAc,CAAC,KAAK;IAC/B,MAAMC,MAAM,GAAGX,MAAM,CAACU,aAAa,CAAC;IACpC,MAAMX,OA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tF,CAAC,CAAC;EACN;AACJ,CAAC;AAED,OAAO,MAAM2B,eAAe,GAAG;EAC3BP,IAAI,EAAE;IACFC,YAAY,EAAE;EAClB,CAAC;EACD1B,IAAI,EAAE,MAAAA,CAAO;IAAEC;EAAc,CAAC,KAAK;IAC/B,MAAMC,MAAM,GAAGX,MAAM,CAACU,aAAa,CAAC;IACpC,MAAMX,OAAO,CAAC,MAAM;MAChBH,MAAM,CAACe,MAAM,CAACI,SAAS,CAAC,oDAAoD,CAAC,CAAC,CAACD,iBAAiB,CAAC,CAAC;IACtG,CAAC,CAAC;EACN;AACJ,CAAC;AAED,OAAO,MAAM4B,WAAW,GAAG;EACvBjC,IAAI,EAAE,MAAAA,CAAO;IAAEC;EAAc,CAAC,KAAK;IAC/B,MAAMC,MAAM,GAAGX,MAAM,CAACU,aAAa,CAAC;IAEpC,MAAMX,OAAO,CAAC,YAAY;MACtBH,MAAM,CAAC,MAAMe,MAAM,CAACI,SAAS,CAAC,qBAAqB,CAAC,CAAC,CAACD,iBAAiB,CAAC,CAAC;IAC7E,CAAC,CAAC;EACN;AACJ,CAAC;AAED,eAAe;EACX6B,KAAK,EAAE,uDAAuD;EAC9DC,SAAS,EAAE3C,eAAe;EAC1BiC,IAAI,EAAE;IACFW,QAAQ,EAAEC,MAAM,CAACC,aAAa;IAC9BZ,YAAY,EAAEW,MAAM,CAACE,SAAS;IAC9BC,KAAK,EAAEH,MAAM,CAACI;EAClB,CAAC;EACDd,UAAU,EAAE;IACRC,GAAG,EAAE;MACDC,QAAQ,EAAET;IACd;EACJ;AACJ,CAAC","ignoreList":[]}
|
|
@@ -263,6 +263,7 @@ class ContentSidebar extends React.Component {
|
|
|
263
263
|
defaultView,
|
|
264
264
|
detailsSidebarProps,
|
|
265
265
|
docGenSidebarProps,
|
|
266
|
+
features,
|
|
266
267
|
fileId,
|
|
267
268
|
getPreview,
|
|
268
269
|
getViewer,
|
|
@@ -302,7 +303,8 @@ class ContentSidebar extends React.Component {
|
|
|
302
303
|
value: this.api
|
|
303
304
|
}, /*#__PURE__*/React.createElement(NavRouter, {
|
|
304
305
|
history: history,
|
|
305
|
-
initialEntries: [initialPath]
|
|
306
|
+
initialEntries: [initialPath],
|
|
307
|
+
features: features
|
|
306
308
|
}, /*#__PURE__*/React.createElement(TooltipProvider, null, /*#__PURE__*/React.createElement(Sidebar, {
|
|
307
309
|
activitySidebarProps: activitySidebarProps,
|
|
308
310
|
additionalTabs: additionalTabs,
|
|
@@ -349,6 +349,7 @@ class ContentSidebar extends React.Component<Props, State> {
|
|
|
349
349
|
defaultView,
|
|
350
350
|
detailsSidebarProps,
|
|
351
351
|
docGenSidebarProps,
|
|
352
|
+
features,
|
|
352
353
|
fileId,
|
|
353
354
|
getPreview,
|
|
354
355
|
getViewer,
|
|
@@ -382,7 +383,7 @@ class ContentSidebar extends React.Component<Props, State> {
|
|
|
382
383
|
return (
|
|
383
384
|
<Internationalize language={language} messages={messages}>
|
|
384
385
|
<APIContext.Provider value={(this.api: any)}>
|
|
385
|
-
<NavRouter history={history} initialEntries={[initialPath]}>
|
|
386
|
+
<NavRouter history={history} initialEntries={[initialPath]} features={features}>
|
|
386
387
|
<TooltipProvider>
|
|
387
388
|
<Sidebar
|
|
388
389
|
activitySidebarProps={activitySidebarProps}
|