Skip to content
Closed
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
11 changes: 9 additions & 2 deletions src/components/widget/layout/BaseModalLayout.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface StoryArgs {
hasHeader: boolean
hasContentFilter: boolean
hasHeaderRightArea: boolean
headerPadding: 'default' | 'symmetric'
cardCount: number
}

Expand All @@ -46,6 +47,11 @@ const meta: Meta<StoryArgs> = {
control: 'boolean',
description: 'Toggle header visibility'
},
headerPadding: {
control: 'select',
options: ['default', 'symmetric'],
description: 'Header bar spacing; symmetric matches the settings dialog'
},
hasContentFilter: {
control: 'boolean',
description: 'Toggle content filter visibility'
Expand Down Expand Up @@ -172,7 +178,7 @@ const createStoryTemplate = (args: StoryArgs) => ({
},
template: `
<div>
<BaseModalLayout v-if="!args.hasRightPanel" :content-title="args.contentTitle || 'Content Title'">
<BaseModalLayout v-if="!args.hasRightPanel" :content-title="args.contentTitle || 'Content Title'" :header-padding="args.headerPadding">
<!-- Left Panel Header Title -->
<template v-if="args.hasLeftPanel" #leftPanelHeaderTitle>
<i class="icon-[lucide--puzzle] size-4 text-neutral" />
Expand Down Expand Up @@ -294,7 +300,7 @@ const createStoryTemplate = (args: StoryArgs) => ({
</template>
</BaseModalLayout>

<BaseModalLayout v-else :content-title="args.contentTitle || 'Content Title'">
<BaseModalLayout v-else :content-title="args.contentTitle || 'Content Title'" :header-padding="args.headerPadding">
<!-- Same content but WITH right panel -->
<!-- Left Panel Header Title -->
<template v-if="args.hasLeftPanel" #leftPanelHeaderTitle>
Expand Down Expand Up @@ -421,6 +427,7 @@ const createStoryTemplate = (args: StoryArgs) => ({
export const Default: Story = {
render: (args: StoryArgs) => createStoryTemplate(args),
args: {
headerPadding: 'default',
contentTitle: 'Content Title',
hasLeftPanel: true,
hasRightPanel: true,
Expand Down
31 changes: 25 additions & 6 deletions src/components/widget/layout/BaseModalLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@
</nav>

<div class="flex flex-col overflow-hidden bg-base-background">
<header
v-if="$slots.header"
class="flex h-18 w-full items-center justify-between gap-2 px-6"
>
<div class="flex min-w-0 flex-1 gap-2">
<header v-if="$slots.header" :class="headerClass">
<div :class="headerContentClass">
<Button
v-if="!notMobile && !showLeftPanel"
size="lg"
Expand Down Expand Up @@ -78,7 +75,10 @@
>
{{ contentTitle }}
</h2>
<div :class="contentContainerClass">
<div
:class="contentContainerClass"
@scroll="$emit('contentScroll', $event)"
>
<slot name="content" />
</div>
</main>
Expand Down Expand Up @@ -155,25 +155,30 @@ const SIZE_CLASSES = {

type ModalSize = keyof typeof SIZE_CLASSES
type ContentPadding = 'default' | 'compact' | 'none'
type HeaderPadding = 'default' | 'symmetric'

const {
contentTitle,
rightPanelTitle,
size = 'lg',
leftPanelWidth = '14rem',
contentPadding = 'default',
headerPadding = 'default',
closeButtonVariant
} = defineProps<{
contentTitle: string
rightPanelTitle?: string
size?: ModalSize
leftPanelWidth?: string
contentPadding?: ContentPadding
headerPadding?: HeaderPadding
closeButtonVariant?: ButtonVariants['variant']
}>()

const sizeClasses = computed(() => SIZE_CLASSES[size])

defineEmits<{ contentScroll: [event: Event] }>()

const isRightPanelOpen = defineModel<boolean>('rightPanelOpen', {
default: false
})
Expand Down Expand Up @@ -205,6 +210,20 @@ const showLeftPanel = computed(() => {
return shouldShow
})

const headerClass = computed(() =>
cn(
'flex w-full items-center justify-between gap-2',
headerPadding === 'symmetric' ? 'min-h-11 p-6' : 'h-18 px-6'
)
)

const headerContentClass = computed(() =>
cn(
'flex min-w-0 flex-1 gap-2',
headerPadding === 'symmetric' && 'min-h-11 items-center'
)
)

const contentContainerClass = computed(() =>
cn(
'flex scrollbar-custom min-h-0 flex-1 flex-col overflow-y-auto',
Expand Down
6 changes: 5 additions & 1 deletion src/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -3307,10 +3307,11 @@
"pendingCount": "Pending ({count})"
},
"columns": {
"email": "Email",
"inviteDate": "Invite date",
"expiryDate": "Expiry date",
"role": "Role",
"creditsUsed": "Monthly credits"
"creditsUsed": "Credits used this month"
},
"actions": {
"copyInviteLink": "Copy invite link",
Expand All @@ -3333,10 +3334,13 @@
"upsellBannerReactivate": "To add more teammates, reactivate your plan.",
"upgradeToTeam": "Upgrade to Team",
"reactivateTeam": "Reactivate Team",
"totalMembersCount": "{count} of {maxSeats} total members.",
"needMoreMembers": "Need more members?",
"contactUs": "Contact us",
"noInvites": "No pending invites",
"noInvitesMatch": "No invites match \"{query}\"",
"noMembers": "No members",
"noMembersMatch": "No members match \"{query}\"",
"searchPlaceholder": "Search..."
},
"partnerNodes": {
Expand Down
193 changes: 178 additions & 15 deletions src/platform/settings/components/SettingDialog.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import { render, screen } from '@testing-library/vue'
import userEvent from '@testing-library/user-event'
import { fireEvent, render, screen } from '@testing-library/vue'
import { beforeEach, expect, it, vi } from 'vitest'
import { nextTick, ref } from 'vue'
import { createI18n } from 'vue-i18n'
import type { Ref } from 'vue'

import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore'
import type { NavGroupData } from '@/types/navTypes'

import SettingDialog from './SettingDialog.vue'

const settingUiMocks = vi.hoisted(() => ({
navGroups: null as unknown as Ref<NavGroupData[]>
navGroups: null as unknown as Ref<NavGroupData[]>,
defaultCategory: null as unknown as Ref<{
key: string
label: string
children: never[]
}>
}))
const searchMocks = vi.hoisted(() => ({
inSearch: null as unknown as Ref<boolean>,
Expand All @@ -21,13 +29,7 @@ vi.mock<unknown>(
import('@/platform/settings/composables/useSettingUI'),
() => ({
useSettingUI: () => ({
defaultCategory: {
value: {
key: 'workspace-allowlist',
label: 'Allowlist',
children: []
}
},
defaultCategory: settingUiMocks.defaultCategory,
settingCategories: { value: [] },
navGroups: settingUiMocks.navGroups,
findCategoryByKey: (key: string) =>
Expand Down Expand Up @@ -73,6 +75,34 @@ vi.mock(
)

beforeEach(() => {
const workspaceStore: ReturnType<typeof useTeamWorkspaceStore> & {
activeWorkspaceId: string | null
} = useTeamWorkspaceStore()
workspaceStore.activeWorkspaceId = 'ws-acme'
workspaceStore.$patch({
workspaces: [
{
id: 'ws-acme',
name: 'Acme Team',
type: 'team',
role: 'owner',
created_at: '2026-01-01T00:00:00Z',
joined_at: '2026-01-01T00:00:00Z',
isSubscribed: true,
subscriptionPlan: null,
subscriptionTier: null,
members: [],
pendingInvites: [],
membersLoaded: true,
pendingInvitesLoaded: true
}
]
})
settingUiMocks.defaultCategory = ref({
key: 'workspace-allowlist',
label: 'Allowlist',
children: []
})
settingUiMocks.navGroups = ref([
{
title: 'Workspace',
Expand All @@ -96,22 +126,51 @@ beforeEach(() => {
searchMocks.searchResultsCategories = ref(new Set<string>())
})

it('falls back when the active navigation item becomes unavailable', async () => {
render(SettingDialog, {
function renderDialog() {
return render(SettingDialog, {
props: { onClose: vi.fn() },
global: {
mocks: { $t: (key: string) => key },
plugins: [
createI18n({
legacy: false,
locale: 'en',
messages: { en: {} },
missingWarn: false,
fallbackWarn: false
})
],
stubs: {
BaseModalLayout: {
template:
'<div><slot name="leftPanel" /><slot name="content" /></div>'
emits: ['content-scroll'],
template: `
<div>
<slot name="leftPanel" />
<slot name="header" />
<div
data-testid="panel-scroller"
@scroll="$emit('content-scroll', $event)"
>
<slot name="content" />
</div>
</div>`
},
NavItem: { template: '<button><slot /></button>' },
NavTitle: true,
SearchInput: true
SearchInput: true,
WorkspaceProfilePic: { template: '<div data-testid="ws-pic" />' }
}
}
})
}

async function scrollPanelTo(scrollTop: number) {
const scroller = screen.getByTestId('panel-scroller')
scroller.scrollTop = scrollTop
await fireEvent.scroll(scroller)
}

it('falls back when the active navigation item becomes unavailable', async () => {
renderDialog()
expect(
await screen.findByText('workspace-allowlist panel')
).toBeInTheDocument()
Expand All @@ -135,3 +194,107 @@ it('falls back when the active navigation item becomes unavailable', async () =>
screen.queryByText('workspace-allowlist panel')
).not.toBeInTheDocument()
})

it('shows the workspace identity in the dialog header on workspace sections', async () => {
renderDialog()

expect(
await screen.findByRole('heading', { name: 'Acme Team' })
).toBeInTheDocument()
expect(screen.getByTestId('ws-pic')).toBeInTheDocument()
})

it('leaves the dialog header empty outside workspace sections', async () => {
settingUiMocks.defaultCategory.value = {
key: 'comfy',
label: 'Comfy',
children: []
}
settingUiMocks.navGroups.value = [
{
title: 'Comfy',
items: [{ id: 'comfy', label: 'Comfy', icon: 'icon-[lucide--cog]' }]
}
]

renderDialog()

await nextTick()
expect(screen.queryByTestId('ws-pic')).not.toBeInTheDocument()
expect(
screen.queryByRole('heading', { name: 'Acme Team' })
).not.toBeInTheDocument()
})

it('collapses the header once the panel scrolls and restores it only at top', async () => {
renderDialog()
expect(
await screen.findByRole('heading', { name: 'Acme Team' })
).toBeInTheDocument()

await scrollPanelTo(40)
expect(
screen.queryByRole('heading', { name: 'Acme Team' })
).not.toBeInTheDocument()
expect(screen.queryByTestId('ws-pic')).not.toBeInTheDocument()

// Between the expand and collapse thresholds the header stays put, so a
// marginally-scrollable panel cannot flip-flop it.
await scrollPanelTo(10)
expect(
screen.queryByRole('heading', { name: 'Acme Team' })
).not.toBeInTheDocument()

await scrollPanelTo(0)
expect(
await screen.findByRole('heading', { name: 'Acme Team' })
).toBeInTheDocument()
expect(screen.getByTestId('ws-pic')).toBeInTheDocument()
})

it('collapses the header when a nested panel scroller scrolls', async () => {
renderDialog()
expect(
await screen.findByRole('heading', { name: 'Acme Team' })
).toBeInTheDocument()

// Workspace panels scroll internally (their own overflow container), so the
// collapse must catch the scroll in the capture phase on the content
// wrapper, not just the layout-level scroller.
const scrollerHost = screen.getByTestId('panel-scroller')
// eslint-disable-next-line testing-library/no-node-access -- the capture wrapper is an unlabeled layout div; no Testing Library query can address it
const wrapper = scrollerHost.firstElementChild as HTMLElement
const nested = document.createElement('div')
wrapper.appendChild(nested)
nested.scrollTop = 40
await fireEvent.scroll(nested)

expect(
screen.queryByRole('heading', { name: 'Acme Team' })
).not.toBeInTheDocument()

nested.scrollTop = 0
await fireEvent.scroll(nested)
expect(
await screen.findByRole('heading', { name: 'Acme Team' })
).toBeInTheDocument()
})

it('restores the collapsed header when switching sections', async () => {
renderDialog()
expect(
await screen.findByRole('heading', { name: 'Acme Team' })
).toBeInTheDocument()

await scrollPanelTo(40)
expect(
screen.queryByRole('heading', { name: 'Acme Team' })
).not.toBeInTheDocument()

await userEvent.click(screen.getByRole('button', { name: 'Workspace' }))

expect(await screen.findByText('workspace panel')).toBeInTheDocument()
expect(
await screen.findByRole('heading', { name: 'Acme Team' })
).toBeInTheDocument()
})
Loading
Loading