Files
Jonathan Adelineandpeter_baserow a8bf3b73ae feat: redesign app sidebar (#6798)
* feat: redesign sidebar workspace navigation

* feat: redesign the sidebar footer and account menu

Match the account menu to the sidebar prototype and reuse the admin
navigation in a submenu. Keep Add new above the footer while the
application list scrolls.

* fix: show the sortable indicator only when dragging

* feat: refine workspace sidebar application navigation

* feat: reorganize workspace sidebar shortcuts

* fix: isolate workspace sidebar menus and actions

* fix: cancel sortable drops on hidden lists

* fix(enterprise): allow retrying Direct support

* feat: simplify the workspace overview header

* fix: prevent horizontal overflow around the sidebar

Constrain animated tree groups to the width of the sidebar so long labels truncate. On narrow screens, let the sidebar expand over the content instead of reducing the usable page width.

* fix: fit workspace cards and creation menus on mobile

* test: keep the current table selected after reload

* fix: undo and redo edits across expanded sidebar applications

* fix: keep sidebar groups out of the tab order

* fix: highlight the active database in the tables tour

* feat: label workspace integrations in the settings menu

* fix: keep the workspace sidebar and guided tour usable on phones

* fix: undo sidebar row imports in the destination database

* fix: keep the guided tour highlight on the current step

* fix: show an empty state in the workspace picker

* fix: confirm workspace deletion before moving it to trash

* feat: open registered workspace settings tabs from the sidebar

* fix: keep the sidebar logo the same size across workspaces

---------

Co-authored-by: peter_baserow <peter@baserow.io>
2026-11-23 20:42:20 +04:00

218 lines
5.7 KiB
Vue

<template>
<Context
ref="context"
class="sidebar-account-menu"
tabindex="-1"
max-height-if-outside-viewport
overflow-scroll
@shown="onShow"
@hidden="onHidden"
@keydown.esc="onEscape"
>
<div class="sidebar__user">
<div class="sidebar__user-email">{{ email }}</div>
<ul v-sidebar-tab-order class="context__menu">
<li class="context__menu-item">
<button
ref="settingsTrigger"
type="button"
class="context__menu-item-link"
@click="settingsModal.show()"
>
<i class="context__menu-item-icon iconoir-user-circle"></i>
{{ $t('sidebar.settings') }}
</button>
<SettingsModal ref="settingsModal"></SettingsModal>
</li>
<component
:is="component"
v-for="(component, index) in accountComponents"
:key="'sidebarUserContextComponent' + index"
@hide="context.hide()"
></component>
<li v-if="isStaff" class="context__menu-item">
<button
ref="adminTrigger"
type="button"
class="context__menu-item-link"
:aria-expanded="adminMenuOpen"
@click="toggleAdminMenu"
>
<i class="context__menu-item-icon iconoir-settings"></i>
{{ $t('sidebar.adminTools') }}
<i
class="sidebar-account-menu__chevron iconoir-nav-arrow-right"
aria-hidden="true"
></i>
</button>
</li>
<li v-if="anyGuidedTourActive" class="context__menu-item">
<button
type="button"
class="context__menu-item-link"
@click="replayGuidedTour()"
>
<i class="context__menu-item-icon iconoir-help-circle"></i>
{{ $t('sidebar.replayGuidedTour') }}
</button>
</li>
<li class="context__menu-item context__menu-item--with-separator">
<button
type="button"
class="context__menu-item-link"
:class="{ 'context__menu-item-link--loading': logoffLoading }"
@click="logoff()"
>
<i class="context__menu-item-icon iconoir-log-out"></i>
{{ $t('sidebar.logoff') }}
</button>
</li>
</ul>
<Context
v-if="isStaff"
ref="adminContext"
class="sidebar-admin-menu"
tabindex="-1"
:horizontal-viewport-margin="8"
max-height-if-outside-viewport
overflow-scroll
@shown="onAdminMenuShown"
@hidden="adminMenuOpen = false"
@keydown.esc.stop.prevent="closeAdminMenu"
>
<SidebarAdmin
v-sidebar-tab-order
show-section-separators
@activate="onAdminActivate"
/>
</Context>
</div>
</Context>
</template>
<script setup>
import { computed, nextTick, ref } from 'vue'
import { useStore } from 'vuex'
import { useNuxtApp, useRoute, useRouter } from '#imports'
import vSidebarTabOrder from '@baserow/modules/core/directives/sidebarTabOrder'
import SidebarAdmin from '@baserow/modules/core/components/sidebar/SidebarAdmin.vue'
import SettingsModal from '@baserow/modules/core/components/settings/SettingsModal.vue'
import { logoutAndRedirectToLogin } from '@baserow/modules/core/utils/auth'
const props = defineProps({
selectedWorkspace: {
type: Object,
required: true,
},
})
const emit = defineEmits(['hidden', 'shown', 'toggle-admin'])
const store = useStore()
const { $registry } = useNuxtApp()
const route = useRoute()
const router = useRouter()
const context = ref(null)
const adminContext = ref(null)
const adminTrigger = ref(null)
const settingsTrigger = ref(null)
const settingsModal = ref(null)
const adminMenuOpen = ref(false)
const logoffLoading = ref(false)
const email = computed(() => store.getters['auth/getUsername'])
const isStaff = computed(() => store.getters['auth/isStaff'])
const accountComponents = computed(() =>
Object.values($registry.getAll('plugin'))
.flatMap((plugin) =>
plugin.getUserContextComponents(props.selectedWorkspace)
)
.filter((component) => component !== null)
)
const anyGuidedTourActive = computed(() =>
Object.values($registry.getAll('guidedTour')).some((tour) =>
tour.isActive(route)
)
)
async function onShow() {
emit('shown')
await nextTick()
if (context.value?.isOpen()) {
settingsTrigger.value?.focus()
}
}
function onHidden() {
if (adminContext.value?.isOpen()) {
adminContext.value.hide()
}
emit('hidden')
}
function onEscape(event) {
if (!event.defaultPrevented) {
event.preventDefault()
event.stopPropagation()
const opener = context.value.opener
context.value.hide()
opener?.focus()
}
}
function toggleAdminMenu(event) {
const trigger = event.currentTarget
adminContext.value.toggle(
trigger,
'over-top',
'left',
0,
trigger.offsetWidth + 12
)
}
async function onAdminMenuShown() {
if (!context.value?.isOpen() || !adminContext.value?.isOpen()) {
return
}
adminMenuOpen.value = true
await nextTick()
if (adminMenuOpen.value) {
adminContext.value
?.getTeleportedElement()
?.querySelector('a[href]')
?.focus()
}
}
function closeAdminMenu() {
adminContext.value.hide()
adminTrigger.value?.focus()
}
function onAdminActivate() {
context.value.hide()
emit('toggle-admin', true)
}
async function replayGuidedTour() {
context.value.hide()
await nextTick()
await store.dispatch('guidedTour/forceStart')
}
async function logoff() {
logoffLoading.value = true
await logoutAndRedirectToLogin(router, store, false, false, true)
}
defineExpose({ toggle: (...args) => context.value.toggle(...args) })
</script>