fix(client): hide the new identity action on a managed install

This commit is contained in:
Maurice
2026-10-29 09:08:35 +01:00
committed by Maurice
parent afacf00c9f
commit 44add57109
4 changed files with 15 additions and 6 deletions
@@ -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(<ServiceIdentityPanel managed />);
expect(await screen.findByText('admin.trekApi.quota.hint.revoked')).toBeInTheDocument();
expect(screen.queryByRole('button', { name: 'admin.trekApi.quota.regenerate' })).toBeNull();
});
});
@@ -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<HTMLElement>(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 (
<section
+1 -1
View File
@@ -387,7 +387,7 @@ export default function AdminSettingsTab({ admin, t }: AdminSettingsTabProps): R
{/* Three comparable blocks, in the order we would have people choose
them. Weather moved out entirely: it needs no key and had nothing
to configure, so it had no business in a card about keys. */}
<TrekApiCard t={t} />
<TrekApiCard t={t} managed={managed} />
{!managed && (<>
<ProviderBlock title={t('admin.mapsKey')}>
+3 -2
View File
@@ -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
))}
</ul>
<ServiceIdentityPanel />
<ServiceIdentityPanel managed={managed} />
</div>
<details className="group border-t border-edge-faint">