From 567d4d0a2e5a1e5f25dcce541e2ad960e2c46490 Mon Sep 17 00:00:00 2001 From: Stanislaw Adaszewski Date: Tue, 11 Feb 2020 21:31:06 +0100 Subject: [PATCH] Implemented WBBrowseDialogCollectionList. --- .../wb-browse-dialog-collection-list.js | 65 ++++++++++++++++++- .../dialog/wb-browse-dialog-project-list.js | 11 ++-- .../js/dialog/wb-browse-dialog-user-list.js | 2 + frontend/src/js/dialog/wb-browse-dialog.js | 44 +++++++++++-- .../src/js/page/wb-launch-workflow-page.js | 3 +- 5 files changed, 112 insertions(+), 13 deletions(-) diff --git a/frontend/src/js/dialog/wb-browse-dialog-collection-list.js b/frontend/src/js/dialog/wb-browse-dialog-collection-list.js index 3f83c5b..41d26e5 100644 --- a/frontend/src/js/dialog/wb-browse-dialog-collection-list.js +++ b/frontend/src/js/dialog/wb-browse-dialog-collection-list.js @@ -1,11 +1,72 @@ import { h, Component } from 'preact'; +import WBTable from 'wb-table'; +import WBPagination from 'wb-pagination'; +import makeArvadosRequest from 'make-arvados-request'; class WBBrowseDialogCollectionList extends Component { - render() { + constructor(...args) { + super(...args); + this.state.rows = []; + } + + componentDidMount() { + this.fetchRows(); + } + + componentWillReceiveProps(nextProps) { + this.props = nextProps; + this.fetchRows(); + } + + prepareRows(items) { + const { navigate, selectWhat, makeSelectionCell } = this.props; + return items.map(it => (selectWhat === 'directory' ? [ + makeSelectionCell(it.uuid) + ] : []).concat([ + ( + { e.preventDefault(); + navigate('/browse-dialog/content/' + it.uuid); } }>{ it.name } + ), + it.uuid + ])); + } + + fetchRows() { + const { arvHost, arvToken } = this.props.app.state; + const { ownerUuid, textSearch, page, itemsPerPage } = this.props; + const filters = []; + if (ownerUuid) + filters.push(['owner_uuid', '=', ownerUuid]); + if (textSearch) + filters.push(['name', 'ilike', '%' + textSearch + '%']); + let prom = makeArvadosRequest(arvHost, arvToken, + '/arvados/v1/collections?filters=' + + encodeURIComponent(JSON.stringify(filters)) + + '&limit=' + itemsPerPage + + '&offset=' + (itemsPerPage * page)); + prom = prom.then(xhr => this.setState({ + 'rows': this.prepareRows(xhr.response.items), + 'numPages': Math.ceil(xhr.response.items_available / itemsPerPage) + })); + return prom; + } + + render({ selectWhat, page, navigate }, { rows, numPages }) { return ( -
WBBrowseDialogCollectionList
+
+ + + navigate({ 'bottomPage': i }) } /> +
); } } +WBBrowseDialogCollectionList.defaultProps = { + 'itemsPerPage': 20 +}; + export default WBBrowseDialogCollectionList; diff --git a/frontend/src/js/dialog/wb-browse-dialog-project-list.js b/frontend/src/js/dialog/wb-browse-dialog-project-list.js index 7ee65e9..fe0294a 100644 --- a/frontend/src/js/dialog/wb-browse-dialog-project-list.js +++ b/frontend/src/js/dialog/wb-browse-dialog-project-list.js @@ -20,8 +20,8 @@ class WBBrowseDialogProjectList extends Component { } prepareRows(items) { - const { navigate } = this.props; - return items.map(it => [ + const { navigate, selectWhat, makeSelectionCell } = this.props; + return items.map(it => (selectWhat === 'owner' ? [ makeSelectionCell(it.uuid, 'project') ] : []).concat([ ( { e.preventDefault(); @@ -29,7 +29,7 @@ class WBBrowseDialogProjectList extends Component { } }>{ it.name } ), it.uuid - ]); + ])); } fetchSharedWithMe() { @@ -83,10 +83,11 @@ class WBBrowseDialogProjectList extends Component { return prom; } - render({ app, navigate, page }, { numPages, rows }) { + render({ app, navigate, page, selectWhat }, { numPages, rows }) { return (
- { '\u00A0' } +
+ ) : ( + + ); + } + render({ app, id, selectMany, selectWhat }, { history, currentUrl, mode, uuid, topPage, bottomPage, textSearch }) { return ( - ) : (mode === 'browse' || mode === 'shared-with-me') ? ( + ) : (selectWhat !== 'owner' && mode === 'browse') ? (
Collections
- + this.navigate(url) } + ownerUuid={ uuid } selectWhat={ selectWhat } + makeSelectionCell={ uuid => this.makeSelectionCell(uuid) } />
) : null } @@ -194,4 +224,8 @@ class WBBrowseDialog extends Component { } } +WBBrowseDialog.defaultProps = { + 'accept': () => {} +}; + export default WBBrowseDialog; diff --git a/frontend/src/js/page/wb-launch-workflow-page.js b/frontend/src/js/page/wb-launch-workflow-page.js index e71fcc4..a7802ea 100644 --- a/frontend/src/js/page/wb-launch-workflow-page.js +++ b/frontend/src/js/page/wb-launch-workflow-page.js @@ -110,7 +110,8 @@ class WBLaunchWorkflowPage extends Component { items={ app.state.toolboxItems } selectMany={ true } onAccepted={ values => alert(values) } /> - + { workflow ? (