171 lines
6.8 KiB
TypeScript
171 lines
6.8 KiB
TypeScript
import { Link } from '@inertiajs/react';
|
|
import { Management, button, control } from '../management/shared';
|
|
import {
|
|
useProfileSupportInstallation,
|
|
type SupportPlan,
|
|
} from '@/lib/profile-support-installation';
|
|
function SupportInstallationForm({ initial }: { initial: SupportPlan }) {
|
|
const edit = useProfileSupportInstallation(initial),
|
|
plan = edit.plan;
|
|
return (
|
|
<section className="space-y-4">
|
|
<p>
|
|
Destino: {plan.target.database}:{plan.target.port}
|
|
</p>
|
|
<p>
|
|
{plan.installed
|
|
? 'Suporte técnico actualizado'
|
|
: plan.repairable
|
|
? 'Migração registada com a restrição anterior; reposição delimitada disponível.'
|
|
: 'Actualização do Suporte técnico por aplicar'}
|
|
</p>
|
|
<p>
|
|
{plan.ready
|
|
? 'Provas actuais verificadas.'
|
|
: 'Dependências ou provas por completar.'}{' '}
|
|
Backup/restauro: {plan.backupDate ?? 'Prova actual pendente'}
|
|
</p>
|
|
{!plan.mfa_confirmed && (
|
|
<p role="alert">
|
|
Renove a autenticação MFA nesta conta antes de aplicar a
|
|
actualização.
|
|
</p>
|
|
)}
|
|
{!plan.consistent && !plan.repairable && (
|
|
<p role="alert">
|
|
A estrutura não corresponde à versão reconhecida. Preserve
|
|
os dados e reconcilie a divergência antes de instalar.
|
|
</p>
|
|
)}
|
|
<ul>
|
|
{Object.entries(plan.dependencies).map(([name, ok]) => (
|
|
<li key={name}>
|
|
{(
|
|
{
|
|
profiles_installed: 'Base dos perfis instalada',
|
|
profiles_consistent:
|
|
'Base dos perfis consistente',
|
|
management_020000: 'Gestão de oportunidades',
|
|
resources_030000: 'Recursos das oportunidades',
|
|
existing_identity_organization_audit:
|
|
'Identidades, organizações e auditoria',
|
|
} as Record<string, string>
|
|
)[name] ?? 'Dependência da instalação'}
|
|
: {ok ? 'presente' : 'pendente'}
|
|
</li>
|
|
))}
|
|
</ul>
|
|
<ul>
|
|
{plan.changes.map((change) => (
|
|
<li key={change}>{change}</li>
|
|
))}
|
|
</ul>
|
|
<p>{plan.rollback}</p>
|
|
{edit.stale && (
|
|
<section
|
|
className="space-y-2 rounded border p-3"
|
|
aria-label="Comparar prévia da actualização"
|
|
>
|
|
<h2 className="font-semibold">A prévia mudou</h2>
|
|
<p>
|
|
Anterior:{' '}
|
|
{edit.base.installed ? 'Actualizado' : 'Por actualizar'}{' '}
|
|
·{' '}
|
|
{edit.base.ready
|
|
? 'Provas verificadas'
|
|
: 'Provas pendentes'}{' '}
|
|
· {edit.base.backupDate ?? 'Sem prova actual'}
|
|
</p>
|
|
<p>
|
|
Actual:{' '}
|
|
{plan.installed ? 'Actualizado' : 'Por actualizar'} ·{' '}
|
|
{plan.ready ? 'Provas verificadas' : 'Provas pendentes'}{' '}
|
|
· {plan.backupDate ?? 'Sem prova actual'}
|
|
</p>
|
|
<p>
|
|
Confira novamente o destino, a estrutura e as alterações
|
|
indicadas antes de confirmar.
|
|
</p>
|
|
<button
|
|
type="button"
|
|
className={button}
|
|
disabled={!edit.canAdopt}
|
|
onClick={edit.adopt}
|
|
>
|
|
Confirmar leitura da prévia actual
|
|
</button>
|
|
</section>
|
|
)}
|
|
<label className="block">
|
|
Fundamento da actualização
|
|
<textarea
|
|
className={control}
|
|
minLength={20}
|
|
maxLength={1000}
|
|
value={edit.reason}
|
|
onChange={(event) => edit.change(event.target.value)}
|
|
/>
|
|
</label>
|
|
<label className="block">
|
|
<input
|
|
type="checkbox"
|
|
checked={edit.confirmed}
|
|
disabled={edit.busy || edit.uncertain}
|
|
onChange={(event) =>
|
|
edit.setConfirmed(event.target.checked)
|
|
}
|
|
/>{' '}
|
|
Confirmo esta actualização no destino indicado
|
|
</label>
|
|
{edit.uncertain && (
|
|
<p>
|
|
O envio original aguarda confirmação. A repetição conserva o
|
|
plano, o fundamento e a confirmação originais.
|
|
</p>
|
|
)}
|
|
<div className="flex flex-wrap gap-3">
|
|
<button
|
|
type="button"
|
|
className={button}
|
|
disabled={!edit.canSend}
|
|
onClick={() => void edit.send()}
|
|
>
|
|
Aplicar actualização do Suporte técnico
|
|
</button>
|
|
{edit.canRetry && (
|
|
<button
|
|
type="button"
|
|
className={button}
|
|
onClick={() => void edit.send(true)}
|
|
>
|
|
Repetir envio original
|
|
</button>
|
|
)}
|
|
<button
|
|
type="button"
|
|
className={button}
|
|
disabled={edit.refreshing}
|
|
onClick={() => void edit.refresh()}
|
|
>
|
|
Actualizar prévia
|
|
</button>
|
|
</div>
|
|
{edit.message && <p role="status">{edit.message}</p>}
|
|
{edit.error && <p role="alert">{edit.error}</p>}
|
|
</section>
|
|
);
|
|
}
|
|
export default function SupportInstallation(plan: SupportPlan) {
|
|
return (
|
|
<Management title="Actualizar Suporte técnico">
|
|
<Link className="underline" href="/management/profile-install">
|
|
Voltar à instalação dos perfis
|
|
</Link>
|
|
<SupportInstallationForm
|
|
key={`${plan.actorId}:${plan.target.database}:${plan.target.port}`}
|
|
initial={plan}
|
|
/>
|
|
</Management>
|
|
);
|
|
}
|