From 44add57109326bb8d747488d31571776b5089a21 Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 29 Oct 2026 09:08:35 +0100 Subject: [PATCH] fix(client): hide the new identity action on a managed install --- .../src/components/Admin/ServiceIdentityPanel.test.tsx | 9 ++++++++- client/src/components/Admin/ServiceIdentityPanel.tsx | 5 +++-- client/src/pages/admin/AdminSettingsTab.tsx | 2 +- client/src/pages/admin/TrekApiCard.tsx | 5 +++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/client/src/components/Admin/ServiceIdentityPanel.test.tsx b/client/src/components/Admin/ServiceIdentityPanel.test.tsx index 3079a123e..2e29816a9 100644 --- a/client/src/components/Admin/ServiceIdentityPanel.test.tsx +++ b/client/src/components/Admin/ServiceIdentityPanel.test.tsx @@ -1,4 +1,4 @@ -// FE-ADMIN-SVCID-001 to FE-ADMIN-SVCID-007 +// FE-ADMIN-SVCID-001 to FE-ADMIN-SVCID-008 import userEvent from '@testing-library/user-event'; import type { ServiceIdentityStatus } from '@trek/shared'; import { http, HttpResponse } from 'msw'; @@ -103,4 +103,11 @@ describe('ServiceIdentityPanel', () => { await waitFor(() => expect(regenerated).toBe(1)); expect(await screen.findByText('admin.trekApi.quota.hint.registering')).toBeInTheDocument(); }); + + it('FE-ADMIN-SVCID-008: a managed install leaves the identity to its operator', async () => { + serve({ state: 'revoked', tier: 'std', keySource: 'registered', quota: null, lastSeenAt: null }); + render(); + expect(await screen.findByText('admin.trekApi.quota.hint.revoked')).toBeInTheDocument(); + expect(screen.queryByRole('button', { name: 'admin.trekApi.quota.regenerate' })).toBeNull(); + }); }); diff --git a/client/src/components/Admin/ServiceIdentityPanel.tsx b/client/src/components/Admin/ServiceIdentityPanel.tsx index 61dd36eb0..cdc4fd929 100644 --- a/client/src/components/Admin/ServiceIdentityPanel.tsx +++ b/client/src/components/Admin/ServiceIdentityPanel.tsx @@ -81,8 +81,9 @@ function stateHint(t: TranslationFn, status: ServiceIdentityStatus | null, faile * How this installation stands with the TREK services: whether it has its key, * today's allowance against what is used, and when the count starts again. * Read when the card is in view and refreshed every 30 seconds while it stays. + * A managed install leaves the identity to its operator, so it offers no new one. */ -export default function ServiceIdentityPanel() { +export default function ServiceIdentityPanel({ managed = false }: { managed?: boolean }) { const { t } = useTranslation(); const toast = useToast(); const panel = useRef(null); @@ -100,7 +101,7 @@ export default function ServiceIdentityPanel() { }; const hint = stateHint(t, status, failed); - const canRegenerate = status !== null && status.keySource !== 'env' && status.state !== 'off'; + const canRegenerate = !managed && status !== null && status.keySource !== 'env' && status.state !== 'off'; return (
+ {!managed && (<> diff --git a/client/src/pages/admin/TrekApiCard.tsx b/client/src/pages/admin/TrekApiCard.tsx index 52eecc23b..e55570948 100644 --- a/client/src/pages/admin/TrekApiCard.tsx +++ b/client/src/pages/admin/TrekApiCard.tsx @@ -10,6 +10,7 @@ import { TREK_API_SOURCES as SOURCES, trekApiFacts, trekApiFields } from '../../ interface TrekApiCardProps { t: TranslationFn + managed?: boolean } /** @@ -41,7 +42,7 @@ function FactGroup({ icon, title, note, children }: { icon: React.ReactNode; tit ) } -export default function TrekApiCard({ t }: TrekApiCardProps): React.ReactElement { +export default function TrekApiCard({ t, managed = false }: TrekApiCardProps): React.ReactElement { const fields = trekApiFields(t) const facts = trekApiFacts(t) @@ -73,7 +74,7 @@ export default function TrekApiCard({ t }: TrekApiCardProps): React.ReactElement ))} - +