Skip to content

Commit

Permalink
GUI Issue-#3737: faceted search export templates - selected files (#3748
Browse files Browse the repository at this point in the history
)
  • Loading branch information
AleksandrGorodetskii authored Oct 17, 2024
1 parent 01367d6 commit 186c6b5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions client/src/components/search/FacetedSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ class FacetedSearch extends React.Component {
}}
sorting={sortingOrder}
facets={facets}
selectedItems={this.state.selectedItems}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -105,11 +105,15 @@ function ExportMenu ({onExport, onExportTemplate, onConfigure, templates}) {
break;
}
};
const selected = selectedItems.length;
const templatesSection = templates.length ? [
<Divider key="divider" />,
...templates.map(template => (
<MenuItem key={`template|${template.key}`}>
{template['friendly_name'] || template.key}
<span className="cp-text-not-important">
{selected ? ` - ${selected} file${selected > 1 ? 's' : ''}` : ''}
</span>
</MenuItem>
))
] : [];
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -368,6 +378,7 @@ class ExportButton extends React.Component {
onConfigure={this.onConfigure}
templates={templates}
storages={this.storages}
selectedItems={this.props.selectedItems}
/>
)}
className={className}
Expand Down Expand Up @@ -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;

0 comments on commit 186c6b5

Please sign in to comment.