diff --git a/kbase-extension/static/kbase/js/common/cellComponents/tabs/infoTab.js b/kbase-extension/static/kbase/js/common/cellComponents/tabs/infoTab.js index e9bf90ec7b..1e7d7e55b2 100644 --- a/kbase-extension/static/kbase/js/common/cellComponents/tabs/infoTab.js +++ b/kbase-extension/static/kbase/js/common/cellComponents/tabs/infoTab.js @@ -4,8 +4,6 @@ define(['domPurify', 'common/format', 'common/html', 'util/string'], ( html, string ) => { - 'use strict'; - // Note - would destructure in the arguments, but that would require a change to eslint rules. const { sanitize } = DOMPurify; @@ -29,7 +27,11 @@ define(['domPurify', 'common/format', 'common/html', 'util/string'], ( const parameterArray = appSpec.parameters.map((param) => { const textOptions = param.text_options; let types = null; - if (textOptions && Array.isArray(textOptions.valid_ws_types)) { + if ( + textOptions && + Array.isArray(textOptions.valid_ws_types) && + textOptions.valid_ws_types.indexOf('*') === -1 + ) { const typesArray = textOptions.valid_ws_types.map((type) => { return a( { @@ -220,12 +222,12 @@ define(['domPurify', 'common/format', 'common/html', 'util/string'], ( ), appTag ? span( - { - class: `${cssBaseClass}__tag label label-primary`, - title: `${appTag} version of the app`, - }, - appTag - ) + { + class: `${cssBaseClass}__tag label label-primary`, + title: `${appTag} version of the app`, + }, + appTag + ) : '', ] ), diff --git a/kbase-extension/static/kbase/js/widgets/narrative_core/kbaseNarrativeDownloadPanel.js b/kbase-extension/static/kbase/js/widgets/narrative_core/kbaseNarrativeDownloadPanel.js index 182c01d6e1..a406ffa9b1 100644 --- a/kbase-extension/static/kbase/js/widgets/narrative_core/kbaseNarrativeDownloadPanel.js +++ b/kbase-extension/static/kbase/js/widgets/narrative_core/kbaseNarrativeDownloadPanel.js @@ -15,6 +15,7 @@ define([ ], (Promise, KBWidget, $, Config, APIUtil, kbase_client_api, GenericClient, Jupyter) => { const STAGING_EXPORT_APP = 'kb_staging_exporter/export_to_staging'; const JSON_EXPORT_APP = 'kb_staging_exporter/export_json_to_staging'; + const CSS_BASE = 'kb-download-panel'; return KBWidget({ name: 'kbaseNarrativeDownloadPanel', @@ -92,19 +93,19 @@ define([ }, renderStructure: function () { - const $container = $('
').addClass('kb-download-panel'); - const $label = $('
').addClass('kb-download-panel__label').append('Export as:'); - const $buttons = $('
').addClass('kb-download-panel__buttons'); + const $container = $('
').addClass(CSS_BASE); + const $label = $('
').addClass(`${CSS_BASE}__label`).append('Export as:'); + const $buttons = $('
').addClass(`${CSS_BASE}__buttons`); $container.append($label).append($buttons); this.$elem.append($container); - this.$statusDiv = $('
').addClass('kb-download-panel__status'); + this.$statusDiv = $('
').addClass(`${CSS_BASE}__status`); this.$elem.append(this.$statusDiv.hide()); }, renderDownloadButtons: function () { const downloaders = this.prepareDownloaders(this.type); - const $btnPanel = this.$elem.find('.kb-download-panel__buttons'); + const $btnPanel = this.$elem.find(`.${CSS_BASE}__buttons`); downloaders.forEach((dlInfo) => { if (dlInfo.name.toLocaleLowerCase() === 'staging') { $btnPanel.append( @@ -259,7 +260,7 @@ define([ }, showMessage: function (msg) { - this.$statusDiv.empty().append(msg); + this.$statusDiv.empty().append(msg).show(); }, showError: function (error) { @@ -272,11 +273,14 @@ define([ } // error is final state, so reactivate! this.$elem.find('.kb-data-list-btn').prop('disabled', false); - this.$statusDiv.empty().append( - $('') - .addClass('kb-download-panel__status_error') - .append('Error: ' + error) - ); + this.$statusDiv + .empty() + .append( + $('') + .addClass(`${CSS_BASE}__status_error`) + .append('Error: ' + error) + ) + .show(); }, stopTimer: function () { diff --git a/test/unit/spec/common/cellComponents/tabs/infoTab-Spec.js b/test/unit/spec/common/cellComponents/tabs/infoTab-Spec.js index 27e282fed6..3c316e5a55 100644 --- a/test/unit/spec/common/cellComponents/tabs/infoTab-Spec.js +++ b/test/unit/spec/common/cellComponents/tabs/infoTab-Spec.js @@ -3,8 +3,6 @@ define(['common/cellComponents/tabs/infoTab', 'common/props', 'testUtil'], ( Props, TestUtil ) => { - 'use strict'; - describe('The App Info Tab module', () => { it('loads', () => { expect(InfoTab).not.toBe(null); @@ -86,6 +84,13 @@ define(['common/cellComponents/tabs/infoTab', 'common/props', 'testUtil'], ( ui_name: 'Adapters', id: 'adapters', }, + { + text_options: { + valid_ws_types: ['*', 'SomeModule.SomeType'], + }, + ui_name: 'Any old object', + id: 'any_old_object', + }, ], }, tag: APP.ONE.TAG, @@ -305,6 +310,19 @@ define(['common/cellComponents/tabs/infoTab', 'common/props', 'testUtil'], ( ).toBe(appData[APP.ONE.ID].app.spec.parameters[1].ui_name); }); + it('renders no links for a parameter than can be a wildcard type', () => { + const paramThree = container.querySelectorAll( + `.${cssBaseClass}__list_item--params` + )[2]; + expect( + paramThree.querySelector(`.${cssBaseClass}__param--id`).textContent + ).toBe(appData[APP.ONE.ID].app.spec.parameters[2].id); + expect( + paramThree.querySelector(`.${cssBaseClass}__param--ui-name`).textContent + ).toBe(appData[APP.ONE.ID].app.spec.parameters[2].ui_name); + expect(paramThree.querySelectorAll('a').length).toBe(0); + }); + it('renders run stats correctly', () => { if (isMulti) { // no run stats in the multi-app version diff --git a/test/unit/spec/narrative_core/kbaseNarrativeDownloadPanel-spec.js b/test/unit/spec/narrative_core/kbaseNarrativeDownloadPanel-spec.js index cc97690f65..8c0f1f7bd6 100644 --- a/test/unit/spec/narrative_core/kbaseNarrativeDownloadPanel-spec.js +++ b/test/unit/spec/narrative_core/kbaseNarrativeDownloadPanel-spec.js @@ -8,6 +8,7 @@ define([ ], ($, kbaseNarrativeDownloadPanel, Jupyter, Mocks, TestUtil, Config) => { const JSON_EXPORT_APP = 'kb_staging_exporter/export_json_to_staging'; const STAGING_EXPORT_APP = 'kb_staging_exporter/export_to_staging'; + const CSS_BASE = 'kb-download-panel'; describe('The kbaseNarrativeDownloadPanel widget', () => { let $div = null; @@ -124,7 +125,7 @@ define([ }); await initDownloadPanel(null, {}); - const $status = $div.find('.kb-download-status'); + const $status = $div.find(`.${CSS_BASE}__status`); expect($status.text()).toContain('Error: an error happened'); }); @@ -236,14 +237,14 @@ define([ await TestUtil.waitForElementState( $div[0], () => { - const text = $div[0].querySelector('.kb-download-status').textContent || ''; + const text = $div[0].querySelector(`.${CSS_BASE}__status`).textContent || ''; return text.endsWith(errorMsg); }, () => { exportBtns[0].click(); } ); - expect($div[0].querySelector('.kb-download-status').textContent).toContain(errorMsg); + expect($div[0].querySelector(`.${CSS_BASE}__status`).textContent).toContain(errorMsg); expect(widget.timer).toBeNull(); }); @@ -323,22 +324,22 @@ define([ await TestUtil.waitForElementState( $div[0], () => { - const text = $div[0].querySelector('.kb-download-status').textContent || ''; + const text = $div[0].querySelector(`.${CSS_BASE}__status`).textContent || ''; return text.endsWith('some log'); }, () => { exportBtns[0].click(); } ); - expect($div[0].querySelector('.kb-download-status').textContent).toContain('some log'); + expect($div[0].querySelector(`.${CSS_BASE}__status`).textContent).toContain('some log'); expect(widget.timer).not.toBeNull(); await TestUtil.waitForElementState($div[0], () => { - const text = $div[0].querySelector('.kb-download-status').textContent; + const text = $div[0].querySelector(`.${CSS_BASE}__status`).textContent; return text === ''; }); - expect($div[0].querySelector('.kb-download-status').textContent).toBe(''); + expect($div[0].querySelector(`.${CSS_BASE}__status`).textContent).toBe(''); expect(widget.timer).toBeNull(); }); @@ -383,14 +384,14 @@ define([ await TestUtil.waitForElementState( $div[0], () => { - const text = $div[0].querySelector('.kb-download-status').textContent || ''; + const text = $div[0].querySelector(`.${CSS_BASE}__status`).textContent || ''; return text.endsWith(errorMsg); }, () => { exportBtns[0].click(); } ); - expect($div[0].querySelector('.kb-download-status').textContent).toContain(errorMsg); + expect($div[0].querySelector(`.${CSS_BASE}__status`).textContent).toContain(errorMsg); expect(widget.timer).toBeNull(); });