From 7e7b05620ff800ae459d0bf007bbace6aaebbdbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=A5=87?= <16399091+binaricat@users.noreply.github.com> Date: Tue, 27 Oct 2026 13:04:03 +0000 Subject: [PATCH] Revert "feat(plugins): share borderless installed settings rows" This reverts commit e4eb33856b335fe0b1d302827b1325ddfc23bdde. --- components/plugins/PluginListRow.tsx | 31 ------------ .../tabs/PluginInstalledGrid.test.tsx | 49 +++---------------- .../settings/tabs/PluginPackageManager.tsx | 25 +++------- .../tabs/PluginSettingsLanding.test.tsx | 7 --- .../settings/tabs/PluginSettingsLanding.tsx | 20 +++++--- .../settings/tabs/PluginStatePill.test.tsx | 6 +-- 6 files changed, 28 insertions(+), 110 deletions(-) delete mode 100644 components/plugins/PluginListRow.tsx diff --git a/components/plugins/PluginListRow.tsx b/components/plugins/PluginListRow.tsx deleted file mode 100644 index c702b1225..000000000 --- a/components/plugins/PluginListRow.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import React from 'react'; -import { ChevronRight } from 'lucide-react'; -import { PluginBrandIcon } from './PluginBrandIcon'; - -/** Shared installed-plugin composition; navigation never wraps the quick actions. */ -export function PluginListRow({ plugin, name, description, metadata, actions, openLabel, onOpen }: { - plugin: NetcattyInstalledPlugin; - name: string; - description: string; - metadata?: React.ReactNode; - actions: React.ReactNode; - openLabel?: string; - onOpen?: () => void; -}) { - const heading = - {name} - {plugin.activeVersion && {plugin.activeVersion}} - ; - return
-
-
- {onOpen ? :
{heading}

{description}

} - {metadata &&
{metadata}
} -
-
{actions}
-
; -} diff --git a/components/settings/tabs/PluginInstalledGrid.test.tsx b/components/settings/tabs/PluginInstalledGrid.test.tsx index 2db8c8bdd..dbbdaabfe 100644 --- a/components/settings/tabs/PluginInstalledGrid.test.tsx +++ b/components/settings/tabs/PluginInstalledGrid.test.tsx @@ -1,16 +1,12 @@ import assert from 'node:assert/strict'; import test from 'node:test'; import React from 'react'; -import { renderToStaticMarkup } from 'react-dom/server'; -import { JSDOM } from 'jsdom'; -import { PluginListRow } from '../../plugins/PluginListRow'; -import { Toggle } from '../settings-ui'; import { act, create, type ReactTestRenderer } from 'react-test-renderer'; import { I18nProvider } from '../../../application/i18n/I18nProvider'; import { PluginPackageManager } from './PluginPackageManager'; import type { usePluginManager } from '../../../application/state/usePluginManager'; -test('installed rows filter, open one detail and restore search, scroll and row focus without toggle navigation', async () => { +test('installed grid filters, opens one detail and restores search, scroll and card focus without pill navigation', async () => { const globals = globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }; const previous = globals.IS_REACT_ACT_ENVIRONMENT; globals.IS_REACT_ACT_ENVIRONMENT = true; const raf = globalThis.requestAnimationFrame; @@ -39,14 +35,11 @@ test('installed rows filter, open one detail and restore search, scroll and row const authorRow = alphaCard.findByProps({ 'data-plugin-author-row': true }); assert.ok(authorRow.findAllByType('span').some((node) => node.children.includes('Example')), 'author has its own compact row'); assert.ok(authorRow.findByProps({ 'data-plugin-author-placeholder': true }), 'an unverified installed publisher has a default avatar'); - assert.ok(alphaCard.findAllByType('span').some((node) => node.props.className?.includes('line-clamp-2')), 'row description is bounded'); - assert.ok(alphaCard.props['data-plugin-row'], 'installed entries use the shared row composition'); - assert.match(alphaCard.findByProps({ 'data-plugin-row-tag': true }).props.className, /border-0/); - assert.doesNotMatch(alphaCard.props.className, /bg-card|border|divide/); + assert.ok(alphaCard.findAllByType('p').some((node) => node.props.className?.includes('line-clamp-3')), 'card description is bounded'); assert.match(JSON.stringify(renderer.toJSON()), /MIT/); assert.match(JSON.stringify(renderer.toJSON()), /Incompatible version/); - assert.equal(renderer.root.findAllByType('div').some((node) => node.props.className?.includes('repeat(auto-fill')), false, 'installed rows no longer inherit the marketplace grid'); - const pill = renderer.root.findAllByType('button').find((node) => node.props.role === 'switch')!; + assert.ok(renderer.root.findAllByType('div').some((node) => node.props.className?.includes('repeat(auto-fill'))); + const pill = renderer.root.findAllByType('button').find((node) => node.props['aria-pressed'] !== undefined)!; await act(async () => pill.props.onClick()); assert.deepEqual(toggles, [[plugins[0].id, true]]); assert.deepEqual(selections, []); await act(async () => renderer.root.findByType('input').props.onChange({ target: { value: 'Alpha' } })); @@ -64,39 +57,9 @@ test('installed rows filter, open one detail and restore search, scroll and row assert.equal(cards().length, 0); await act(async () => renderer.root.findByType('input').props.onChange({ target: { value: '' } })); await act(async () => renderer.update( selections.push(id)} />)); - const unknown = renderer.root.findAllByType('button').filter((node) => node.props.role === 'switch'); + const unknown = renderer.root.findAllByType('button').filter((node) => node.children.includes('Status unknown')); assert.equal(unknown.length, 2); - assert.ok(unknown.every((node) => node.props.disabled === true && node.props['aria-label'].startsWith('Status unknown'))); + assert.ok(unknown.every((node) => node.props.disabled === true && node.props['aria-pressed'] === undefined)); await act(async () => renderer.unmount()); } finally { globals.IS_REACT_ACT_ENVIRONMENT = previous; globalThis.requestAnimationFrame = raf; } }); - - -test('long installed-row text keeps baseline tags and independent native-button actions', () => { - const name = `Long plugin ${'unbroken'.repeat(30)}`; - const description = `Description ${'long description '.repeat(30)}`; - const plugin = { id: 'com.test.long', activeVersion: '1.2.3-preview.4', enabled: false, runtime: {} } as NetcattyInstalledPlugin; - const html = renderToStaticMarkup({'https://source.example/'.repeat(20)}} openLabel={`Details ${name}`} onOpen={() => {}} - actions={ {}} />} />); - const dom = new JSDOM(html); - try { - const row = dom.window.document.querySelector('[data-plugin-row]')!; - const navigation = row.querySelector('[data-plugin-card]')!; - const toggle = row.querySelector('[role=switch]')!; - const tag = row.querySelector('[data-plugin-row-tag]')!; - assert.equal(navigation.type, 'button'); - assert.equal(toggle.type, 'button'); - assert.equal(navigation.contains(toggle), false, 'Enter/Space on the switch cannot invoke row navigation'); - assert.match(navigation.className, /focus-visible:ring-2/); - assert.match(toggle.className, /focus-visible:ring-2/); - assert.match(tag.parentElement!.className, /items-baseline/); - assert.equal(tag.previousElementSibling!.textContent, name, 'long names stay available without title truncation'); - assert.match(tag.previousElementSibling!.className, /overflow-wrap:anywhere/); - assert.match(tag.className, /border-0/); - assert.equal(navigation.querySelector('[title]')!.getAttribute('title'), description, 'clamped descriptions retain the full text'); - assert.match(row.className, /minmax\(0,1fr\)/); - assert.doesNotMatch(row.querySelector('[data-plugin-icon-slot]')!.className, /border|ring|bg-/); - assert.equal(row.querySelector('button button'), null); - } finally { dom.window.close(); } -}); diff --git a/components/settings/tabs/PluginPackageManager.tsx b/components/settings/tabs/PluginPackageManager.tsx index 87930ec84..aefbd27df 100644 --- a/components/settings/tabs/PluginPackageManager.tsx +++ b/components/settings/tabs/PluginPackageManager.tsx @@ -4,8 +4,6 @@ import React, { useRef, useState } from 'react'; import { PluginPermissionPanel } from './PluginPermissionPanel'; import { PluginBrandIcon } from '../../plugins/PluginBrandIcon'; import { PluginAuthorRow } from '../../plugins/PluginAuthorRow'; -import { PluginListRow } from '../../plugins/PluginListRow'; -import { Toggle } from '../settings-ui'; import { ArrowLeft } from 'lucide-react'; import { usePluginManager } from '../../../application/state/usePluginManager'; import { useI18n } from '../../../application/i18n/I18nProvider'; @@ -82,25 +80,13 @@ export function PluginPackageManager({ manager, onSelectionChange, initialSelect if (!manager.available) return null; return
{selectedPlugin && } - {!selectedPlugin && manager.plugins.length > 0 && } + {!selectedPlugin && manager.plugins.length > 0 && } {!selectedPlugin && manager.plugins.length > 0 && setSearch(event.target.value)} placeholder={t('settings.plugins.market.search')} aria-label={t('settings.plugins.market.search')} />} {!selectedPlugin && manager.plugins.length > 0 && visible.length === 0 &&

{t('settings.plugins.market.noResults')}

} {manager.error &&

{manager.error}

} {!manager.plugins.length &&
{t('settings.plugins.manager.empty')}
} -
- {visible.map((plugin) => !selectedPlugin ? choose(plugin.id)} - metadata={<> - {plugin.manifest?.publisher && } - {plugin.source ? `${t('settings.plugins.sources.source')}: ${t(plugin.source.kind === 'official' ? 'settings.plugins.sources.official' : plugin.source.kind === 'third-party' ? 'settings.plugins.sources.thirdparty' : 'settings.plugins.sources.local')}${plugin.source.origin ? ` · ${plugin.source.origin}` : ''}` : t('settings.plugins.landing.sourceUnknown')} - {plugin.manifest?.license && {plugin.manifest.license}} - {manager.statusKnown === false && {t('settings.plugins.permissions.statusUnknown')}} - {plugin.runtime.lastError && {t('settings.plugins.manager.lastError')}: {plugin.runtime.lastError}} - } - actions={ void manager.setEnabled(plugin.id, enabled)} />} - /> :
+
+ {visible.map((plugin) =>
+
:

{plugin.activeVersion}{plugin.manifest?.license ? ` · ${plugin.manifest.license}` : ''}

} {plugin.runtime.lastError &&

{t('settings.plugins.manager.lastError')}: {plugin.runtime.lastError}

} {selected === plugin.id && <> diff --git a/components/settings/tabs/PluginSettingsLanding.test.tsx b/components/settings/tabs/PluginSettingsLanding.test.tsx index cb3df5238..37cb05c01 100644 --- a/components/settings/tabs/PluginSettingsLanding.test.tsx +++ b/components/settings/tabs/PluginSettingsLanding.test.tsx @@ -41,13 +41,6 @@ test('landing rows expose real sources/status/settings and quick toggles preserv await render(); assert.equal(document.querySelector('[role=dialog]'), null); assert.equal(document.querySelector('input[type=checkbox]'), null); - assert.equal(document.querySelectorAll('[data-plugin-row]').length, 2); - assert.equal(document.querySelectorAll('[data-plugin-icon-slot]').length, 2); - assert.equal(document.querySelector('[data-plugin-row-list]')!.className.includes('border'), false); - const alphaRow = document.querySelector('[data-plugin-row="com.example.alpha"]')!; - assert.ok(alphaRow.querySelector('[data-plugin-row-tag]')); - assert.equal(alphaRow.querySelector('[data-plugin-row-actions] [role=switch]')?.getAttribute('aria-label'), 'Disable Alpha'); - assert.equal(alphaRow.querySelector('button button'), null, 'quick actions are never nested inside navigation'); assert.equal(document.querySelectorAll('[role=switch]').length, 2, 'only real plugin toggles appear on landing'); assert.match(document.body.textContent!, /Running/); assert.match(document.body.textContent!, /Source: Official/); diff --git a/components/settings/tabs/PluginSettingsLanding.tsx b/components/settings/tabs/PluginSettingsLanding.tsx index 7a09e77e6..7aff699e2 100644 --- a/components/settings/tabs/PluginSettingsLanding.tsx +++ b/components/settings/tabs/PluginSettingsLanding.tsx @@ -5,7 +5,7 @@ import type { usePluginUpdateCheck } from '../../../application/state/usePluginU import type { usePluginManager } from '../../../application/state/usePluginManager'; import { Button } from '../../ui/button'; import { Input } from '../../ui/input'; -import { PluginListRow } from '../../plugins/PluginListRow'; +import { PluginBrandIcon } from '../../plugins/PluginBrandIcon'; import { PluginAuthorRow } from '../../plugins/PluginAuthorRow'; import { SettingCard, SettingRow, SettingsSection, Toggle } from '../settings-ui'; import { PluginLogSettings } from './PluginLogSettings'; @@ -63,24 +63,28 @@ export function PluginSettingsLanding({ manager, settingsAvailable, settingsErro {manager.statusKnown && manager.available && manager.plugins.length === 0 &&

{t('settings.plugins.landing.empty')}

} {manager.plugins.length > 0 && <> setSearch(event.target.value)} /> - {visible.length === 0 ?

{t('settings.plugins.market.noResults')}

:
+ {visible.length === 0 ?

{t('settings.plugins.market.noResults')}

: {visible.map((plugin) => { const name = nameOf(plugin); const description = localized(plugin.manifest?.description); const availableUpdate = updates?.result?.updates.find((item) => item.pluginId === plugin.id && item.sourceId === plugin.source?.id); const declaredSettings = Boolean(plugin.manifest?.contributes?.settings?.length || plugin.manifest?.contributes?.views?.some((view) => view.location === 'settings')); - return + return } label={ + {name} + {plugin.activeVersion && {plugin.activeVersion}} + } description={<> {plugin.manifest?.publisher && } - {[sourceOf(plugin), statusOf(plugin)].filter(Boolean).join(' · ')} - {availableUpdate && {t('settings.plugins.landing.updateAvailable').replace('{version}', availableUpdate.availableVersion)}} - } actions={ + {[sourceOf(plugin), statusOf(plugin)].filter(Boolean).join(' · ')} + {availableUpdate && {t('settings.plugins.landing.updateAvailable').replace('{version}', availableUpdate.availableVersion)}} + {description && {description}} + }>
{declaredSettings && } void manager.setEnabled(plugin.id, enabled)} />
- } />; +
; })} -
} + } } ; diff --git a/components/settings/tabs/PluginStatePill.test.tsx b/components/settings/tabs/PluginStatePill.test.tsx index 997ff82f1..0d22192cd 100644 --- a/components/settings/tabs/PluginStatePill.test.tsx +++ b/components/settings/tabs/PluginStatePill.test.tsx @@ -6,14 +6,14 @@ import { I18nProvider } from '../../../application/i18n/I18nProvider'; import { PluginPackageManager } from './PluginPackageManager'; import type { usePluginManager } from '../../../application/state/usePluginManager'; -test('detail state pill exposes actual state, opposite action, focus styling and pending disable without granting permissions', async () => { +test('state pill exposes actual state, opposite action, focus styling and pending disable without granting permissions', async () => { const globals = globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }; const previous = globals.IS_REACT_ACT_ENVIRONMENT; globals.IS_REACT_ACT_ENVIRONMENT = true; const calls: unknown[] = []; - const plugin = { id: 'com.test.pill', activeVersion: '1.0.0', enabled: true, manifest: { name: 'Pill', main: { browser: 'index.js' }, engines: { api: '0.1.0-internal', netcatty: '*' } }, runtime: {} } as NetcattyInstalledPlugin; + const plugin = { id: 'com.test.pill', activeVersion: '1.0.0', enabled: true, manifest: { name: 'Pill' }, runtime: {} } as NetcattyInstalledPlugin; const manager = { available: true, plugins: [plugin], busy: false, setEnabled: async (...args: unknown[]) => { calls.push(args); } } as unknown as ReturnType; let renderer: ReactTestRenderer; - const render = (enabled: boolean, busy = false) => ; + const render = (enabled: boolean, busy = false) => ; try { await act(async () => { renderer = create(render(true)); }); const pill = () => renderer.root.findAllByType('button').find((node) => node.props['aria-pressed'] !== undefined)!;