Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open Dashboard and Editor links in new tab by default #4923

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontend/src/composables/NavigationHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { useRouter } from 'vue-router'
export function useNavigationHelper () {
const _router = useRouter()

const openInANewTab = (href) => {
const openInANewTab = (href, target = '_blank') => {
return new Promise(resolve => {
window.open(href, '_blank')
window.open(href, target)
resolve()
})
}
Expand Down
18 changes: 13 additions & 5 deletions frontend/src/pages/instance/components/DashboardLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
v-if="!hidden"
kind="secondary"
data-action="open-dashboard"
:to="dashboardURL"
:target="target"
:disabled="buttonDisabled"
class="whitespace-nowrap"
@click.stop.prevent
@mouseup.stop.prevent
@click="openDashboard"
>
<template v-if="showText" #icon-left>
<ChartPieIcon />
Expand All @@ -23,11 +20,14 @@
</template>

<script>

import { ChartPieIcon } from '@heroicons/vue/outline'

import { useNavigationHelper } from '../../../composables/NavigationHelper.js'

import { removeSlashes } from '../../../composables/String.js'

const { openInANewTab } = useNavigationHelper()

export default {
name: 'DashboardLink',
components: { ChartPieIcon },
Expand Down Expand Up @@ -67,6 +67,14 @@ export default {
target () {
return '_db2_' + (this.instance?.id || '')
}
},
methods: {
openDashboard () {
if (this.buttonDisabled) {
return
}
openInANewTab(this.dashboardURL, this.target)
}
}
}
</script>
16 changes: 5 additions & 11 deletions frontend/src/pages/instance/components/EditorLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
:disabled="buttonDisabled"
class="whitespace-nowrap"
:emit-instead-of-navigate="true"
@select="openEditor"
>
<template v-if="showText" #icon-left>
<ProjectIcon />
Expand Down Expand Up @@ -96,16 +95,11 @@ export default {
return false
}

switch (true) {
case !this.isImmersiveEditor:
return this.openInANewTab(this.editorURL)
case evt.ctrlKey || evt.metaKey || evt.button === 1:
// On Mac Keyboard, ⌘ + click opens in new tab (⌘ is `metaKey`)
// Otherwise Ctrl + click opens in new tab (Ctrl is `ctrlKey`)
// Middle mouse button click opens in a new tab (button === 1)
return this.openInANewTab(this.url)
default:
return this.$router.push(this.url)
const target = `_${this.instance.id}`
if (!this.isImmersiveEditor) {
return this.openInANewTab(this.editorURL, target)
} else {
return this.openInANewTab(this.url, target)
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions test/e2e/frontend/cypress/tests/instances/editor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ describe('FlowForge - Instance editor', () => {
.children()
.should('exist')

cy.window().then((win) => {
cy.stub(win, 'open').as('windowOpen')
})

cy.get('[data-action="open-editor"]').click()

cy.get('[data-el="editor-iframe"]').should('exist')
cy.get('[data-el="tabs-drawer"]').should('exist')
cy.get('@windowOpen').should('be.calledWithMatch', /\/instance\/.*\/editor/)
})

it('has working drawer navigation tabs', () => {
Expand Down
Loading