From d9c7f4b0b9452c63b8b5f6af48cc698031b57afa Mon Sep 17 00:00:00 2001 From: Stanislaw Adaszewski Date: Wed, 4 Mar 2020 17:15:56 +0100 Subject: [PATCH] Further progress in workflow launcher. --- .../wb-browse-dialog-collection-content.js | 9 +- .../wb-browse-dialog-collection-list.js | 11 +- frontend/src/js/dialog/wb-browse-dialog.js | 13 +- .../src/js/page/wb-launch-workflow-page.js | 133 ++++++++++++++---- 4 files changed, 123 insertions(+), 43 deletions(-) diff --git a/frontend/src/js/dialog/wb-browse-dialog-collection-content.js b/frontend/src/js/dialog/wb-browse-dialog-collection-content.js index 2c757f4..e2a1d98 100644 --- a/frontend/src/js/dialog/wb-browse-dialog-collection-content.js +++ b/frontend/src/js/dialog/wb-browse-dialog-collection-content.js @@ -67,13 +67,16 @@ class WBBrowseDialogCollectionContent extends Component { prepareRows(listing) { const { makeSelectionCell, collectionPath, navigate, - page, itemsPerPage, collectionUuid, textSearch } = this.props; + page, itemsPerPage, collectionUuid, textSearch, selectWhat } = this.props; const textLower = textSearch.toLowerCase(); listing = listing.filter(it => (it[1].toLowerCase().indexOf(textLower) !== -1)); const numPages = Math.ceil(listing.length / itemsPerPage); const rows = listing.slice(page * itemsPerPage, (page + 1) * itemsPerPage).map(it => [ - makeSelectionCell(collectionUuid + '/' + collectionPath + '/' + it[1]), + ((it[0] === 'd' && selectWhat === 'directory') || + (it[0] === 'f' && selectWhat === 'file')) ? + makeSelectionCell(collectionUuid + collectionPath + '/' + it[1]) : + null, it[0] === 'd' ? ( { e.preventDefault(); @@ -99,7 +102,7 @@ class WBBrowseDialogCollectionContent extends Component { aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%"> ] } - navigate({ 'bottomPage': i }) } /> 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 3f934a2..9b26ab6 100644 --- a/frontend/src/js/dialog/wb-browse-dialog-collection-list.js +++ b/frontend/src/js/dialog/wb-browse-dialog-collection-list.js @@ -20,15 +20,14 @@ class WBBrowseDialogCollectionList extends Component { prepareRows(items) { const { navigate, selectWhat, makeSelectionCell } = this.props; - return items.map(it => (selectWhat === 'directory' ? [ - makeSelectionCell(it.uuid) - ] : []).concat([ + return items.map(it => [ + (selectWhat === 'directory' ? makeSelectionCell(it.uuid) : null), ( { e.preventDefault(); navigate('/browse-dialog/content/' + it.uuid + '////'); } }>{ it.name } ), it.uuid - ])); + ]); } fetchRows() { @@ -54,8 +53,8 @@ class WBBrowseDialogCollectionList extends Component { render({ selectWhat, page, navigate }, { rows, numPages }) { return (
- { selectMany ? ( + onclick={ e => { e.preventDefault(); accept(selectedOrder); $('#' + id).modal('hide'); } }>Accept ) : null }
diff --git a/frontend/src/js/page/wb-launch-workflow-page.js b/frontend/src/js/page/wb-launch-workflow-page.js index 29e14f8..6b0cdfe 100644 --- a/frontend/src/js/page/wb-launch-workflow-page.js +++ b/frontend/src/js/page/wb-launch-workflow-page.js @@ -3,6 +3,7 @@ import WBNavbarCommon from 'wb-navbar-common'; import WBArvadosCrumbs from 'wb-arvados-crumbs'; import WBBrowseDialog from 'wb-browse-dialog'; import WBTable from 'wb-table'; +import WBNameAndUuid from 'wb-name-and-uuid'; import makeArvadosRequest from 'make-arvados-request'; import linkState from 'linkstate'; @@ -16,6 +17,51 @@ function parseDefinition(text) { return definition; } +function encodeURIComponentIncludingDots(s) { + return encodeURIComponent(s).replace('.', '%2E'); +} + +class WBPathDisplay extends Component { + fetchData() { + const { app, path } = this.props; + const { arvHost, arvToken } = app.state; + let m; + if (m = /^[0-9a-f]{32}\+[0-9]+/.exec(path)); + else if (m = /^[a-z0-9]{5}-[a-z0-9]{5}-[a-z0-9]{15}/.exec(path)); + else return; + let prom = makeArvadosRequest(arvHost, arvToken, + '/arvados/v1/collections/' + m[0]); + prom = prom.then(xhr => this.setState({ + item: xhr.response, + tail: path.substr(m[0].length) + })); + } + + componentDidMount() { + this.fetchData(); + } + + componentWillReceiveProps(nextProps) { + this.props = nextProps; + this.fetchData(); + } + + render({}, { item, tail }) { + if (!item) + return 'Loading...'; + + return ( + + + { item.name || item.uuid } + + { tail } + + + ); + } +} + class WBLaunchWorkflowPage extends Component { constructor(...args) { super(...args); @@ -38,20 +84,25 @@ class WBLaunchWorkflowPage extends Component { } renderInput(inputSpec) { + const { app } = this.props; + const isFile = (inputSpec.type === 'File' || inputSpec.type === 'File[]' || (inputSpec.type.type === 'array' && inputSpec.type.items === 'File')); const isDirectory = (inputSpec.type === 'Directory' || inputSpec.type === 'Directory[]' || (inputSpec.type.type === 'array' && inputSpec.type.items === 'Directory')); - const isArray = (inputSpec.type === 'File[]' || inputSpec.type === 'Directory[]' || - inputSpec.type.type === 'array'); + const isArray = true; // (inputSpec.type === 'File[]' || inputSpec.type === 'Directory[]' || + // inputSpec.type.type === 'array'); if (!isFile && !isDirectory) return ( - (this.state.inputs[inputSpec.id] = e.target.value) }> +
+ (this.state.inputs[inputSpec.id] = e.target.value) }> +
{ inputSpec.doc }
+
); const button = ( @@ -60,7 +111,7 @@ class WBLaunchWorkflowPage extends Component { e.preventDefault(); this.browseDialogRef.current.show(isFile ? 'file' : 'directory', isArray, v => { - this.state.inputs[inputSpec.id] = v.toString(); + this.state.inputs[inputSpec.id] = JSON.stringify(v); this.setState({}); }); } }> @@ -68,14 +119,36 @@ class WBLaunchWorkflowPage extends Component { ); + let value = this.state.inputs[inputSpec.id]; + if (value) { + try { + value = jsyaml.load(value); + } catch (_) {} + } + return ( -
- (this.state.inputs[inputSpec.id] = e.target.value) }> -
- { button } +
+
+ (this.state.inputs[inputSpec.id] = e.target.value) }> +
+ { button } +
+
{ inputSpec.doc }
+ { value ? + isArray ? ( +
    + { value.map(path => ( +
  • + +
  • + )) } +
+ ) : ( + + ) : null }
); } @@ -102,24 +175,22 @@ class WBLaunchWorkflowPage extends Component {
-
- { projectUuid ? ( - - ) : null } - -
- -
- -
+
+ +
+
+ + { projectUuid ? ( + + ) : null }
@@ -144,6 +215,12 @@ class WBLaunchWorkflowPage extends Component { this.renderInput(it) ]) } />
+ +
+ +
) :
Loading...
}
);