diff --git a/client/src/components/search/FacetedSearch.js b/client/src/components/search/FacetedSearch.js index f928f4ec82..e7501c3774 100644 --- a/client/src/components/search/FacetedSearch.js +++ b/client/src/components/search/FacetedSearch.js @@ -895,6 +895,7 @@ class FacetedSearch extends React.Component { }} sorting={sortingOrder} facets={facets} + selectedItems={this.state.selectedItems} /> ); }; diff --git a/client/src/components/search/faceted-search/controls/export-button/index.js b/client/src/components/search/faceted-search/controls/export-button/index.js index 5bfdec74b9..ac2cd43b4f 100644 --- a/client/src/components/search/faceted-search/controls/export-button/index.js +++ b/client/src/components/search/faceted-search/controls/export-button/index.js @@ -81,7 +81,7 @@ function checkTemplatePermissions (userInfo, template) { }); } -function ExportMenu ({onExport, onExportTemplate, onConfigure, templates}) { +function ExportMenu ({onExport, onExportTemplate, onConfigure, templates, selectedItems = []}) { const handle = ({key}) => { const [exportType, exportKey] = key.split('|'); switch (exportType) { @@ -105,11 +105,15 @@ function ExportMenu ({onExport, onExportTemplate, onConfigure, templates}) { break; } }; + const selected = selectedItems.length; const templatesSection = templates.length ? [ , ...templates.map(template => ( {template['friendly_name'] || template.key} + + {selected ? ` - ${selected} file${selected > 1 ? 's' : ''}` : ''} + )) ] : []; @@ -286,7 +290,13 @@ class ExportButton extends React.Component { const hide = message.loading(uploadToBucket ? 'Exporting...' : 'Downloading...', 0); await setStateAwaited({pending: true}); try { - const payload = this.getFacetedSearchExportPayload(); + const payload = { + ...this.getFacetedSearchExportPayload(), + files: (this.props.selectedItems || []).map(item => ({ + path: item.path, + storageId: item.parentId + })) + }; if (uploadToBucket) { await saveExport(template, payload); } else { @@ -368,6 +378,7 @@ class ExportButton extends React.Component { onConfigure={this.onConfigure} templates={templates} storages={this.storages} + selectedItems={this.props.selectedItems} /> )} className={className} @@ -425,7 +436,8 @@ ExportButton.propTypes = { query: PropTypes.string, filters: PropTypes.object, sorting: PropTypes.array, - facets: PropTypes.array + facets: PropTypes.array, + selectedItems: PropTypes.array }; export default ExportButton;