style(client): satisfy panel lint rules
This commit is contained in:
1 parent
9736136d95
commit
092d16d7ab
6 files changed
+22
-17
No files matched your search
@@ -16,7 +16,7 @@ export type DocumentTitleProps = Pick<PropsRuntime<'root'>, 'useSessions' | 'use
|
||||
*/
|
||||
export function DocumentTitle({ useSessions, usePanelInfo, productTitle }: DocumentTitleProps): null {
|
||||
const showSessionTitle = usePanelInfo(info => info.activePanelId === null)
|
||||
const title = useSessions(state => {
|
||||
const title = useSessions((state) => {
|
||||
const current = state.current
|
||||
return !showSessionTitle || current === undefined ? undefined : state.byId[current]?.title
|
||||
})
|
||||
|
||||
@@ -23,7 +23,7 @@ beforeEach(() => {
|
||||
originalBodyStyle = document.body.getAttribute('style')
|
||||
originalDarkTheme = document.body.getAttribute('data-ds-dark-theme')
|
||||
originalThemeMetadata = [...document.head.querySelectorAll('meta[name="theme-color"]')]
|
||||
originalThemeMetadata.forEach(node => { node.remove() })
|
||||
originalThemeMetadata.forEach((node) => { node.remove() })
|
||||
vi.stubGlobal('innerWidth', 1920)
|
||||
})
|
||||
|
||||
@@ -35,7 +35,7 @@ afterEach(async () => {
|
||||
restoreAttribute(document.documentElement, 'style', originalRootStyle)
|
||||
restoreAttribute(document.body, 'style', originalBodyStyle)
|
||||
restoreAttribute(document.body, 'data-ds-dark-theme', originalDarkTheme)
|
||||
document.head.querySelectorAll('meta[name="theme-color"]').forEach(node => { node.remove() })
|
||||
document.head.querySelectorAll('meta[name="theme-color"]').forEach((node) => { node.remove() })
|
||||
document.head.append(...originalThemeMetadata)
|
||||
vi.unstubAllGlobals()
|
||||
}
|
||||
@@ -65,7 +65,7 @@ async function bench() {
|
||||
await slotsFiber.await()
|
||||
const slots = ctx.get('slots') as SlotRegistry
|
||||
let host: SlotRendererHost | undefined
|
||||
slots.install({ renderRoot: value => { host = value; return null } })
|
||||
slots.install({ renderRoot: (value) => { host = value; return null } })
|
||||
const rendererHost = (): SlotRendererHost => {
|
||||
slots.renderSlot('root', {})
|
||||
if (host === undefined) throw new Error('the root renderer did not receive its host')
|
||||
|
||||
@@ -38,11 +38,11 @@ describe('DocumentTitle', () => {
|
||||
document.title = 'stale title'
|
||||
const mounted = render(<DocumentTitle {...props} productTitle="DeepSeek Harness" />)
|
||||
expect(document.title).toBe('DeepSeek Harness')
|
||||
act(() => { sessions.update(state => { state.byId[sessionId]!.title = 'First title' }) })
|
||||
act(() => { sessions.update((state) => { state.byId[sessionId]!.title = 'First title' }) })
|
||||
expect(document.title).toBe('First title — DeepSeek Harness')
|
||||
act(() => { sessions.update(state => { state.byId[sessionId]!.title = 'Revised title' }) })
|
||||
act(() => { sessions.update((state) => { state.byId[sessionId]!.title = 'Revised title' }) })
|
||||
expect(document.title).toBe('Revised title — DeepSeek Harness')
|
||||
act(() => { sessions.update(state => { state.current = undefined }) })
|
||||
act(() => { sessions.update((state) => { state.current = undefined }) })
|
||||
expect(document.title).toBe('DeepSeek Harness')
|
||||
mounted.unmount()
|
||||
expect(document.title).toBe('DeepSeek Harness')
|
||||
@@ -50,7 +50,7 @@ describe('DocumentTitle', () => {
|
||||
|
||||
it('uses the localized product title supplied by the frame', () => {
|
||||
const { sessionId, sessions, props } = titleSources()
|
||||
sessions.update(state => { state.byId[sessionId]!.title = 'First title' })
|
||||
sessions.update((state) => { state.byId[sessionId]!.title = 'First title' })
|
||||
const mounted = render(<DocumentTitle {...props} productTitle="DSH Local Build" />)
|
||||
expect(document.title).toBe('First title — DSH Local Build')
|
||||
mounted.unmount()
|
||||
@@ -59,12 +59,12 @@ describe('DocumentTitle', () => {
|
||||
|
||||
it('keeps the product title across global panels and restores the latest Session title on return', () => {
|
||||
const { sessionId, sessions, panelInfo, props } = titleSources()
|
||||
sessions.update(state => { state.byId[sessionId]!.title = 'Session title' })
|
||||
sessions.update((state) => { state.byId[sessionId]!.title = 'Session title' })
|
||||
render(<DocumentTitle {...props} productTitle="Product" />)
|
||||
expect(document.title).toBe('Session title — Product')
|
||||
act(() => { panelInfo.set({ activePanelId: 'panel-a' as MainPanelId }) })
|
||||
expect(document.title).toBe('Product')
|
||||
act(() => { sessions.update(state => { state.byId[sessionId]!.title = 'Updated title' }) })
|
||||
act(() => { sessions.update((state) => { state.byId[sessionId]!.title = 'Updated title' }) })
|
||||
expect(document.title).toBe('Product')
|
||||
act(() => { panelInfo.set({ activePanelId: 'panel-b' as MainPanelId }) })
|
||||
expect(document.title).toBe('Product')
|
||||
@@ -75,7 +75,7 @@ describe('DocumentTitle', () => {
|
||||
|
||||
it('uses the product title when the current Session row is not available', () => {
|
||||
const { sessions, props } = titleSources()
|
||||
sessions.update(state => { state.byId = {}; state.ids = [] })
|
||||
sessions.update((state) => { state.byId = {}; state.ids = [] })
|
||||
render(<DocumentTitle {...props} productTitle="Product" />)
|
||||
expect(document.title).toBe('Product')
|
||||
})
|
||||
|
||||
@@ -52,7 +52,7 @@ export function apply(ctx: ClientContext): void {
|
||||
}).sort((a, b) => a.order - b.order)
|
||||
const previous = panels.getSnapshot()
|
||||
if (previous.length === next.length && previous.every((panel, index) => {
|
||||
const candidate = next[index]!
|
||||
const candidate = next[index] as SidebarPanelMetadata
|
||||
return panel.id === candidate.id && panel.order === candidate.order && panel.label === candidate.label
|
||||
})) return
|
||||
panels.set(next)
|
||||
|
||||
@@ -41,7 +41,8 @@ function mountColumn(): { column: HTMLElement; quiet: () => boolean } {
|
||||
<SidebarRoot
|
||||
collapsed={false} width={300}
|
||||
useSessions={neverHook} useSessionPendingInteraction={useSessionPendingInteraction}
|
||||
usePanelInfo={usePanelInfo} selectPanel={() => {}} usePanels={selector => selector([])} useResource={useResource} useWorkspaces={neverHook}
|
||||
usePanelInfo={usePanelInfo} selectPanel={() => {}} usePanels={selector => selector([])}
|
||||
useResource={useResource} useWorkspaces={neverHook}
|
||||
startSession={vi.fn()} toggleSidebar={vi.fn()} t={t}
|
||||
renderSlot={((_key: string, owner: SidebarSectionOwnerProps) =>
|
||||
<div data-testid="region" data-wide={owner.wide} />) as SidebarRootComponentProps['renderSlot']}
|
||||
|
||||
@@ -46,7 +46,8 @@ function mountShell({ collapsed = false, width = 300 }: { collapsed?: boolean; w
|
||||
<SidebarRoot
|
||||
collapsed={current.collapsed} width={current.width}
|
||||
useSessions={neverHook} useSessionPendingInteraction={useSessionPendingInteraction}
|
||||
usePanelInfo={usePanelInfo} selectPanel={() => {}} usePanels={selector => selector([])} useResource={useResource} useWorkspaces={neverHook}
|
||||
usePanelInfo={usePanelInfo} selectPanel={() => {}} usePanels={selector => selector([])}
|
||||
useResource={useResource} useWorkspaces={neverHook}
|
||||
startSession={startSession} toggleSidebar={toggleSidebar} t={t}
|
||||
renderSlot={((
|
||||
key: string,
|
||||
@@ -111,7 +112,8 @@ describe('SidebarRoot shell', () => {
|
||||
const { container } = render(<SidebarRoot
|
||||
collapsed={false} width={300}
|
||||
useSessions={neverHook} useSessionPendingInteraction={useSessionPendingInteraction}
|
||||
usePanelInfo={usePanelInfo} selectPanel={() => {}} usePanels={selector => selector([])} useResource={useResource} useWorkspaces={neverHook}
|
||||
usePanelInfo={usePanelInfo} selectPanel={() => {}} usePanels={selector => selector([])}
|
||||
useResource={useResource} useWorkspaces={neverHook}
|
||||
startSession={vi.fn()} toggleSidebar={vi.fn()} t={t}
|
||||
renderSlot={((_key: string, _owner: unknown, options?: { fallback?: ReactNode }) =>
|
||||
options?.fallback ?? null) as SidebarRootComponentProps['renderSlot']}
|
||||
@@ -130,7 +132,8 @@ describe('SidebarRoot shell', () => {
|
||||
render(<SidebarRoot
|
||||
collapsed={false} width={300}
|
||||
useSessions={neverHook} useSessionPendingInteraction={useSessionPendingInteraction}
|
||||
usePanelInfo={usePanelInfo} selectPanel={() => {}} usePanels={selector => selector([])} useResource={useResource} useWorkspaces={neverHook}
|
||||
usePanelInfo={usePanelInfo} selectPanel={() => {}} usePanels={selector => selector([])}
|
||||
useResource={useResource} useWorkspaces={neverHook}
|
||||
startSession={vi.fn()} toggleSidebar={vi.fn()} t={t}
|
||||
renderSlot={((_key: string, _owner: unknown, options?: { fallback?: ReactNode }) =>
|
||||
options?.fallback ?? null) as SidebarRootComponentProps['renderSlot']}
|
||||
@@ -144,7 +147,8 @@ describe('SidebarRoot shell', () => {
|
||||
render(<SidebarRoot
|
||||
collapsed={false} width={300}
|
||||
useSessions={neverHook} useSessionPendingInteraction={useSessionPendingInteraction}
|
||||
usePanelInfo={usePanelInfo} selectPanel={() => {}} usePanels={selector => selector([])} useResource={useResource} useWorkspaces={neverHook}
|
||||
usePanelInfo={usePanelInfo} selectPanel={() => {}} usePanels={selector => selector([])}
|
||||
useResource={useResource} useWorkspaces={neverHook}
|
||||
startSession={vi.fn()} toggleSidebar={vi.fn()} t={t}
|
||||
renderSlot={((_key: string, _owner: unknown, options?: { fallback?: ReactNode }) =>
|
||||
options?.fallback ?? null) as SidebarRootComponentProps['renderSlot']}
|
||||
|
||||
Reference in new issue
Block a user