Compact contour actions and delete VPS applications with all access
Device Core qualification / qualify (push) Successful in 7m19s
Device Core qualification / qualify (push) Successful in 7m19s
This commit is contained in:
@@ -20,7 +20,7 @@ export function B2HostSettings({ host, workspace, onClose, onChanged, onError }:
|
||||
const [expanded, setExpanded] = useState<string[]>([]), [keyRows, setKeyRows] = useState<string[]>([]);
|
||||
const [creating, setCreating] = useState(''), [name, setName] = useState('');
|
||||
const [creationIntent, setCreationIntent] = useState<{ id: string; name: string } | null>(null);
|
||||
const [history, setHistory] = useState<string[]>([]);
|
||||
const [hiddenHistory, setHiddenHistory] = useState<string[]>([]);
|
||||
const [issued, setIssued] = useState<{ applicationId: string; clientId: string; value: string } | null>(null);
|
||||
const [credentialRows, setCredentialRows] = useState<string[]>([]);
|
||||
const [confirm, setConfirm] = useState<{ action: string; fields: Record<string, unknown>; text: string } | null>(null);
|
||||
@@ -46,6 +46,7 @@ export function B2HostSettings({ host, workspace, onClose, onChanged, onError }:
|
||||
setCredentialRows((rows) => [...new Set([...rows, clientId])]);
|
||||
}
|
||||
if (action === 'key-revoke' && issued?.clientId === data.clientId) setIssued(null);
|
||||
if (action === 'application-delete' && issued?.applicationId === data.integrationId) setIssued(null);
|
||||
if (action === 'connect') { setConnection(''); setImportOpen(false); setSection('contours'); }
|
||||
setCreating(''); setName(''); setCreationIntent(null);
|
||||
try { await refresh(); await onChanged(); } catch (error) { onError(error); }
|
||||
@@ -65,13 +66,22 @@ export function B2HostSettings({ host, workspace, onClose, onChanged, onError }:
|
||||
const open = keyRows.includes(app.id), active = app.credentials.some((item) => item.enabled);
|
||||
return <li key={app.id} className="b2-disclosure">
|
||||
<ResourceRow title={app.name} metadata={legacy ? 'Подключение Mission Core · v1' : active ? 'Ключ выдан' : 'Нет действующего ключа'}
|
||||
actions={<IconButton label={`Ключи ${app.name}`} aria-expanded={open} aria-controls={`keys-${app.id}`} onClick={() => setKeyRows(toggle(keyRows, app.id))}><Icon name={open ? 'chevron-up' : 'chevron-down'} /></IconButton>} />
|
||||
actions={<>
|
||||
{open && !legacy ? <>
|
||||
<IconButton label={`История ключей ${app.name}`} aria-pressed={!hiddenHistory.includes(app.id)} onClick={() => setHiddenHistory(toggle(hiddenHistory, app.id))}><Icon name={hiddenHistory.includes(app.id) ? 'eye-off' : 'eye'} /></IconButton>
|
||||
{canManage ? <>
|
||||
<IconButton label={`${active ? 'Перевыпустить' : 'Выдать'} ключ ${app.name}`} disabled={busy} onClick={() => setConfirm({ action: 'key-issue', fields: { integrationId: app.id, replace: active }, text: active ? `Перевыпустить ключ «${app.name}»? Прежний ключ перестанет работать.` : `Выдать ключ «${app.name}»?` })}><Icon name="plus" /></IconButton>
|
||||
<IconButton label={`Удалить приложение ${app.name}`} disabled={busy} onClick={() => setConfirm({ action: 'application-delete', fields: { integrationId: app.id }, text: `Удалить «${app.name}» со всеми ключами и связями с контурами на этом VPS? Доступ приложения прекратится. Устройства, данные контуров и другие приложения сохранятся.` })}><Icon name="trash" /></IconButton>
|
||||
</> : null}
|
||||
</> : null}
|
||||
<IconButton label={`Ключи ${app.name}`} aria-expanded={open} aria-controls={`keys-${app.id}`} onClick={() => setKeyRows(toggle(keyRows, app.id))}><Icon name={open ? 'chevron-up' : 'chevron-down'} /></IconButton>
|
||||
</>} />
|
||||
{open ? <div id={`keys-${app.id}`} className="b2-disclosure__body">
|
||||
{legacy ? <>
|
||||
<dl className="b2-tracker-facts"><dt>Тип подключения</dt><dd>Прямая привязка Mission Core</dd><dt>ID приложения</dt><dd>{app.id}</dd></dl>
|
||||
<p>Это прежняя привязка сервера, без OAuth-ключа. Выпуск и отзыв ключей ниже относятся к приложениям API v2 и не изменяют эту привязку.</p>
|
||||
</> : <>
|
||||
<ResourceList>{app.credentials.filter((item) => item.enabled || history.includes(app.id)).map((item) => {
|
||||
<ResourceList>{app.credentials.filter((item) => item.enabled || !hiddenHistory.includes(app.id)).map((item) => {
|
||||
const keyOpen = credentialRows.includes(item.client_id);
|
||||
const secret = issued?.applicationId === app.id && issued.clientId === item.client_id ? issued : null;
|
||||
return <li key={item.client_id} className="b2-disclosure">
|
||||
@@ -87,10 +97,7 @@ export function B2HostSettings({ host, workspace, onClose, onChanged, onError }:
|
||||
</div> : null}
|
||||
</li>;
|
||||
})}</ResourceList>
|
||||
<div className="b2-actions">
|
||||
{app.credentials.some((item) => !item.enabled) ? <Button variant="ghost" onClick={() => setHistory(toggle(history, app.id))}>{history.includes(app.id) ? 'Скрыть историю' : 'История ключей'}</Button> : null}
|
||||
{canManage ? <Button disabled={busy} onClick={() => setConfirm({ action: 'key-issue', fields: { integrationId: app.id, replace: active }, text: active ? `Перевыпустить ключ «${app.name}»? Прежний ключ перестанет работать.` : `Выдать ключ «${app.name}»?` })}>{active ? 'Перевыпустить ключ' : 'Выдать ключ'}</Button> : null}
|
||||
</div>
|
||||
{!app.credentials.length ? <p>Ключи ещё не выданы</p> : null}
|
||||
</>}
|
||||
</div> : null}
|
||||
</li>;
|
||||
@@ -126,13 +133,16 @@ export function B2HostSettings({ host, workspace, onClose, onChanged, onError }:
|
||||
const available = (status?.contours || []).filter((contour) => !status?.links?.some((link) => link.contourId === contour.id));
|
||||
return <li key={item.projectRef} className="b2-disclosure">
|
||||
<ResourceRow title={item.name} metadata={linked ? 'Контур VPS связан с проектом' : 'Проект Device Core'}
|
||||
actions={<IconButton label={`Контур ${item.name}`} aria-expanded={open} aria-controls={`contour-${item.projectRef}`} onClick={() => setExpanded(toggle(expanded, item.projectRef))}><Icon name={open ? 'chevron-up' : 'chevron-down'} /></IconButton>} />
|
||||
actions={<>
|
||||
{open && linked && canManage ? <IconButton label={`Добавить приложение в ${item.name}`} disabled={busy} onClick={() => { setCreating(item.projectRef); setName(''); setCreationIntent(null); }}><Icon name="plus" /></IconButton> : null}
|
||||
<IconButton label={`Контур ${item.name}`} aria-expanded={open} aria-controls={`contour-${item.projectRef}`} onClick={() => setExpanded(toggle(expanded, item.projectRef))}><Icon name={open ? 'chevron-up' : 'chevron-down'} /></IconButton>
|
||||
</>} />
|
||||
{open ? <div id={`contour-${item.projectRef}`} className="b2-disclosure__body">
|
||||
{!linked ? <>
|
||||
{canManage ? <Button disabled={busy} loading={pending === 'project-connect'} onClick={() => void run('project-connect', { targetProjectRef: item.projectRef })}>Подключить проект к VPS</Button> : null}
|
||||
{available.length ? <Select label="Связать с существующим контуром" value="" options={[{ value: '', label: 'Выбрать контур VPS' }, ...available.map((c) => ({ value: c.id, label: c.name }))]} onChange={(contourId) => { if (contourId) void run('link', { contourId, targetProjectRef: item.projectRef }); }} disabled={busy} /> : null}
|
||||
</> : <>
|
||||
<div className="b2-section-heading"><strong>Приложения и ключи</strong>{canManage ? <IconButton label={`Добавить приложение в ${item.name}`} disabled={busy} onClick={() => { setCreating(item.projectRef); setName(''); setCreationIntent(null); }}><Icon name="plus" /></IconButton> : null}</div>
|
||||
<div className="b2-section-heading"><strong>Приложения и ключи</strong></div>
|
||||
<ResourceList>{apps.map(applicationRow)}</ResourceList>
|
||||
{!apps.length && creating !== item.projectRef ? <p>Ключи приложений ещё не выданы</p> : null}
|
||||
{creating === item.projectRef ? <div className="b2-settings">
|
||||
@@ -149,6 +159,6 @@ export function B2HostSettings({ host, workspace, onClose, onChanged, onError }:
|
||||
})}</ResourceList> : null}
|
||||
</div>
|
||||
</FeatureSettingsWindow>
|
||||
<ConfirmationModal open={Boolean(confirm)} title="Ключ приложения" description={confirm?.text} confirmLabel="Подтвердить" cancelLabel="Отмена" onClose={() => setConfirm(null)} onConfirm={async () => { if (confirm && await run(confirm.action, confirm.fields)) setConfirm(null); }} />
|
||||
<ConfirmationModal open={Boolean(confirm)} title={confirm?.action === 'application-delete' ? 'Удалить приложение' : 'Ключ приложения'} description={confirm?.text} confirmLabel={confirm?.action === 'application-delete' ? 'Удалить приложение' : 'Подтвердить'} cancelLabel="Отмена" onClose={() => setConfirm(null)} onConfirm={async () => { if (confirm && !busy && await run(confirm.action, confirm.fields)) setConfirm(null); }} />
|
||||
</>;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,5 @@
|
||||
.b2-tracker-facts dt { color: var(--nodedc-text-muted); }
|
||||
.b2-tracker-facts dd { margin: 0; overflow-wrap: anywhere; }
|
||||
|
||||
.b2-onboarding-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: var(--nodedc-space-4); align-items: start; }
|
||||
.b2-onboarding-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--nodedc-space-4); align-items: start; }
|
||||
.b2-onboarding-grid > * { min-width: 0; }
|
||||
@media (max-width: 760px) { .b2-onboarding-grid { grid-template-columns: minmax(0, 1fr); } }
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"version": "0.2.2",
|
||||
"filename": "nodedc-arnavi-vps-0.2.2.pyz",
|
||||
"sha256": "de509d4029a0276d42937a5e5f0aacaf7e0851826ad935c0b6679a9212dec2de",
|
||||
"bytes": 16126396,
|
||||
"version": "0.2.3",
|
||||
"filename": "nodedc-arnavi-vps-0.2.3.pyz",
|
||||
"sha256": "0d52c38d0e8afd7c1d72bb59e01d20328f8ac2cd8bb2abfd50f3d265db4bcaf4",
|
||||
"bytes": 16126822,
|
||||
"sourceRepository": "https://git.dcserve.ru/SILVER/NODEDC_MISSION_CORE_ARNAVI-VPS.git",
|
||||
"sourceCommit": "c67afcd6a1328f00bef4f86f1b1baea2cf277f45",
|
||||
"manifestSha256": "dd819af361dee4df4b13e769c3b7a9a7f542f07de30364a6a110b9e6dc8c9108",
|
||||
"sourceCommit": "973e994f02176d438e8ff42f17baccc5fddb6184",
|
||||
"manifestSha256": "b5aa33a08addace744b0ffecc23777fbe56a8d1ea58f6dd59e5161082a6a847a",
|
||||
"environment": "ubuntu-24.04-amd64"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user