import { h, Component, createRef } from 'preact'; 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'; function parseDefinition(text) { let definition; try { definition = JSON.parse(text); } catch (_) { definition = jsyaml.load(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); this.browseDialogRef = createRef(); this.state.inputs = {}; } componentDidMount() { let { app, workflowUuid } = this.props; let { arvHost, arvToken } = app.state; let prom = makeArvadosRequest(arvHost, arvToken, '/arvados/v1/workflows/' + workflowUuid); prom = prom.then(xhr => this.setState({ 'workflow': xhr.response, 'workflowDefinition': parseDefinition(xhr.response.definition), 'defaultProcessName': xhr.response.name + ' ' + (new Date().toISOString()), 'defaultProcessDescription': xhr.response.description })); } 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 = true; // (inputSpec.type === 'File[]' || inputSpec.type === 'Directory[]' || // inputSpec.type.type === 'array'); if (!isFile && !isDirectory) return (
(this.state.inputs[inputSpec.id] = e.target.value) }>
{ inputSpec.doc }
); const button = ( ); 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 }
{ inputSpec.doc }
{ value ? isArray ? ( ) : ( ) : null }
); } render({ app, workflowUuid }, { workflow, workflowDefinition, projectUuid, processName, processDescription, defaultProcessName, defaultProcessDescription }) { return (
{ workflow ? (

Launch Workflow

{ projectUuid ? ( ) : null }
(a.id === '#main')).inputs.map(it => [ it.label || it.id, this.renderInput(it) ]) } />
) :
Loading...
}
); } } export default WBLaunchWorkflowPage;