diff --git a/conda/js/src/components/toolchain/ToolchainEditor.jsx b/conda/js/src/components/toolchain/ToolchainEditor.jsx index 4ccad1bb37d9ed125340de85ceb8c46b961be12e..991b6830f936022619066ef640918aeb46f1f08c 100644 --- a/conda/js/src/components/toolchain/ToolchainEditor.jsx +++ b/conda/js/src/components/toolchain/ToolchainEditor.jsx @@ -259,7 +259,7 @@ export class ToolchainEditor extends React.PureComponent<Props, State> { const toBlockNamesAndChannels = connectionData.map(c => [c.to.split('.')[0], c.channel]); const assignBlockChannels = (blocks: BlockType[]) => { return blocks.map(b => { - if(b.synchronized_channel !== '') + if(this.props.data.contents.connections.find(c => c.to.startsWith(`${ b.name }.`)) && b.synchronized_channel !== '') return b; const tbnc = toBlockNamesAndChannels.find(([n, c]) => n === b.name); if(!tbnc) @@ -465,11 +465,15 @@ export class ToolchainEditor extends React.PureComponent<Props, State> { if(newBlock === undefined){ newBlock = {}; if(set === 'blocks' || set === 'analyzers'){ - newBlock.inputs = []; - newBlock.synchronized_channel = Object.keys(this.props.data.contents.representation.channel_colors)[0]; + newBlock.inputs = [ + 'input', + ]; + newBlock.synchronized_channel = ''; } if(set === 'blocks' || set === 'datasets'){ - newBlock.outputs = []; + newBlock.outputs = [ + 'output', + ]; } } newBlock.name = blockName; diff --git a/conda/js/src/components/toolchain/ToolchainEditor.spec.jsx b/conda/js/src/components/toolchain/ToolchainEditor.spec.jsx index d08960344aa9d8230e4268ea5da5fafdb49119cf..6291a71a2ab4084e3e19a78ff3d32184146714dd 100644 --- a/conda/js/src/components/toolchain/ToolchainEditor.spec.jsx +++ b/conda/js/src/components/toolchain/ToolchainEditor.spec.jsx @@ -302,11 +302,13 @@ describe('<ToolchainEditor />', function() { wrapper.find('rect#block_dataset').simulate('click'); wrapper.update(); expect(wrapper.find('ToolchainModal').props().active).to.equal(true); - expect(wrapper.find('.modal').find('CacheInput').props().value).to.equal('dataset'); - wrapper.find('.modal').find('CacheInput').prop('onChange')( { target: { value: 'training_data' }}); + expect(wrapper.find('.modal').find('CacheInput#tcModalInitFocus').props().value).to.equal('dataset'); + wrapper.find('.modal').find('CacheInput#tcModalInitFocus').prop('onChange')( { target: { value: 'training_data' }}); wrapper.update(); + /* wrapper.find('.modal button.btn-secondary').simulate('click'); wrapper.update(); + */ wrapper.find('.modal button.btn-secondary').simulate('click'); wrapper.update(); wrapper.find('.modal CacheInput[value="output"]').prop('onChange')( { target: { value: 'measurements' }}); @@ -329,11 +331,13 @@ describe('<ToolchainEditor />', function() { wrapper.find('rect#block_dataset0').simulate('click'); wrapper.update(); expect(wrapper.find('ToolchainModal').props().active).to.equal(true); - expect(wrapper.find('.modal').find('CacheInput').props().value).to.equal('dataset0'); - wrapper.find('.modal').find('CacheInput').prop('onChange')( { target: { value: 'testing_data' }}); + expect(wrapper.find('.modal').find('CacheInput#tcModalInitFocus').props().value).to.equal('dataset0'); + wrapper.find('.modal').find('CacheInput#tcModalInitFocus').prop('onChange')( { target: { value: 'testing_data' }}); wrapper.update(); + /* wrapper.find('.modal button.btn-secondary').simulate('click'); wrapper.update(); + */ wrapper.find('.modal button.btn-secondary').simulate('click'); wrapper.update(); wrapper.find('.modal CacheInput[value="output"]').prop('onChange')( { target: { value: 'measurements' }}); @@ -355,15 +359,17 @@ describe('<ToolchainEditor />', function() { wrapper.find('rect#block_block').simulate('click'); wrapper.update(); expect(wrapper.find('ToolchainModal').props().active).to.equal(true); - expect(wrapper.find('.modal').find('CacheInput').props().value).to.equal('block'); - wrapper.find('.modal').find('CacheInput').prop('onChange')( { target: { value: 'training_alg' }}); + expect(wrapper.find('.modal').find('CacheInput#tcModalInitFocus').props().value).to.equal('block'); + wrapper.find('.modal').find('CacheInput#tcModalInitFocus').prop('onChange')( { target: { value: 'training_alg' }}); wrapper.update(); wrapper.find('.modal button.btn-secondary').at(0).simulate('click'); wrapper.update(); + /* wrapper.find('.modal button.btn-secondary').at(0).simulate('click'); wrapper.update(); wrapper.find('.modal button.btn-secondary').at(1).simulate('click'); wrapper.update(); + */ wrapper.find('.modal CacheInput[value="input"]').prop('onChange')( { target: { value: 'measurements' }}); wrapper.update(); wrapper.find('.modal CacheInput[value="input0"]').prop('onChange')( { target: { value: 'species' }}); @@ -382,22 +388,24 @@ describe('<ToolchainEditor />', function() { 'outputs': [ 'lda_machine' ], - 'synchronized_channel': 'training_data', + 'synchronized_channel': '', }); // testing_alg wrapper.find('rect#block_block0').simulate('click'); wrapper.update(); expect(wrapper.find('ToolchainModal').props().active).to.equal(true); - expect(wrapper.find('.modal').find('CacheInput').props().value).to.equal('block0'); - wrapper.find('.modal').find('CacheInput').prop('onChange')( { target: { value: 'testing_alg' }}); + expect(wrapper.find('.modal').find('CacheInput#tcModalInitFocus').props().value).to.equal('block0'); + wrapper.find('.modal').find('CacheInput#tcModalInitFocus').prop('onChange')( { target: { value: 'testing_alg' }}); wrapper.update(); wrapper.find('.modal button.btn-secondary').at(0).simulate('click'); wrapper.update(); + /* wrapper.find('.modal button.btn-secondary').at(0).simulate('click'); wrapper.update(); wrapper.find('.modal button.btn-secondary').at(1).simulate('click'); wrapper.update(); + */ wrapper.find('.modal CacheInput[value="input"]').prop('onChange')( { target: { value: 'measurements' }}); wrapper.update(); wrapper.find('.modal CacheInput[value="input0"]').prop('onChange')( { target: { value: 'lda_machine' }}); @@ -416,16 +424,18 @@ describe('<ToolchainEditor />', function() { 'outputs': [ 'scores' ], - 'synchronized_channel': 'training_data', + 'synchronized_channel': '', }); // analyzer wrapper.find('rect#block_analyzer').simulate('click'); wrapper.update(); expect(wrapper.find('ToolchainModal').props().active).to.equal(true); - expect(wrapper.find('.modal').find('CacheInput').props().value).to.equal('analyzer'); + expect(wrapper.find('.modal').find('CacheInput#tcModalInitFocus').props().value).to.equal('analyzer'); + /* wrapper.find('.modal button.btn-secondary').simulate('click'); wrapper.update(); + */ wrapper.find('.modal button.btn-secondary').simulate('click'); wrapper.update(); wrapper.find('.modal CacheInput[value="input"]').prop('onChange')( { target: { value: 'scores' }}); @@ -441,7 +451,7 @@ describe('<ToolchainEditor />', function() { 'scores', 'species' ], - 'synchronized_channel': 'training_data', + 'synchronized_channel': '', }); /* connect stuff via createConnections() */ @@ -449,16 +459,17 @@ describe('<ToolchainEditor />', function() { wrapper.instance().createConnections([{ from: 'training_data.measurements', to: 'training_alg.measurements', channel: 'training_data' }]); // channel: training_data wrapper.instance().createConnections([{ from: 'training_data.species', to: 'training_alg.species', channel: 'training_data' }]); - // channel: training_data - wrapper.instance().createConnections([{ from: 'training_alg.lda_machine', to: 'testing_alg.lda_machine', channel: 'training_data' }]); // channel: testing_data wrapper.instance().createConnections([{ from: 'testing_data.measurements', to: 'testing_alg.measurements', channel: 'testing_data' }]); // channel: training_data - wrapper.instance().createConnections([{ from: 'testing_alg.scores', to: 'analyzer.scores', channel: 'training_data' }]); + wrapper.instance().createConnections([{ from: 'training_alg.lda_machine', to: 'testing_alg.lda_machine', channel: 'training_data' }]); // channel: testing_data wrapper.instance().createConnections([{ from: 'testing_data.species', to: 'analyzer.species', channel: 'testing_data' }]); + // channel: testing_data + wrapper.instance().createConnections([{ from: 'testing_alg.scores', to: 'analyzer.scores', channel: 'testing_data' }]); /* fix channels */ + /* // testing_alg wrapper.find('rect#block_testing_alg').simulate('click'); wrapper.update(); @@ -467,6 +478,7 @@ describe('<ToolchainEditor />', function() { wrapper.update(); wrapper.find('button.close').simulate('click'); wrapper.update(); + */ expect(wrapper.props().data.contents.blocks[1]).to.deep.equal({ 'name': 'testing_alg', @@ -481,6 +493,7 @@ describe('<ToolchainEditor />', function() { }); // analyzer + /* wrapper.find('rect#block_analyzer').simulate('click'); wrapper.update(); expect(wrapper.find('ToolchainModal').props().active).to.equal(true); @@ -488,6 +501,7 @@ describe('<ToolchainEditor />', function() { wrapper.update(); wrapper.find('button.close').simulate('click'); wrapper.update(); + */ expect(wrapper.props().data.contents.analyzers[0]).to.deep.equal({ 'name': 'analyzer',