Skip to content

Commit

Permalink
workflow: open new tabs on top (#1177)
Browse files Browse the repository at this point in the history
When a new tab (i.e. Cylc view) is opened it should be activated (i.e. put on top).
  • Loading branch information
oliver-sanders authored Dec 22, 2022
1 parent e9e1d8e commit 2d97cd5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Tree view: Task messages are now shown along with outputs.
[#1124](https://github.com/cylc/cylc-ui/pull/1075) - Table view: More options
for number of tasks per page.

[#1177](https://github.com/cylc/cylc-ui/pull/1177) -
New tabs now open on top.

### Fixes

[#1108](https://github.com/cylc/cylc-ui/pull/1108) -
Expand Down
7 changes: 5 additions & 2 deletions src/components/cylc/workflow/Lumino.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,19 @@ export default {
* Create a widget.
*
*/
addWidget (id, name) {
addWidget (id, name, onTop = true) {
this.widgets.push(id)
const luminoWidget = new LuminoWidget(id, name, /* closable */ true)
this.dock.addWidget(luminoWidget)
this.dock.addWidget(luminoWidget, { mode: 'tab-after' })
// give time for Lumino's widget DOM element to be created
this.$nextTick(() => {
document.getElementById(id)
.addEventListener('lumino:activated', this.onWidgetActivated)
document.getElementById(id)
.addEventListener('lumino:deleted', this.onWidgetDeleted)
if (onTop) {
luminoWidget.parent.selectWidget(luminoWidget)
}
})
},
Expand Down
22 changes: 20 additions & 2 deletions tests/e2e/specs/workflow.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,28 @@ describe('Workflow view and component/widget', () => {

it('Should be able to add two widgets of different types', () => {
cy.visit('/#/workflows/one')
cy.get('.lm-TabBar-tabLabel').should('have.length', 1)

// there should be one widget open by default (tree)
cy.get('.lm-TabBar-tabLabel')
// there should be a tab representing the widget
.should('have.length', 1)
// the tab should contain the name of the widget
.contains('tree')
// the tab should be active (that is to say on top)
.parent()
.should('have.class', 'lm-mod-current')

cy.get('a.add-view').click()
cy.get('#toolbar-add-Table-view').click()
cy.get('.lm-TabBar-tabLabel').should('have.length', 2)
cy.get('.lm-TabBar-tabLabel')
// there should be two tabs (tree + table)
.should('have.length', 2)
// the new tab should be last
.last()
.contains('table')
// the new tab should be active (that is to say on top)
.parent()
.should('have.class', 'lm-mod-current')
})

it('Should remove widgets added successfully', () => {
Expand Down

0 comments on commit 2d97cd5

Please sign in to comment.