Web: render component update transactions
This commit is contained in:
5 files changed
+425
-45
No files matched your search
@@ -53,12 +53,22 @@ export const ru: Record<string, string> = {
|
||||
'Downgrade': 'Понижение версии',
|
||||
'Incompatible': 'Несовместимо',
|
||||
'Restart required': 'Нужен перезапуск',
|
||||
'Local only': 'Только локально',
|
||||
'Apply {0}': 'Применить {0}',
|
||||
'Apply Echoion {0}': 'Применить Echoion {0}',
|
||||
'Echoion {0}': 'Echoion {0}',
|
||||
'No update': 'Нет обновления',
|
||||
'Rollback to {0}': 'Откатить до {0}',
|
||||
'Rollback: {0}': 'Откат: {0}',
|
||||
'Rollback target: {0}': 'Цель отката: {0}',
|
||||
'No rollback': 'Откат недоступен',
|
||||
'No prior healthy generation was reported.':
|
||||
'Предыдущее исправное поколение не найдено.',
|
||||
'Enabled': 'Включено',
|
||||
'Source': 'Источник',
|
||||
'Source layout': 'Схема источника',
|
||||
'Component catalogs always require signatures.':
|
||||
'Каталоги компонентов всегда требуют подписи.',
|
||||
'Channel': 'Канал',
|
||||
'{0} source': 'Источник: {0}',
|
||||
'{0} channel': 'Канал: {0}',
|
||||
@@ -89,7 +99,11 @@ export const ru: Record<string, string> = {
|
||||
'Managed': 'Управляемый',
|
||||
'Unmanaged': 'Неуправляемый',
|
||||
'Apply': 'Применить',
|
||||
'Apply transaction': 'Применить транзакцию',
|
||||
'Rollback': 'Откатить',
|
||||
'Restore previous': 'Восстановить предыдущее',
|
||||
'Restore generation': 'Восстановить поколение',
|
||||
'Restore healthy generation': 'Восстановить исправное поколение',
|
||||
'Never': 'Никогда',
|
||||
'Automatic updates armed': 'Автоматические обновления активны',
|
||||
'Automatic updates paused': 'Автоматические обновления приостановлены',
|
||||
@@ -98,6 +112,18 @@ export const ru: Record<string, string> = {
|
||||
'Check now': 'Проверить сейчас',
|
||||
'Checking…': 'Проверка…',
|
||||
'Loading update state…': 'Загрузка состояния обновлений…',
|
||||
'TRANSACTION PREVIEW': 'ПРЕДПРОСМОТР ТРАНЗАКЦИИ',
|
||||
'Stage transaction': 'Подготовить транзакцию',
|
||||
'Stage and restart': 'Подготовить и перезапустить',
|
||||
'Reloadable modules will be quiesced before activation.':
|
||||
'Перезагружаемые модули будут приостановлены перед активацией.',
|
||||
'Echoion will restart and run a 30 second local health check.':
|
||||
'Echoion перезапустится и выполнит локальную проверку состояния в течение 30 секунд.',
|
||||
'Desktop is listed for this release but must update itself locally.':
|
||||
'Desktop входит в этот выпуск, но должен обновиться локально.',
|
||||
'{0} server components · {1}': 'Компоненты сервера: {0} · {1}',
|
||||
'components': 'компоненты',
|
||||
'none': 'нет',
|
||||
'Installed plugins': 'Установленные плагины',
|
||||
'Only managed plugins participate in update activation.':
|
||||
'В активации обновлений участвуют только управляемые плагины.',
|
||||
@@ -153,9 +179,13 @@ export const ru: Record<string, string> = {
|
||||
'После перехода в режим ожидания Echoion будет перезапущен для применения обновления. Продолжить?',
|
||||
'Apply and restart': 'Применить и перезапустить',
|
||||
'{0} update queued': 'Обновление {0} поставлено в очередь',
|
||||
'Component transaction queued': 'Транзакция компонентов поставлена в очередь',
|
||||
'Confirm rollback': 'Подтвердите откат',
|
||||
'Roll back {0} to {1}?': 'Откатить {0} до {1}?',
|
||||
'Atomically restore generation {0} and validate it locally?':
|
||||
'Атомарно восстановить поколение {0} и проверить его локально?',
|
||||
'Rollback queued': 'Откат поставлен в очередь',
|
||||
'Generation rollback queued': 'Откат поколения поставлен в очередь',
|
||||
'Enable unsigned update policy': 'Разрешить политику обновлений без подписи',
|
||||
'Unsigned staging will be permitted for: {0}. Type ENABLE UNSIGNED to save this policy.':
|
||||
'Подготовка без подписи будет разрешена для: {0}. Введите ENABLE UNSIGNED, чтобы сохранить политику.',
|
||||
|
||||
@@ -101,6 +101,10 @@ const RPC_METHOD_BY_INDEX: readonly string[] = [
|
||||
'ApplyUpdate',
|
||||
'RollbackUpdate',
|
||||
'ConfirmUnsignedUpdate', // 95
|
||||
'PreviewUpdateTransaction',
|
||||
'ApplyUpdateTransaction',
|
||||
'RollbackUpdateGeneration',
|
||||
'GetUpdateHistory', // 99
|
||||
];
|
||||
|
||||
export function auditMethodName(method: number): string {
|
||||
|
||||
@@ -87,7 +87,11 @@ export type RpcMethodName =
|
||||
| 'CheckForUpdates'
|
||||
| 'ApplyUpdate'
|
||||
| 'RollbackUpdate'
|
||||
| 'ConfirmUnsignedUpdate';
|
||||
| 'ConfirmUnsignedUpdate'
|
||||
| 'PreviewUpdateTransaction'
|
||||
| 'ApplyUpdateTransaction'
|
||||
| 'RollbackUpdateGeneration'
|
||||
| 'GetUpdateHistory';
|
||||
|
||||
|
||||
type Pending = {
|
||||
|
||||
+107
-12
@@ -1,4 +1,4 @@
|
||||
export type UpdateComponent = 'runtime' | 'core' | 'plugins';
|
||||
export type UpdateComponent = string;
|
||||
|
||||
export interface UpdatePublicKey {
|
||||
id: string;
|
||||
@@ -6,6 +6,7 @@ export interface UpdatePublicKey {
|
||||
}
|
||||
|
||||
export interface UpdateSourceConfig {
|
||||
kind: 'direct' | 'component-layout';
|
||||
url: string;
|
||||
publicKeys: UpdatePublicKey[];
|
||||
allowUnsigned: boolean;
|
||||
@@ -77,10 +78,48 @@ export interface ComponentUpdateStatus {
|
||||
source?: string;
|
||||
candidate?: UpdateCandidate;
|
||||
rollbackVersion?: string;
|
||||
rollbackGeneration?: string;
|
||||
activationMode?: string;
|
||||
requiresRestart?: boolean;
|
||||
localOnly?: boolean;
|
||||
downloadSize?: number;
|
||||
dependencies?: Record<string, string>;
|
||||
lastChangedAt?: string | number;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface UpdateTransactionComponent {
|
||||
componentId: string;
|
||||
pluginId?: string;
|
||||
kind?: string;
|
||||
currentVersion?: string;
|
||||
version: string;
|
||||
candidate?: boolean;
|
||||
activationMode?: string;
|
||||
localOnly?: boolean;
|
||||
requiresRestart?: boolean;
|
||||
downloadSize?: number;
|
||||
dependencies?: Record<string, string>;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface UpdateTransaction {
|
||||
id: string;
|
||||
source?: string;
|
||||
channel?: string;
|
||||
sequence?: number;
|
||||
productVersion?: string;
|
||||
activeGeneration?: string;
|
||||
rollbackGeneration?: string;
|
||||
downloadSize?: number;
|
||||
desktopDownloadSize?: number;
|
||||
requiresRestart?: boolean;
|
||||
compatible?: boolean;
|
||||
applying?: boolean;
|
||||
components: UpdateTransactionComponent[];
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface PluginUpdateStatus {
|
||||
id: string;
|
||||
name?: string;
|
||||
@@ -112,9 +151,10 @@ export interface UpdateStatus {
|
||||
checking: boolean;
|
||||
lastCheckAt?: string | number;
|
||||
nextCheckAt?: string | number;
|
||||
components: Record<UpdateComponent, ComponentUpdateStatus>;
|
||||
components: Record<string, ComponentUpdateStatus>;
|
||||
plugins: PluginUpdateStatus[];
|
||||
history: UpdateHistoryEntry[];
|
||||
transaction?: UpdateTransaction;
|
||||
message?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
@@ -138,6 +178,7 @@ export const DEFAULT_UPDATE_CONFIG: UpdateConfig = {
|
||||
retainHealthyVersions: 2,
|
||||
sources: {
|
||||
official: {
|
||||
kind: 'component-layout',
|
||||
url: '',
|
||||
publicKeys: [],
|
||||
allowUnsigned: false,
|
||||
@@ -232,6 +273,10 @@ export function normalizeUpdateConfig(payload: unknown): UpdateConfig {
|
||||
: [];
|
||||
sources[id] = {
|
||||
...safeSource,
|
||||
kind:
|
||||
source.kind === 'component-layout'
|
||||
? 'component-layout'
|
||||
: 'direct',
|
||||
url: stringValue(source.url),
|
||||
publicKeys: rawKeys.map((key) => {
|
||||
const rawKey = record(key);
|
||||
@@ -335,7 +380,7 @@ function normalizeCandidate(value: unknown): UpdateCandidate | undefined {
|
||||
}
|
||||
|
||||
function normalizeComponent(
|
||||
component: UpdateComponent,
|
||||
component: string,
|
||||
value: unknown
|
||||
): ComponentUpdateStatus {
|
||||
const raw = record(value);
|
||||
@@ -370,6 +415,48 @@ function normalizeComponent(
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeTransaction(value: unknown): UpdateTransaction | undefined {
|
||||
const raw = record(value);
|
||||
const id = stringValue(raw.id || raw.transactionId);
|
||||
if (!id) return undefined;
|
||||
const components: UpdateTransactionComponent[] = Array.isArray(raw.components)
|
||||
? raw.components
|
||||
.flatMap((value): UpdateTransactionComponent[] => {
|
||||
const component = record(value);
|
||||
const componentId = stringValue(component.componentId);
|
||||
const version = stringValue(component.version);
|
||||
if (!componentId || !version) return [];
|
||||
return [{
|
||||
...component,
|
||||
componentId,
|
||||
version,
|
||||
pluginId: stringValue(component.pluginId) || undefined,
|
||||
dependencies: record(component.dependencies) as Record<
|
||||
string,
|
||||
string
|
||||
>,
|
||||
}];
|
||||
})
|
||||
: [];
|
||||
return {
|
||||
...raw,
|
||||
id,
|
||||
components,
|
||||
source: stringValue(raw.source) || undefined,
|
||||
channel: stringValue(raw.channel) || undefined,
|
||||
productVersion: stringValue(raw.productVersion) || undefined,
|
||||
activeGeneration: stringValue(raw.activeGeneration) || undefined,
|
||||
rollbackGeneration: stringValue(raw.rollbackGeneration) || undefined,
|
||||
sequence: numberValue(raw.sequence, 0) || undefined,
|
||||
downloadSize: numberValue(raw.downloadSize, 0) || undefined,
|
||||
desktopDownloadSize:
|
||||
numberValue(raw.desktopDownloadSize, 0) || undefined,
|
||||
requiresRestart: booleanValue(raw.requiresRestart, false),
|
||||
compatible: booleanValue(raw.compatible, true),
|
||||
applying: booleanValue(raw.applying, false),
|
||||
};
|
||||
}
|
||||
|
||||
function normalizePlugin(value: unknown): PluginUpdateStatus | null {
|
||||
const raw = record(value);
|
||||
const id = stringValue(raw.id || raw.pluginId);
|
||||
@@ -413,6 +500,18 @@ export function normalizeUpdateStatus(payload: unknown): UpdateStatus {
|
||||
(Array.isArray(pluginComponent.items) && pluginComponent.items) ||
|
||||
[];
|
||||
const rawHistory = Array.isArray(raw.history) ? raw.history : [];
|
||||
const components: Record<string, ComponentUpdateStatus> = {};
|
||||
for (const [component, value] of Object.entries(rawComponents)) {
|
||||
components[component] = normalizeComponent(component, value);
|
||||
}
|
||||
for (const component of ['runtime', 'core', 'plugins']) {
|
||||
components[component] ||= normalizeComponent(
|
||||
component,
|
||||
component === 'plugins'
|
||||
? pluginComponent
|
||||
: raw[component]
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
...raw,
|
||||
@@ -428,18 +527,12 @@ export function normalizeUpdateStatus(payload: unknown): UpdateStatus {
|
||||
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),
|
||||
},
|
||||
components,
|
||||
plugins: rawPluginEntries
|
||||
.map(normalizePlugin)
|
||||
.filter((plugin): plugin is PluginUpdateStatus => plugin !== null),
|
||||
history: rawHistory.map((entry) => record(entry) as UpdateHistoryEntry),
|
||||
transaction: normalizeTransaction(raw.transaction),
|
||||
message: stringValue(raw.message) || undefined,
|
||||
};
|
||||
}
|
||||
@@ -451,8 +544,10 @@ export function configForSave(config: UpdateConfig): UpdateConfig {
|
||||
const { bearerTokenPresent: _present, ...writable } = source;
|
||||
sources[id] = {
|
||||
...sourceFieldsWithoutSecrets(writable),
|
||||
kind: source.kind,
|
||||
url: source.url.trim(),
|
||||
allowUnsigned: source.allowUnsigned,
|
||||
allowUnsigned:
|
||||
source.kind === 'component-layout' ? false : source.allowUnsigned,
|
||||
bearerTokenEnv: source.bearerTokenEnv.trim(),
|
||||
publicKeys: source.publicKeys
|
||||
.map((key) => ({
|
||||
|
||||
@@ -24,18 +24,40 @@ import {
|
||||
type UpdateConfig,
|
||||
type UpdateSourceConfig,
|
||||
type UpdateStatus,
|
||||
type UpdateTransaction,
|
||||
} from '../lib/updates';
|
||||
|
||||
const COMPONENTS: readonly UpdateComponent[] = [
|
||||
'runtime',
|
||||
'core',
|
||||
'plugins',
|
||||
];
|
||||
const COMPONENTS = ['runtime', 'core', 'plugins'] as const;
|
||||
type PolicyComponent = (typeof COMPONENTS)[number];
|
||||
|
||||
function componentLabel(component: UpdateComponent): string {
|
||||
function componentLabel(component: string): string {
|
||||
if (component === 'runtime') return t('Runtime bundle');
|
||||
if (component === 'core') return t('Core');
|
||||
return t('Plugins');
|
||||
if (component === 'plugins') return t('Plugins');
|
||||
const labels: Record<string, string> = {
|
||||
EchoionApi: 'API SDK',
|
||||
EchoionHost: 'Host',
|
||||
EchoionCore: 'Core',
|
||||
EchoionWeb: 'Web',
|
||||
EchoionStandalone: 'Standalone',
|
||||
EchoionUpdater: 'Updater',
|
||||
EchoionDesktop: 'Desktop',
|
||||
EchoionPluginUrlShortenerInternal: 'URL shortener · internal',
|
||||
EchoionPluginUrlShortenerExternal: 'URL shortener · external',
|
||||
};
|
||||
return labels[component] || component.replace(/([a-z])([A-Z])/g, '$1 $2');
|
||||
}
|
||||
|
||||
function formatBytes(value?: number): string {
|
||||
if (!value || value < 0) return '0 B';
|
||||
const units = ['B', 'KiB', 'MiB', 'GiB'];
|
||||
let size = value;
|
||||
let unit = 0;
|
||||
while (size >= 1024 && unit < units.length - 1) {
|
||||
size /= 1024;
|
||||
unit += 1;
|
||||
}
|
||||
return `${size.toFixed(unit ? 1 : 0)} ${units[unit]}`;
|
||||
}
|
||||
|
||||
function formatTimestamp(value?: string | number): string {
|
||||
@@ -117,11 +139,13 @@ function ComponentCard(props: {
|
||||
}) {
|
||||
const candidate = props.status.candidate;
|
||||
const component = props.status.component;
|
||||
const rollback =
|
||||
props.status.rollbackGeneration || props.status.rollbackVersion;
|
||||
return (
|
||||
<article className="update-component-card">
|
||||
<div className="update-component-head">
|
||||
<div className={`update-component-mark ${component}`} aria-hidden="true">
|
||||
{component === 'runtime' ? 'R' : component === 'core' ? 'C' : 'P'}
|
||||
<div className="update-component-mark" aria-hidden="true">
|
||||
{componentLabel(component).slice(0, 1).toUpperCase()}
|
||||
</div>
|
||||
<div>
|
||||
<h2>{componentLabel(component)}</h2>
|
||||
@@ -148,6 +172,23 @@ function ComponentCard(props: {
|
||||
</div>
|
||||
|
||||
{candidate && <CandidateBadges candidate={candidate} />}
|
||||
<div className="update-badges">
|
||||
{props.status.activationMode && (
|
||||
<StatusBadge>{props.status.activationMode}</StatusBadge>
|
||||
)}
|
||||
{props.status.localOnly && <StatusBadge>{t('Local only')}</StatusBadge>}
|
||||
{!!props.status.downloadSize && (
|
||||
<StatusBadge>{formatBytes(props.status.downloadSize)}</StatusBadge>
|
||||
)}
|
||||
</div>
|
||||
{props.status.dependencies &&
|
||||
Object.keys(props.status.dependencies).length > 0 && (
|
||||
<p className="muted mono">
|
||||
{Object.entries(props.status.dependencies)
|
||||
.map(([id, range]) => `${id} ${range}`)
|
||||
.join(' · ')}
|
||||
</p>
|
||||
)}
|
||||
{(candidate?.message || props.status.message) && (
|
||||
<p className="update-card-message">
|
||||
{candidate?.message || props.status.message}
|
||||
@@ -157,10 +198,11 @@ function ComponentCard(props: {
|
||||
<div className="update-card-actions">
|
||||
<button
|
||||
className="btn btn-accent"
|
||||
disabled={
|
||||
disabled={
|
||||
props.busy ||
|
||||
!candidate ||
|
||||
candidate.compatible === false
|
||||
candidate.compatible === false ||
|
||||
props.status.localOnly
|
||||
}
|
||||
onClick={props.onApply}
|
||||
>
|
||||
@@ -168,11 +210,11 @@ function ComponentCard(props: {
|
||||
</button>
|
||||
<button
|
||||
className="btn btn-ghost"
|
||||
disabled={props.busy || !props.status.rollbackVersion}
|
||||
disabled={props.busy || !rollback || props.status.localOnly}
|
||||
onClick={props.onRollback}
|
||||
>
|
||||
{props.status.rollbackVersion
|
||||
? tf('Rollback to {0}', props.status.rollbackVersion)
|
||||
{rollback
|
||||
? tf('Rollback to {0}', rollback)
|
||||
: t('No rollback')}
|
||||
</button>
|
||||
</div>
|
||||
@@ -181,7 +223,7 @@ function ComponentCard(props: {
|
||||
}
|
||||
|
||||
function PolicyEditor(props: {
|
||||
component: UpdateComponent;
|
||||
component: PolicyComponent;
|
||||
policy: ComponentUpdatePolicy;
|
||||
sourceIds: string[];
|
||||
onChange: (policy: ComponentUpdatePolicy) => void;
|
||||
@@ -275,6 +317,25 @@ function SourceEditor(props: {
|
||||
)}
|
||||
</legend>
|
||||
<div className="update-source-grid">
|
||||
<label className="update-field">
|
||||
<span>{t('Source layout')}</span>
|
||||
<select
|
||||
value={props.source.kind}
|
||||
onChange={(event) =>
|
||||
props.onChange({
|
||||
...props.source,
|
||||
kind: event.target.value as UpdateSourceConfig['kind'],
|
||||
allowUnsigned:
|
||||
event.target.value === 'component-layout'
|
||||
? false
|
||||
: props.source.allowUnsigned,
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="component-layout">component-layout</option>
|
||||
<option value="direct">direct</option>
|
||||
</select>
|
||||
</label>
|
||||
<label className="update-field update-field-wide">
|
||||
<span>{t('Feed URL')}</span>
|
||||
<input
|
||||
@@ -282,7 +343,9 @@ function SourceEditor(props: {
|
||||
placeholder={
|
||||
props.id === 'official'
|
||||
? t('Empty uses the release build default')
|
||||
: 'https://updates.example/feed.json'
|
||||
: props.source.kind === 'component-layout'
|
||||
? 'https://updates.example/echoion'
|
||||
: 'https://updates.example/feed.json'
|
||||
}
|
||||
value={props.source.url}
|
||||
onChange={(event) =>
|
||||
@@ -320,6 +383,7 @@ function SourceEditor(props: {
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={props.source.allowUnsigned}
|
||||
disabled={props.source.kind === 'component-layout'}
|
||||
onChange={(event) =>
|
||||
props.onChange({
|
||||
...props.source,
|
||||
@@ -328,6 +392,9 @@ function SourceEditor(props: {
|
||||
}
|
||||
/>
|
||||
<span>{t('Permit manual unsigned staging')}</span>
|
||||
{props.source.kind === 'component-layout' && (
|
||||
<small>{t('Component catalogs always require signatures.')}</small>
|
||||
)}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@@ -514,7 +581,7 @@ export function UpdatesView() {
|
||||
}
|
||||
|
||||
function changePolicy(
|
||||
component: UpdateComponent,
|
||||
component: PolicyComponent,
|
||||
policy: ComponentUpdatePolicy
|
||||
) {
|
||||
if (!draft) return;
|
||||
@@ -621,6 +688,73 @@ export function UpdatesView() {
|
||||
setBusy('');
|
||||
}
|
||||
|
||||
async function applyComponentTransaction(transaction: UpdateTransaction) {
|
||||
if (transaction.compatible === false || transaction.applying) return;
|
||||
const serverComponents = transaction.components.filter(
|
||||
(component) => !component.localOnly
|
||||
);
|
||||
const desktopComponents = transaction.components.filter(
|
||||
(component) => component.localOnly
|
||||
);
|
||||
const details = [
|
||||
tf('{0} server components · {1}',
|
||||
serverComponents.length,
|
||||
formatBytes(transaction.downloadSize)),
|
||||
transaction.requiresRestart
|
||||
? t('Echoion will restart and run a 30 second local health check.')
|
||||
: t('Reloadable modules will be quiesced before activation.'),
|
||||
transaction.rollbackGeneration
|
||||
? tf('Rollback target: {0}', transaction.rollbackGeneration)
|
||||
: t('No prior healthy generation was reported.'),
|
||||
desktopComponents.length
|
||||
? t('Desktop is listed for this release but must update itself locally.')
|
||||
: '',
|
||||
].filter(Boolean);
|
||||
const confirmed = await confirmDialog({
|
||||
title: tf(
|
||||
'Apply Echoion {0}',
|
||||
transaction.productVersion || transaction.id.slice(0, 12)
|
||||
),
|
||||
message: details.join('\n'),
|
||||
confirmLabel: transaction.requiresRestart
|
||||
? t('Stage and restart')
|
||||
: t('Stage transaction'),
|
||||
});
|
||||
if (!confirmed) return;
|
||||
setBusy(`transaction:${transaction.id}`);
|
||||
const payload = await safeCall<unknown>('ApplyUpdateTransaction', {
|
||||
transactionId: transaction.id,
|
||||
});
|
||||
if (payload !== null) {
|
||||
await loadStatus();
|
||||
toast(t('Component transaction queued'));
|
||||
}
|
||||
setBusy('');
|
||||
}
|
||||
|
||||
async function rollbackGeneration(generation?: string) {
|
||||
if (!generation) return;
|
||||
const confirmed = await confirmDialog({
|
||||
title: t('Restore healthy generation'),
|
||||
message: tf(
|
||||
'Atomically restore generation {0} and validate it locally?',
|
||||
generation
|
||||
),
|
||||
confirmLabel: t('Restore generation'),
|
||||
danger: true,
|
||||
});
|
||||
if (!confirmed) return;
|
||||
setBusy(`generation:${generation}`);
|
||||
const payload = await safeCall<unknown>('RollbackUpdateGeneration', {
|
||||
generationId: generation,
|
||||
});
|
||||
if (payload !== null) {
|
||||
await loadStatus();
|
||||
toast(t('Generation rollback queued'));
|
||||
}
|
||||
setBusy('');
|
||||
}
|
||||
|
||||
async function rollbackUpdate(
|
||||
component: UpdateComponent,
|
||||
version?: string,
|
||||
@@ -702,6 +836,7 @@ export function UpdatesView() {
|
||||
sources: {
|
||||
...draft.sources,
|
||||
[id]: {
|
||||
kind: 'direct',
|
||||
url: '',
|
||||
publicKeys: [],
|
||||
allowUnsigned: false,
|
||||
@@ -764,6 +899,39 @@ export function UpdatesView() {
|
||||
});
|
||||
}
|
||||
|
||||
const componentStatuses = status
|
||||
? Object.values(status.components)
|
||||
.filter(
|
||||
(component) =>
|
||||
component.component === 'runtime' ||
|
||||
(component.component !== 'core' &&
|
||||
component.component !== 'plugins') ||
|
||||
(component.component === 'core' &&
|
||||
!status.components.EchoionCore) ||
|
||||
(component.component === 'plugins' &&
|
||||
!status.transaction)
|
||||
)
|
||||
.sort((left, right) => {
|
||||
const order = [
|
||||
'runtime',
|
||||
'EchoionApi',
|
||||
'EchoionHost',
|
||||
'EchoionStandalone',
|
||||
'EchoionCore',
|
||||
'EchoionWeb',
|
||||
'EchoionUpdater',
|
||||
'EchoionDesktop',
|
||||
];
|
||||
const leftIndex = order.indexOf(left.component);
|
||||
const rightIndex = order.indexOf(right.component);
|
||||
return (
|
||||
(leftIndex < 0 ? order.length : leftIndex) -
|
||||
(rightIndex < 0 ? order.length : rightIndex) ||
|
||||
left.component.localeCompare(right.component)
|
||||
);
|
||||
})
|
||||
: [];
|
||||
|
||||
if (!isAdmin) {
|
||||
return (
|
||||
<section className="view" id="view-updates">
|
||||
@@ -823,24 +991,103 @@ export function UpdatesView() {
|
||||
{loading ? t('Loading update state…') : status?.message || ''}
|
||||
</div>
|
||||
|
||||
{status?.transaction && (
|
||||
<div className="card update-transaction-preview">
|
||||
<div className="card-head">
|
||||
<div>
|
||||
<span className="update-kicker">{t('TRANSACTION PREVIEW')}</span>
|
||||
<h2>
|
||||
{tf(
|
||||
'Echoion {0}',
|
||||
status.transaction.productVersion || '—'
|
||||
)}
|
||||
</h2>
|
||||
<p className="muted mono">
|
||||
{status.transaction.source} · {status.transaction.channel} ·{' '}
|
||||
{formatBytes(status.transaction.downloadSize)}
|
||||
</p>
|
||||
</div>
|
||||
<div className="row-gap">
|
||||
{status.transaction.rollbackGeneration && (
|
||||
<button
|
||||
className="btn btn-ghost"
|
||||
disabled={!!busy}
|
||||
onClick={() =>
|
||||
void rollbackGeneration(
|
||||
status.transaction?.rollbackGeneration
|
||||
)
|
||||
}
|
||||
>
|
||||
{t('Restore previous')}
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
className="btn btn-accent"
|
||||
disabled={
|
||||
!!busy ||
|
||||
status.transaction.compatible === false ||
|
||||
status.transaction.applying
|
||||
}
|
||||
onClick={() =>
|
||||
void applyComponentTransaction(status.transaction!)
|
||||
}
|
||||
>
|
||||
{status.transaction.requiresRestart
|
||||
? t('Stage and restart')
|
||||
: t('Apply transaction')}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="update-badges">
|
||||
<StatusBadge tone="success">
|
||||
{status.transaction.components.length} {t('components')}
|
||||
</StatusBadge>
|
||||
{status.transaction.requiresRestart && (
|
||||
<StatusBadge tone="warning">{t('Restart required')}</StatusBadge>
|
||||
)}
|
||||
<StatusBadge>
|
||||
{tf(
|
||||
'Rollback: {0}',
|
||||
status.transaction.rollbackGeneration || t('none')
|
||||
)}
|
||||
</StatusBadge>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="update-component-grid">
|
||||
{status && COMPONENTS.map((component) => (
|
||||
{componentStatuses.map((componentStatus) => (
|
||||
<ComponentCard
|
||||
key={component}
|
||||
status={status.components[component]}
|
||||
key={componentStatus.component}
|
||||
status={componentStatus}
|
||||
busy={!!busy}
|
||||
onApply={() =>
|
||||
void applyUpdate(
|
||||
component,
|
||||
status.components[component].candidate
|
||||
)
|
||||
}
|
||||
onRollback={() =>
|
||||
void rollbackUpdate(
|
||||
component,
|
||||
status.components[component].rollbackVersion
|
||||
)
|
||||
}
|
||||
onApply={() => {
|
||||
if (
|
||||
status?.transaction &&
|
||||
!COMPONENTS.some(
|
||||
(component) => component === componentStatus.component
|
||||
)
|
||||
) {
|
||||
void applyComponentTransaction(status.transaction);
|
||||
} else {
|
||||
void applyUpdate(
|
||||
componentStatus.component,
|
||||
componentStatus.candidate
|
||||
);
|
||||
}
|
||||
}}
|
||||
onRollback={() => {
|
||||
if (componentStatus.rollbackGeneration) {
|
||||
void rollbackGeneration(
|
||||
componentStatus.rollbackGeneration
|
||||
);
|
||||
} else {
|
||||
void rollbackUpdate(
|
||||
componentStatus.component,
|
||||
componentStatus.rollbackVersion
|
||||
);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user