Signed-off-by: faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-07-25 23:44:48 +03:00
1 parent 7a0446b573
commit 3632f2cd43
27 files changed
+3332 -97

No files matched your search

-39
View File
@@ -894,9 +894,6 @@
"arm"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -911,9 +908,6 @@
"arm"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -928,9 +922,6 @@
"arm64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -945,9 +936,6 @@
"arm64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -962,9 +950,6 @@
"loong64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -979,9 +964,6 @@
"loong64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -996,9 +978,6 @@
"ppc64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1013,9 +992,6 @@
"ppc64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1030,9 +1006,6 @@
"riscv64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1047,9 +1020,6 @@
"riscv64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1064,9 +1034,6 @@
"s390x"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1081,9 +1048,6 @@
"x64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -1098,9 +1062,6 @@
"x64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
+2
View File
@@ -46,6 +46,8 @@ const KNOWN_DYNAMIC = new Set([
'Playback history and server insights',
'Server & Admin',
'Manage subscribers and broadcast',
'Updates',
'Runtime, Core, and plugin release control',
'RPC / API',
'Connect to Echoion programmatically',
// Sidebar NAV labels rendered via t(item.label) — same strings as HEADS
+3
View File
@@ -16,6 +16,7 @@ import { SearchView } from './views/SearchView';
import { LibraryView } from './views/LibraryView';
import { StatsView } from './views/StatsView';
import { ServerView } from './views/ServerView';
import { UpdatesView } from './views/UpdatesView';
import { RpcView } from './views/RpcView';
const HEADS: Record<string, [string, string]> = {
@@ -25,6 +26,7 @@ const HEADS: Record<string, [string, string]> = {
library: ['Library', 'Your favorites and saved playlists'],
stats: ['History & Stats', 'Playback history and server insights'],
server: ['Server & Admin', 'Manage subscribers and broadcast'],
updates: ['Updates', 'Runtime, Core, and plugin release control'],
rpc: ['RPC / API', 'Connect to Echoion programmatically'],
};
@@ -92,6 +94,7 @@ export function App() {
{s.view === 'library' && <LibraryView />}
{s.view === 'stats' && <StatsView />}
{s.view === 'server' && <ServerView />}
{s.view === 'updates' && <UpdatesView />}
{s.view === 'rpc' && <RpcView />}
<MiniPlayer />
+17
View File
@@ -0,0 +1,17 @@
import { describe, expect, it } from 'vitest';
import { renderToStaticMarkup } from 'react-dom/server';
import { Modal } from './Modal';
describe('Modal accessibility', () => {
it('labels the dialog and exposes a named close control', () => {
const html = renderToStaticMarkup(
<Modal title="Confirm update" onClose={() => {}}>
<p>Review the candidate.</p>
</Modal>
);
expect(html).toContain('role="dialog"');
expect(html).toContain('aria-modal="true"');
expect(html).toContain('aria-labelledby=');
expect(html).toContain('aria-label="Close"');
});
});
+49 -3
View File
@@ -1,5 +1,6 @@
import type { ReactNode } from 'react';
import { useEffect, useId, useRef, type KeyboardEvent, type ReactNode } from 'react';
import { CloseIcon } from './icons';
import { t } from '../i18n';
export function Modal(props: {
title: string;
@@ -8,15 +9,60 @@ export function Modal(props: {
footer?: ReactNode;
wide?: boolean;
}) {
const titleId = useId();
const modalRef = useRef<HTMLDivElement>(null);
useEffect(() => {
const previous = document.activeElement as HTMLElement | null;
const focusable = modalRef.current?.querySelector<HTMLElement>(
'button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])'
);
focusable?.focus();
return () => previous?.focus();
}, []);
function onKeyDown(event: KeyboardEvent<HTMLDivElement>) {
if (event.key === 'Escape') {
event.preventDefault();
props.onClose();
return;
}
if (event.key !== 'Tab' || !modalRef.current) return;
const focusable = Array.from(
modalRef.current.querySelectorAll<HTMLElement>(
'button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])'
)
);
if (!focusable.length) return;
const first = focusable[0];
const last = focusable[focusable.length - 1];
if (event.shiftKey && document.activeElement === first) {
event.preventDefault();
last.focus();
} else if (!event.shiftKey && document.activeElement === last) {
event.preventDefault();
first.focus();
}
}
return (
<div className="modal-backdrop" onClick={props.onClose}>
<div
ref={modalRef}
className={'modal' + (props.wide ? ' modal-wide' : '')}
role="dialog"
aria-modal="true"
aria-labelledby={titleId}
onKeyDown={onKeyDown}
onClick={(e) => e.stopPropagation()}
>
<div className="modal-head">
<h2>{props.title}</h2>
<button className="icon-btn" onClick={props.onClose}>
<h2 id={titleId}>{props.title}</h2>
<button
className="icon-btn"
aria-label={t('Close')}
onClick={props.onClose}
>
<CloseIcon />
</button>
</div>
+6 -1
View File
@@ -20,6 +20,7 @@ import {
QueueIcon,
SearchIcon,
StatsIcon,
UpdateIcon,
WatchIcon,
} from './icons';
import { t, useLanguage } from '../i18n';
@@ -31,6 +32,7 @@ const NAV: Array<{ view: ViewName; icon: ReactNode; label: string }> = [
{ view: 'library', icon: <HeartIcon />, label: 'Library' },
{ view: 'stats', icon: <StatsIcon />, label: 'History & Stats' },
{ view: 'server', icon: <GearIcon />, label: 'Server & Admin' },
{ view: 'updates', icon: <UpdateIcon />, label: 'Updates' },
{ view: 'rpc', icon: <CodeIcon />, label: 'RPC / API' },
];
@@ -66,7 +68,9 @@ export function Sidebar() {
<nav className="nav">
{NAV.filter(
(item) => item.view !== 'server' || isAdmin
(item) =>
(item.view !== 'server' && item.view !== 'updates') ||
isAdmin
).map((item) => (
<button
key={item.view}
@@ -74,6 +78,7 @@ export function Sidebar() {
'nav-item' +
(s.view === item.view ? ' active' : '')
}
aria-current={s.view === item.view ? 'page' : undefined}
onClick={() => showView(item.view)}
>
<span className="nav-ico">{item.icon}</span>
+3
View File
@@ -63,6 +63,9 @@ export const RoomsIcon = makeIcon(
export const GearIcon = makeIcon(
'M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z'
);
export const UpdateIcon = makeIcon(
'M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01-.25 1.96-.69 2.8l1.46 1.46A7.93 7.93 0 0020 12c0-4.42-3.58-8-8-8zm-5.31 5.2L5.23 7.74A7.93 7.93 0 004 12c0 4.42 3.58 8 8 8v3l4-4-4-4v3c-3.31 0-6-2.69-6-6 0-1.01.25-1.96.69-2.8z'
);
export const CodeIcon = makeIcon(
'M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z'
);
+145
View File
@@ -11,6 +11,7 @@ export const ru: Record<string, string> = {
'History & Stats': 'История и статистика',
'Watch Together': 'Совместный просмотр',
'Server & Admin': 'Сервер и админ',
'Updates': 'Обновления',
'RPC / API': 'RPC / API',
'MUSIC BOT · TS3': 'МУЗЫКАЛЬНЫЙ БОТ · TS3',
'Connect': 'Подключиться',
@@ -32,8 +33,152 @@ export const ru: Record<string, string> = {
'Your favorites and saved playlists': 'Ваше избранное и сохранённые плейлисты',
'Playback history and server insights': 'История воспроизведения и статистика сервера',
'Manage subscribers and broadcast': 'Управление подписчиками и объявления',
'Runtime, Core, and plugin release control':
'Управление выпусками среды, ядра и плагинов',
'Connect to Echoion programmatically': 'Подключение к Echoion из кода',
// Updates
'Runtime bundle': 'Среда выполнения',
'Core': 'Ядро',
'Plugins': 'Плагины',
'default source': 'источник по умолчанию',
'stable': 'стабильный',
'Idle': 'Ожидание',
'Installed': 'Установлено',
'Available': 'Доступно',
'Up to date': 'Актуальная версия',
'Candidate attributes': 'Свойства кандидата',
'Unsigned': 'Без подписи',
'Signed': 'Подписано',
'Downgrade': 'Понижение версии',
'Incompatible': 'Несовместимо',
'Restart required': 'Нужен перезапуск',
'Apply {0}': 'Применить {0}',
'No update': 'Нет обновления',
'Rollback to {0}': 'Откатить до {0}',
'No rollback': 'Откат недоступен',
'Enabled': 'Включено',
'Source': 'Источник',
'Channel': 'Канал',
'{0} source': 'Источник: {0}',
'{0} channel': 'Канал: {0}',
'Auto-apply': 'Применять автоматически',
'Build default': 'Встроенное значение',
'Feed URL': 'URL ленты',
'Empty uses the release build default':
'Пустое поле использует адрес из сборки выпуска',
'Bearer token environment variable': 'Переменная окружения с Bearer-токеном',
'Secret is present in the service environment':
'Секрет присутствует в окружении службы',
'Secret is missing from the service environment':
'Секрет отсутствует в окружении службы',
'Secret presence was not reported': 'Наличие секрета не сообщено службой',
'No bearer token configured': 'Bearer-токен не настроен',
'Permit manual unsigned staging':
'Разрешить ручную подготовку обновлений без подписи',
'Ed25519 trust keys': 'Доверенные ключи Ed25519',
'Only public verification keys belong here.':
'Здесь должны находиться только открытые ключи проверки.',
'Add key': 'Добавить ключ',
'Key ID': 'ID ключа',
'Public key': 'Открытый ключ',
'Remove key {0}': 'Удалить ключ {0}',
'No custom keys; the build-injected keyring is used when available.':
'Пользовательских ключей нет; используется встроенное в сборку хранилище ключей.',
'Remove source': 'Удалить источник',
'Managed': 'Управляемый',
'Unmanaged': 'Неуправляемый',
'Apply': 'Применить',
'Rollback': 'Откатить',
'Never': 'Никогда',
'Automatic updates armed': 'Автоматические обновления активны',
'Automatic updates paused': 'Автоматические обновления приостановлены',
'Last check: {0}': 'Последняя проверка: {0}',
'Next: {0}': 'Следующая: {0}',
'Check now': 'Проверить сейчас',
'Checking…': 'Проверка…',
'Loading update state…': 'Загрузка состояния обновлений…',
'Installed plugins': 'Установленные плагины',
'Only managed plugins participate in update activation.':
'В активации обновлений участвуют только управляемые плагины.',
'managed': 'управляемых',
'No installed plugins reported': 'Установленные плагины не обнаружены',
'Update history': 'История обновлений',
'Checks, staging, activation, and rollback outcomes':
'Результаты проверок, подготовки, активации и откатов',
'When': 'Когда',
'Target': 'Цель',
'Action': 'Действие',
'Result': 'Результат',
'Recorded': 'Записано',
'No update history yet': 'История обновлений пока пуста',
'POLICY DECK': 'ПАНЕЛЬ ПОЛИТИКИ',
'Automation and trust': 'Автоматизация и доверие',
'Configure timing, independent channels, feeds, and public trust roots.':
'Настройте расписание, независимые каналы, ленты и открытые корни доверия.',
'Discard changes': 'Отменить изменения',
'Save policy': 'Сохранить политику',
'Saving…': 'Сохранение…',
'Enable the update scheduler': 'Включить планировщик обновлений',
'Check interval': 'Интервал проверки',
'Schedule jitter': 'Разброс расписания',
'Maintenance start (UTC)': 'Начало обслуживания (UTC)',
'Maintenance duration': 'Длительность обслуживания',
'Maximum runtime deferral': 'Максимальная отсрочка среды',
'Previous healthy versions retained': 'Хранимые предыдущие исправные версии',
'Component channels': 'Каналы компонентов',
'Selections remain independent; incompatible cohorts stay staged.':
'Выбор остаётся независимым; несовместимые наборы остаются подготовленными.',
'Never modify loose local plugin files':
'Никогда не изменять отдельные локальные файлы плагинов',
'Plugin channel overrides': 'Переопределения каналов плагинов',
'Pin individual managed plugins to another source or channel.':
'Назначьте отдельным управляемым плагинам другой источник или канал.',
'Add override': 'Добавить переопределение',
'No plugin overrides': 'Переопределений плагинов нет',
'Sources and trust roots': 'Источники и корни доверия',
'Secret values stay in the service environment and are never returned here.':
'Значения секретов остаются в окружении службы и никогда не возвращаются сюда.',
'Add source': 'Добавить источник',
'Confirm unsigned update': 'Подтвердите обновление без подписи',
'This artifact has no trusted signature. Type {0} to authorize this exact candidate.':
'У этого артефакта нет доверенной подписи. Введите {0}, чтобы разрешить именно этот кандидат.',
'Authorize unsigned candidate': 'Разрешить кандидат без подписи',
'Confirm downgrade': 'Подтвердите понижение версии',
'A downgrade may make saved state incompatible. Type DOWNGRADE to continue.':
'Понижение версии может сделать сохранённое состояние несовместимым. Введите DOWNGRADE для продолжения.',
'Continue with downgrade': 'Продолжить понижение версии',
'Restart Echoion': 'Перезапустить Echoion',
'Applying this update restarts Echoion after it becomes idle. Continue?':
'После перехода в режим ожидания Echoion будет перезапущен для применения обновления. Продолжить?',
'Apply and restart': 'Применить и перезапустить',
'{0} update queued': 'Обновление {0} поставлено в очередь',
'Confirm rollback': 'Подтвердите откат',
'Roll back {0} to {1}?': 'Откатить {0} до {1}?',
'Rollback queued': 'Откат поставлен в очередь',
'Enable unsigned update policy': 'Разрешить политику обновлений без подписи',
'Unsigned staging will be permitted for: {0}. Type ENABLE UNSIGNED to save this policy.':
'Подготовка без подписи будет разрешена для: {0}. Введите ENABLE UNSIGNED, чтобы сохранить политику.',
'Save unsafe policy': 'Сохранить небезопасную политику',
'Update policy saved': 'Политика обновлений сохранена',
'Add update source': 'Добавить источник обновлений',
'Use a short ID made from letters, numbers, dots, dashes, or underscores.':
'Используйте короткий ID из букв, цифр, точек, дефисов или подчёркиваний.',
'Invalid source ID': 'Недопустимый ID источника',
'That source already exists': 'Такой источник уже существует',
'Move every component off this source before removing it':
'Перед удалением переведите все компоненты на другой источник',
'Remove update source': 'Удалить источник обновлений',
'Remove source {0} and its public keys?':
'Удалить источник {0} и его открытые ключи?',
'Add plugin channel override': 'Добавить переопределение канала плагина',
'Enter the exact managed plugin ID.': 'Введите точный ID управляемого плагина.',
'That plugin override already exists':
'Переопределение для этого плагина уже существует',
'Update check completed': 'Проверка обновлений завершена',
'Update policy, trust keys, and activation controls are restricted to administrators.':
'Политика обновлений, доверенные ключи и активация доступны только администраторам.',
// Now playing
'Nothing playing': 'Ничего не играет',
'Up Next': 'Далее',
+1
View File
@@ -22,6 +22,7 @@ export type ViewName =
| 'library'
| 'stats'
| 'server'
| 'updates'
| 'rpc';
export interface AppState {
+2
View File
@@ -9,5 +9,7 @@ describe('audit RPC method mapping', () => {
expect(auditMethodName(72)).toBe('Reserved72');
expect(auditMethodName(73)).toBe('GetTeamSpeakDirectory');
expect(auditMethodName(88)).toBe('SendTeamSpeakServerMessage');
expect(auditMethodName(89)).toBe('GetUpdateStatus');
expect(auditMethodName(95)).toBe('ConfirmUnsignedUpdate');
});
});
+7
View File
@@ -94,6 +94,13 @@ const RPC_METHOD_BY_INDEX: readonly string[] = [
'SendTeamSpeakPrivateMessage',
'SendTeamSpeakChannelMessage',
'SendTeamSpeakServerMessage',
'GetUpdateStatus', // 89
'GetUpdateConfig',
'SetUpdateConfig',
'CheckForUpdates',
'ApplyUpdate',
'RollbackUpdate',
'ConfirmUnsignedUpdate', // 95
];
export function auditMethodName(method: number): string {
+1
View File
@@ -11,5 +11,6 @@ describe('dashboard routing', () => {
it('keeps the remaining flat views bookmarkable', () => {
expect(viewFromHash('#queue')).toBe('queue');
expect(viewFromHash('#server')).toBe('server');
expect(viewFromHash('#updates')).toBe('updates');
});
});
+1
View File
@@ -11,6 +11,7 @@ const VIEWS: readonly ViewName[] = [
'library',
'stats',
'server',
'updates',
'rpc',
];
+27
View File
@@ -75,6 +75,18 @@ describe('RpcClient wire contract', () => {
expect(frame.authToken).toBe('tok-abc');
});
it('sends updater requests through their append-only RPC enum names', async () => {
installFakes();
const rpc = new RpcClient();
await rpc.connect();
const ws = FakeWebSocket.instances[0];
rpc.call('GetUpdateStatus');
const frame = JSON.parse(ws.sent[0]);
expect(frame.method).toBe('GetUpdateStatus');
expect(JSON.parse(frame.params)).toEqual({});
});
it('resolves a call by requestId and JSON-decodes the result string', async () => {
installFakes();
const rpc = new RpcClient();
@@ -125,6 +137,21 @@ describe('RpcClient wire contract', () => {
expect(seen).toEqual([{ position: 1000, duration: 200000 }]);
});
it('dispatches the updater change event without renaming it', async () => {
installFakes();
const rpc = new RpcClient();
await rpc.connect();
const ws = FakeWebSocket.instances[0];
const seen: unknown[] = [];
rpc.on('updates.changed', (data) => seen.push(data));
ws.receive({
event: 'updates.changed',
data: JSON.stringify({ component: 'core', state: 'staged' }),
});
expect(seen).toEqual([{ component: 'core', state: 'staged' }]);
});
it('fires the wildcard listener with event name and data', async () => {
installFakes();
const rpc = new RpcClient();
+8 -1
View File
@@ -80,7 +80,14 @@ export type RpcMethodName =
| 'RemoveTeamSpeakServerGroupMember'
| 'SendTeamSpeakPrivateMessage'
| 'SendTeamSpeakChannelMessage'
| 'SendTeamSpeakServerMessage';
| 'SendTeamSpeakServerMessage'
| 'GetUpdateStatus'
| 'GetUpdateConfig'
| 'SetUpdateConfig'
| 'CheckForUpdates'
| 'ApplyUpdate'
| 'RollbackUpdate'
| 'ConfirmUnsignedUpdate';
type Pending = {
+5 -1
View File
@@ -28,5 +28,9 @@ export class Store<T> {
}
export function useStore<T>(store: Store<T>): T {
return useSyncExternalStore(store.subscribe, () => store.get());
return useSyncExternalStore(
store.subscribe,
() => store.get(),
() => store.get()
);
}
+91
View File
@@ -0,0 +1,91 @@
import { describe, expect, it } from 'vitest';
import {
configForSave,
isValidSourceId,
normalizeUpdateConfig,
normalizeUpdateStatus,
} from './updates';
describe('update payload normalization', () => {
it('normalizes direct config and strips read-only secret presence on save', () => {
const config = normalizeUpdateConfig({
enabled: true,
checkInterval: '12h',
sources: {
private: {
url: ' https://updates.example/feed.json ',
publicKeys: [{ id: ' key-1 ', ed25519: ' abc123 ' }],
allowUnsigned: false,
bearerTokenEnv: ' UPDATE_TOKEN ',
bearerTokenPresent: true,
bearerToken: 'must-not-enter-browser-state',
},
},
runtime: { source: 'private', channel: 'stable' },
plugins: { managedOnly: false },
});
expect(config.checkInterval).toBe('12h');
expect(config.sources.private.bearerTokenPresent).toBe(true);
expect(config.sources.private).not.toHaveProperty('bearerToken');
expect(config.runtime.source).toBe('private');
expect(config.plugins.managedOnly).toBe(true);
const writable = configForSave(config);
expect(writable.sources.private).not.toHaveProperty(
'bearerTokenPresent'
);
expect(writable.sources.private.bearerTokenEnv).toBe('UPDATE_TOKEN');
expect(writable.sources.private.url).toBe(
'https://updates.example/feed.json'
);
expect(writable.sources.private.publicKeys).toEqual([
{ id: 'key-1', ed25519: 'abc123' },
]);
});
it('normalizes component candidates, plugin inventory, and history', () => {
const status = normalizeUpdateStatus({
enabled: true,
checking: false,
components: {
runtime: {
installedVersion: '1.0.0',
availableVersion: '1.1.0',
signed: false,
requiresRestart: true,
},
core: { currentVersion: '4.0.0', state: 'healthy' },
plugins: { state: 'current' },
},
pluginEntries: [
{
pluginId: 'weather',
managed: true,
installedVersion: '2.0.0',
candidate: { version: '2.1.0', signed: true },
},
],
history: [{ timestamp: 42, component: 'runtime', result: 'success' }],
});
expect(status.components.runtime.currentVersion).toBe('1.0.0');
expect(status.components.runtime.candidate).toMatchObject({
version: '1.1.0',
signed: false,
requiresRestart: true,
});
expect(status.plugins[0]).toMatchObject({
id: 'weather',
managed: true,
currentVersion: '2.0.0',
});
expect(status.history).toHaveLength(1);
});
it('accepts safe source identifiers only', () => {
expect(isValidSourceId('private-beta_2')).toBe(true);
expect(isValidSourceId('../escape')).toBe(false);
expect(isValidSourceId('has spaces')).toBe(false);
expect(isValidSourceId('')).toBe(false);
});
});
+481
View File
@@ -0,0 +1,481 @@
export type UpdateComponent = 'runtime' | 'core' | 'plugins';
export interface UpdatePublicKey {
id: string;
ed25519: string;
}
export interface UpdateSourceConfig {
url: string;
publicKeys: UpdatePublicKey[];
allowUnsigned: boolean;
bearerTokenEnv: string;
// Read-only status supplied by the server. It is stripped before save so
// the browser can never turn secret-presence metadata into configuration.
bearerTokenPresent?: boolean;
[key: string]: unknown;
}
export interface ComponentUpdatePolicy {
enabled: boolean;
source: string;
channel: string;
autoApply: boolean;
[key: string]: unknown;
}
export interface PluginOverridePolicy {
source: string;
channel: string;
autoApply: boolean;
[key: string]: unknown;
}
export interface PluginUpdatePolicy extends ComponentUpdatePolicy {
managedOnly: boolean;
overrides: Record<string, PluginOverridePolicy>;
}
export interface UpdateConfig {
enabled: boolean;
checkInterval: string;
jitter: string;
maintenanceWindowUtc: {
start: string;
duration: string;
[key: string]: unknown;
};
maxRuntimeDeferral: string;
retainHealthyVersions: number;
sources: Record<string, UpdateSourceConfig>;
runtime: ComponentUpdatePolicy;
core: ComponentUpdatePolicy;
plugins: PluginUpdatePolicy;
[key: string]: unknown;
}
export interface UpdateCandidate {
id?: string;
version: string;
channel?: string;
source?: string;
signed?: boolean;
compatible?: boolean;
downgrade?: boolean;
requiresRestart?: boolean;
cohort?: string;
message?: string;
[key: string]: unknown;
}
export interface ComponentUpdateStatus {
component: UpdateComponent;
currentVersion?: string;
state?: string;
message?: string;
channel?: string;
source?: string;
candidate?: UpdateCandidate;
rollbackVersion?: string;
lastChangedAt?: string | number;
[key: string]: unknown;
}
export interface PluginUpdateStatus {
id: string;
name?: string;
managed: boolean;
currentVersion?: string;
state?: string;
channel?: string;
source?: string;
candidate?: UpdateCandidate;
rollbackVersion?: string;
message?: string;
[key: string]: unknown;
}
export interface UpdateHistoryEntry {
timestamp?: string | number;
component?: UpdateComponent | string;
pluginId?: string;
action?: string;
version?: string;
result?: string;
message?: string;
actor?: string;
[key: string]: unknown;
}
export interface UpdateStatus {
enabled: boolean;
checking: boolean;
lastCheckAt?: string | number;
nextCheckAt?: string | number;
components: Record<UpdateComponent, ComponentUpdateStatus>;
plugins: PluginUpdateStatus[];
history: UpdateHistoryEntry[];
message?: string;
[key: string]: unknown;
}
const DEFAULT_COMPONENT_POLICY: ComponentUpdatePolicy = {
enabled: true,
source: 'official',
channel: 'stable',
autoApply: true,
};
export const DEFAULT_UPDATE_CONFIG: UpdateConfig = {
enabled: true,
checkInterval: '6h',
jitter: '30m',
maintenanceWindowUtc: {
start: '03:00',
duration: '2h',
},
maxRuntimeDeferral: '24h',
retainHealthyVersions: 2,
sources: {
official: {
url: '',
publicKeys: [],
allowUnsigned: false,
bearerTokenEnv: '',
},
},
runtime: { ...DEFAULT_COMPONENT_POLICY },
core: { ...DEFAULT_COMPONENT_POLICY },
plugins: {
...DEFAULT_COMPONENT_POLICY,
managedOnly: true,
overrides: {},
},
};
function record(value: unknown): Record<string, unknown> {
return value && typeof value === 'object' && !Array.isArray(value)
? (value as Record<string, unknown>)
: {};
}
function stringValue(value: unknown, fallback = ''): string {
return typeof value === 'string' ? value : fallback;
}
function booleanValue(value: unknown, fallback: boolean): boolean {
return typeof value === 'boolean' ? value : fallback;
}
function numberValue(value: unknown, fallback: number): number {
return typeof value === 'number' && Number.isFinite(value)
? value
: fallback;
}
function unwrap(payload: unknown, key: string): Record<string, unknown> {
const outer = record(payload);
const nested = record(outer[key]);
return Object.keys(nested).length ? nested : outer;
}
function sourceFieldsWithoutSecrets(
source: Record<string, unknown>
): Record<string, unknown> {
return Object.fromEntries(
Object.entries(source).filter(([key]) => {
if (key === 'bearerTokenEnv' || key === 'bearerTokenPresent') {
return true;
}
return !/(token|secret|password|authorization|privatekey)/i.test(key);
})
);
}
function normalizeComponentPolicy(
value: unknown,
fallback: ComponentUpdatePolicy
): ComponentUpdatePolicy {
const raw = record(value);
return {
...raw,
enabled: booleanValue(raw.enabled, fallback.enabled),
source: stringValue(raw.source, fallback.source),
channel: stringValue(raw.channel, fallback.channel),
autoApply: booleanValue(raw.autoApply, fallback.autoApply),
};
}
function normalizePluginOverride(
value: unknown,
fallback: ComponentUpdatePolicy
): PluginOverridePolicy {
const raw = record(value);
return {
...raw,
source: stringValue(raw.source, fallback.source),
channel: stringValue(raw.channel, fallback.channel),
autoApply: booleanValue(raw.autoApply, fallback.autoApply),
};
}
export function normalizeUpdateConfig(payload: unknown): UpdateConfig {
const raw = unwrap(payload, 'config');
const rawSources = record(raw.sources);
const sources: Record<string, UpdateSourceConfig> = {};
for (const [id, value] of Object.entries(rawSources)) {
const source = record(value);
const safeSource = sourceFieldsWithoutSecrets(source);
const rawKeys = Array.isArray(source.publicKeys)
? source.publicKeys
: [];
sources[id] = {
...safeSource,
url: stringValue(source.url),
publicKeys: rawKeys.map((key) => {
const rawKey = record(key);
return {
id: stringValue(rawKey.id),
ed25519: stringValue(rawKey.ed25519),
};
}),
allowUnsigned: booleanValue(source.allowUnsigned, false),
bearerTokenEnv: stringValue(source.bearerTokenEnv),
...(typeof source.bearerTokenPresent === 'boolean'
? { bearerTokenPresent: source.bearerTokenPresent }
: {}),
};
}
if (!Object.keys(sources).length) {
sources.official = { ...DEFAULT_UPDATE_CONFIG.sources.official };
}
const runtime = normalizeComponentPolicy(
raw.runtime,
DEFAULT_UPDATE_CONFIG.runtime
);
const core = normalizeComponentPolicy(raw.core, DEFAULT_UPDATE_CONFIG.core);
const rawPlugins = record(raw.plugins);
const pluginBase = normalizeComponentPolicy(
rawPlugins,
DEFAULT_UPDATE_CONFIG.plugins
);
const overrides: Record<string, PluginOverridePolicy> = {};
for (const [id, value] of Object.entries(record(rawPlugins.overrides))) {
overrides[id] = normalizePluginOverride(value, pluginBase);
}
const rawWindow = record(raw.maintenanceWindowUtc);
return {
...raw,
enabled: booleanValue(raw.enabled, DEFAULT_UPDATE_CONFIG.enabled),
checkInterval: stringValue(
raw.checkInterval,
DEFAULT_UPDATE_CONFIG.checkInterval
),
jitter: stringValue(raw.jitter, DEFAULT_UPDATE_CONFIG.jitter),
maintenanceWindowUtc: {
...rawWindow,
start: stringValue(
rawWindow.start,
DEFAULT_UPDATE_CONFIG.maintenanceWindowUtc.start
),
duration: stringValue(
rawWindow.duration,
DEFAULT_UPDATE_CONFIG.maintenanceWindowUtc.duration
),
},
maxRuntimeDeferral: stringValue(
raw.maxRuntimeDeferral,
DEFAULT_UPDATE_CONFIG.maxRuntimeDeferral
),
retainHealthyVersions: numberValue(
raw.retainHealthyVersions,
DEFAULT_UPDATE_CONFIG.retainHealthyVersions
),
sources,
runtime,
core,
plugins: {
...rawPlugins,
...pluginBase,
// Loose local shared objects are never updater-owned. Keep this an
// invariant even if an older or hand-written config says otherwise.
managedOnly: true,
overrides,
},
};
}
function normalizeCandidate(value: unknown): UpdateCandidate | undefined {
const raw = record(value);
const version = stringValue(raw.version || raw.availableVersion);
if (!version) return undefined;
return {
...raw,
id: stringValue(raw.id || raw.candidateId) || undefined,
version,
channel: stringValue(raw.channel) || undefined,
source: stringValue(raw.source) || undefined,
...(typeof raw.signed === 'boolean' ? { signed: raw.signed } : {}),
...(typeof raw.compatible === 'boolean'
? { compatible: raw.compatible }
: {}),
...(typeof raw.downgrade === 'boolean'
? { downgrade: raw.downgrade }
: {}),
...(typeof raw.requiresRestart === 'boolean'
? { requiresRestart: raw.requiresRestart }
: {}),
cohort: stringValue(raw.cohort) || undefined,
message: stringValue(raw.message) || undefined,
};
}
function normalizeComponent(
component: UpdateComponent,
value: unknown
): ComponentUpdateStatus {
const raw = record(value);
const candidate =
normalizeCandidate(raw.candidate) ||
normalizeCandidate({
version: raw.availableVersion,
id: raw.candidateId,
channel: raw.availableChannel,
source: raw.availableSource,
signed: raw.signed,
compatible: raw.compatible,
downgrade: raw.downgrade,
requiresRestart: raw.requiresRestart,
});
return {
...raw,
component,
currentVersion:
stringValue(raw.currentVersion || raw.installedVersion) || undefined,
state: stringValue(raw.state || raw.status) || undefined,
message: stringValue(raw.message) || undefined,
channel: stringValue(raw.channel) || undefined,
source: stringValue(raw.source) || undefined,
candidate,
rollbackVersion: stringValue(raw.rollbackVersion) || undefined,
lastChangedAt:
typeof raw.lastChangedAt === 'string' ||
typeof raw.lastChangedAt === 'number'
? raw.lastChangedAt
: undefined,
};
}
function normalizePlugin(value: unknown): PluginUpdateStatus | null {
const raw = record(value);
const id = stringValue(raw.id || raw.pluginId);
if (!id) return null;
return {
...raw,
id,
name: stringValue(raw.name) || undefined,
managed: booleanValue(raw.managed, false),
currentVersion:
stringValue(raw.currentVersion || raw.installedVersion) || undefined,
state: stringValue(raw.state || raw.status) || undefined,
channel: stringValue(raw.channel) || undefined,
source: stringValue(raw.source) || undefined,
candidate:
normalizeCandidate(raw.candidate) ||
normalizeCandidate({
version: raw.availableVersion,
id: raw.candidateId,
signed: raw.signed,
compatible: raw.compatible,
downgrade: raw.downgrade,
requiresRestart: raw.requiresRestart,
}),
rollbackVersion: stringValue(raw.rollbackVersion) || undefined,
message: stringValue(raw.message) || undefined,
};
}
export function normalizeUpdateStatus(payload: unknown): UpdateStatus {
const raw = unwrap(payload, 'status');
const rawComponents = record(raw.components);
const pluginComponent = record(
rawComponents.plugins ||
(!Array.isArray(raw.plugins) ? raw.plugins : undefined)
);
const rawPluginEntries =
(Array.isArray(raw.pluginEntries) && raw.pluginEntries) ||
(Array.isArray(raw.managedPlugins) && raw.managedPlugins) ||
(Array.isArray(raw.plugins) && raw.plugins) ||
(Array.isArray(pluginComponent.items) && pluginComponent.items) ||
[];
const rawHistory = Array.isArray(raw.history) ? raw.history : [];
return {
...raw,
enabled: booleanValue(raw.enabled, true),
checking: booleanValue(raw.checking, false),
lastCheckAt:
typeof raw.lastCheckAt === 'string' ||
typeof raw.lastCheckAt === 'number'
? raw.lastCheckAt
: undefined,
nextCheckAt:
typeof raw.nextCheckAt === 'string' ||
typeof raw.nextCheckAt === 'number'
? raw.nextCheckAt
: undefined,
components: {
runtime: normalizeComponent(
'runtime',
rawComponents.runtime || raw.runtime
),
core: normalizeComponent('core', rawComponents.core || raw.core),
plugins: normalizeComponent('plugins', pluginComponent),
},
plugins: rawPluginEntries
.map(normalizePlugin)
.filter((plugin): plugin is PluginUpdateStatus => plugin !== null),
history: rawHistory.map((entry) => record(entry) as UpdateHistoryEntry),
message: stringValue(raw.message) || undefined,
};
}
export function configForSave(config: UpdateConfig): UpdateConfig {
const normalized = normalizeUpdateConfig(config);
const sources: Record<string, UpdateSourceConfig> = {};
for (const [id, source] of Object.entries(normalized.sources)) {
const { bearerTokenPresent: _present, ...writable } = source;
sources[id] = {
...sourceFieldsWithoutSecrets(writable),
url: source.url.trim(),
allowUnsigned: source.allowUnsigned,
bearerTokenEnv: source.bearerTokenEnv.trim(),
publicKeys: source.publicKeys
.map((key) => ({
id: key.id.trim(),
ed25519: key.ed25519.trim(),
}))
.filter((key) => key.id || key.ed25519),
};
}
return {
...normalized,
sources,
retainHealthyVersions: Math.max(
1,
Math.min(10, Math.trunc(normalized.retainHealthyVersions))
),
};
}
export function isValidSourceId(value: string): boolean {
return /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(value);
}
export function cloneUpdateConfig(config: UpdateConfig): UpdateConfig {
return normalizeUpdateConfig(JSON.parse(JSON.stringify(config)));
}
+240
View File
@@ -186,6 +186,8 @@ select:focus:not(:focus-visible) { outline: none; }
.btn-ghost:hover { color: var(--text-2); background: rgba(255, 255, 255, 0.04); }
.btn-danger-ghost { background: transparent; border-color: rgba(255, 92, 92, 0.3); color: var(--red-text); }
.btn-danger-ghost:hover { background: rgba(255, 92, 92, 0.1); }
.btn-danger { background: #c8434b; color: #fff; }
.btn-danger:hover { background: #dc5059; }
/* Leave-room button: prominent but not alarming; pushed to the right of the
room header so it reads as the primary in-room action. */
.btn-leave {
@@ -685,3 +687,241 @@ select:focus:not(:focus-visible) { outline: none; }
}
.ts-markup details { margin: 0.4em 0; }
.ts-markup summary { cursor: pointer; font-weight: 600; }
/* ── Updates control plane ──────────────────────────────────────────────
The update surface keeps the dashboard's violet language, but uses a
denser instrument-panel rhythm: version rails, status lamps, and a faint
technical grid make trust and activation state scannable at a glance. */
.updates-view {
position: relative;
}
.updates-view::before {
content: ''; position: absolute; inset: -8px 0 auto; height: 250px;
pointer-events: none; opacity: .18;
background-image:
linear-gradient(rgba(124, 92, 255, .12) 1px, transparent 1px),
linear-gradient(90deg, rgba(124, 92, 255, .12) 1px, transparent 1px);
background-size: 28px 28px;
mask-image: linear-gradient(to bottom, #000, transparent);
}
.update-command-bar {
position: relative; display: flex; align-items: center;
justify-content: space-between; gap: 16px; margin-bottom: 16px;
padding: 14px 16px; border: 1px solid rgba(124, 92, 255, .23);
border-radius: 13px;
background: linear-gradient(110deg, rgba(124, 92, 255, .11), rgba(255, 255, 255, .025) 58%);
}
.update-command-state { display: flex; align-items: center; gap: 12px; min-width: 0; }
.update-command-state p { margin-top: 2px; font-size: 12px; }
.update-beacon {
width: 11px; height: 11px; border-radius: 50%; flex: none;
background: var(--faint); box-shadow: 0 0 0 6px rgba(106, 106, 120, .1);
}
.update-beacon.active {
background: var(--green);
box-shadow: 0 0 0 6px rgba(63, 208, 122, .1), 0 0 18px rgba(63, 208, 122, .4);
}
.update-live-region { min-height: 18px; color: var(--muted-2); font-size: 12px; }
.update-component-grid {
position: relative; display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 12px; margin: 2px 0 18px;
}
.update-component-card {
position: relative; overflow: hidden; display: flex; flex-direction: column;
min-height: 260px; padding: 16px; border: 1px solid var(--line);
border-radius: var(--radius); background: rgba(14, 14, 21, .93);
}
.update-component-card::after {
content: ''; position: absolute; right: -32px; top: -32px;
width: 110px; height: 110px; border-radius: 50%;
background: rgba(124, 92, 255, .08); filter: blur(4px);
}
.update-component-head {
position: relative; z-index: 1; display: grid;
grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
}
.update-component-head h2 { font-size: 15px; }
.update-component-head p { margin-top: 2px; font-size: 10px; }
.update-component-mark {
width: 35px; height: 35px; border-radius: 10px;
display: grid; place-items: center; font: 700 13px var(--font-mono);
color: #d7d0ff; border: 1px solid rgba(124, 92, 255, .28);
background: rgba(124, 92, 255, .13);
}
.update-component-mark.core { color: #8fe8b4; border-color: rgba(63, 208, 122, .25); background: rgba(63, 208, 122, .1); }
.update-component-mark.plugins { color: #ffe08d; border-color: rgba(255, 207, 74, .25); background: rgba(255, 207, 74, .1); }
.update-version-line {
display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
align-items: center; gap: 10px; margin: 20px 0 12px;
}
.update-version-line > div { min-width: 0; }
.update-version-line span {
display: block; color: var(--faint); font-size: 9px; font-weight: 700;
letter-spacing: .09em; text-transform: uppercase;
}
.update-version-line strong {
display: block; overflow: hidden; margin-top: 3px;
font: 700 14px var(--font-mono); text-overflow: ellipsis;
}
.update-version-arrow { color: var(--accent-text) !important; font-size: 16px !important; }
.update-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.update-badge {
display: inline-flex; align-items: center; width: fit-content;
padding: 3px 7px; border-radius: 999px;
font: 700 9px var(--font-mono); letter-spacing: .03em;
text-transform: uppercase; white-space: nowrap;
color: var(--muted); border: 1px solid rgba(255, 255, 255, .08);
background: rgba(255, 255, 255, .04);
}
.update-badge.success { color: var(--green-text); border-color: rgba(63, 208, 122, .22); background: rgba(63, 208, 122, .09); }
.update-badge.warning { color: var(--yellow-text); border-color: rgba(255, 207, 74, .22); background: rgba(255, 207, 74, .09); }
.update-badge.danger { color: var(--red-text); border-color: rgba(255, 92, 92, .24); background: rgba(255, 92, 92, .09); }
.update-card-message { margin-top: 10px; color: var(--muted-2); font-size: 12px; line-height: 1.45; }
.update-card-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: auto; padding-top: 18px; }
.update-card-actions .btn { padding: 7px 10px; font-size: 11px; }
.updates-two-column {
display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
gap: 18px; align-items: start;
}
.update-plugin-list { display: flex; flex-direction: column; }
.update-plugin-row {
display: grid; grid-template-columns: minmax(120px, 1.2fr) auto minmax(105px, .7fr) auto;
align-items: center; gap: 10px; padding: 9px 2px;
border-bottom: 1px solid var(--line);
}
.update-plugin-row:last-child { border-bottom: 0; }
.update-plugin-main { display: flex; flex-direction: column; min-width: 0; }
.update-plugin-main strong, .update-plugin-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.update-plugin-main span { font-size: 10px; margin-top: 2px; }
.update-plugin-version { color: var(--muted); font-size: 11px; }
.update-plugin-actions { display: flex; gap: 5px; }
.update-plugin-actions .btn { padding: 5px 8px; font-size: 10px; }
.update-history-scroll { max-height: 350px; overflow: auto; }
.update-history-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.update-history-table th {
position: sticky; top: 0; z-index: 1; padding: 7px 8px;
text-align: left; color: var(--faint); background: #111119;
font-size: 9px; letter-spacing: .08em; text-transform: uppercase;
}
.update-history-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.update-history-table td:first-child { white-space: nowrap; color: var(--muted-2); }
.update-history-table td small { display: block; margin-top: 2px; color: var(--faint); font: 9px var(--font-mono); }
.update-config { margin-top: 8px; }
.update-config-title, .update-sources-head {
display: flex; align-items: flex-end; justify-content: space-between;
gap: 16px; margin: 27px 0 13px;
}
.update-config-title h2 { font-size: 22px; margin: 2px 0 3px; }
.update-kicker {
color: var(--accent-text); font: 700 9px var(--font-mono);
letter-spacing: .16em;
}
.update-automation-card { border-color: rgba(124, 92, 255, .18); }
.update-automation-grid {
display: grid; grid-template-columns: repeat(6, minmax(100px, 1fr));
gap: 12px; align-items: end;
}
.update-master-switch { grid-column: span 2; align-self: center; }
.update-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.update-field > span {
color: var(--muted-2); font-size: 10px; font-weight: 700;
letter-spacing: .035em;
}
.update-field input, .update-field select, .update-override-row input,
.update-override-row select {
width: 100%; min-width: 0; color: var(--text);
background: rgba(255, 255, 255, .045); border: 1px solid var(--line);
border-radius: 9px; padding: 9px 10px; outline: none; font: inherit;
font-size: 12px;
}
.update-field input:focus, .update-field select:focus,
.update-override-row input:focus, .update-override-row select:focus {
border-color: rgba(124, 92, 255, .48);
}
.update-field select option, .update-override-row select option { color: #111; }
.update-field small { color: var(--faint); font-size: 10px; line-height: 1.35; }
.update-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--muted); font-size: 11px; }
.update-switch input { width: 15px; height: 15px; accent-color: var(--accent); }
.update-policy-list { display: flex; flex-direction: column; }
.update-policy-row {
display: grid; grid-template-columns: minmax(150px, .8fr) minmax(130px, .8fr) minmax(130px, 1fr) auto;
align-items: end; gap: 12px; padding: 12px 2px;
border-bottom: 1px solid var(--line);
}
.update-policy-row:last-child { border-bottom: 0; }
.update-policy-name { display: flex; flex-direction: column; gap: 6px; align-self: center; }
.update-auto-switch { min-height: 36px; align-self: end; }
.update-managed-only { margin-top: 12px; }
.update-override-list { display: flex; flex-direction: column; }
.update-override-row {
display: grid; grid-template-columns: minmax(140px, 1fr) minmax(120px, .7fr) minmax(120px, .8fr) auto auto;
align-items: center; gap: 9px; padding: 8px 0; border-bottom: 1px solid var(--line);
}
.update-override-id { overflow: hidden; text-overflow: ellipsis; }
.update-empty-inline { padding: 10px 2px; font-size: 12px; }
.update-source-list { display: flex; flex-direction: column; gap: 13px; }
.update-source-card {
min-width: 0; padding: 16px; border: 1px solid var(--line);
border-radius: var(--radius); background: var(--panel);
}
.update-source-card legend {
display: flex; align-items: center; gap: 8px; padding: 0 8px;
font-weight: 700;
}
.update-source-grid {
display: grid; grid-template-columns: minmax(240px, 1.4fr) minmax(220px, 1fr) auto;
align-items: start; gap: 12px; margin-bottom: 17px;
}
.update-unsigned-switch { min-height: 55px; align-self: end; color: var(--yellow-text); }
.update-key-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.update-key-head p { margin-top: 2px; font-size: 11px; }
.update-key-list { display: flex; flex-direction: column; }
.update-key-row {
display: grid; grid-template-columns: minmax(130px, .45fr) minmax(220px, 1.55fr) auto;
align-items: end; gap: 8px; padding: 7px 0;
}
.update-key-remove { margin-bottom: 1px; }
.update-source-foot { display: flex; justify-content: flex-end; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
@media (max-width: 1200px) {
.update-component-grid { grid-template-columns: 1fr; }
.update-component-card { min-height: 0; }
.update-automation-grid { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
.update-master-switch { grid-column: span 1; }
}
@media (max-width: 1000px) {
.updates-two-column { grid-template-columns: 1fr; }
.update-source-grid { grid-template-columns: 1fr 1fr; }
.update-unsigned-switch { grid-column: 1 / -1; min-height: auto; }
}
@media (max-width: 720px) {
.update-command-bar, .update-config-title, .update-sources-head {
align-items: stretch; flex-direction: column;
}
.update-command-bar .row-gap, .update-config-title .row-gap { justify-content: flex-end; }
.update-automation-grid, .update-source-grid { grid-template-columns: 1fr; }
.update-policy-row { grid-template-columns: 1fr 1fr; }
.update-policy-name { grid-column: 1 / -1; }
.update-override-row { grid-template-columns: 1fr 1fr; }
.update-override-id { grid-column: 1 / -1; }
.update-key-row { grid-template-columns: 1fr; padding: 11px 0; }
.update-key-remove { justify-self: start; }
.update-plugin-row { grid-template-columns: minmax(0, 1fr) auto; }
.update-plugin-version { grid-column: 1; }
.update-plugin-actions { grid-column: 2; grid-row: 2; }
}
@media (max-width: 460px) {
.update-policy-row, .update-override-row { grid-template-columns: 1fr; }
.update-policy-name, .update-override-id { grid-column: auto; }
.update-version-line { grid-template-columns: 1fr; }
.update-version-arrow { transform: rotate(90deg); width: fit-content; }
.update-history-table th:nth-child(3), .update-history-table td:nth-child(3) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
.update-beacon { box-shadow: none; }
}
+24
View File
@@ -0,0 +1,24 @@
import { afterEach, describe, expect, it } from 'vitest';
import { renderToStaticMarkup } from 'react-dom/server';
import { appStore } from '../lib/app';
import { UpdatesView } from './UpdatesView';
afterEach(() => appStore.set({ identity: null }));
describe('UpdatesView authorization', () => {
it('shows an authorization guard to non-administrators', () => {
appStore.set({ identity: { nickname: 'listener', isAdmin: false } });
const html = renderToStaticMarkup(<UpdatesView />);
expect(html).toContain('Administrator authentication required');
expect(html).not.toContain('Check now');
});
it('renders the update controls only for an administrator', () => {
appStore.set({ identity: { nickname: 'operator', isAdmin: true } });
const html = renderToStaticMarkup(<UpdatesView />);
expect(html).toContain('Check now');
expect(html).toContain('Update history');
expect(html).not.toContain('Administrator authentication required');
expect(html).toContain('aria-live="polite"');
});
});
File diff suppressed because it is too large. Load diff