Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Keep optional Billing Admin cache entries typed explicitly

pulse-triage[bot]7b37fa350b0f
diff --git a/frontend-modern/src/components/Settings/__tests__/BillingAdminReadLifetimes.test.tsx b/frontend-modern/src/components/Settings/__tests__/BillingAdminReadLifetimes.test.tsx
index bf495cd998..8c396fed99 100644
--- a/frontend-modern/src/components/Settings/__tests__/BillingAdminReadLifetimes.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/BillingAdminReadLifetimes.test.tsx
@@ -121,7 +121,9 @@ describe('Billing Admin accepted inventory and billing reads', () => {
await fireEvent.click(screen.getByRole('button', { name: 'Refresh' }));
expect(screen.queryByText('Organization org-a')).not.toBeInTheDocument();
pending.reject(new Error('SYNTHETIC PRIVATE BACKEND DETAIL'));
- await waitFor(() => expect(screen.getByRole('alert')).toHaveTextContent('Failed to load'));
+ await waitFor(() =>
+ expect(screen.getByRole('alert')).toHaveTextContent('Unable to load the organization list.'),
+ );
expect(screen.queryByText(/No organizations/)).not.toBeInTheDocument();
expect(screen.queryByText(/SYNTHETIC PRIVATE/)).not.toBeInTheDocument();
expect(mocks.error).not.toHaveBeenCalled();
@@ -163,7 +165,9 @@ describe('Billing Admin accepted inventory and billing reads', () => {
await settle();
expect(mocks.get).toHaveBeenCalledTimes(2);
expect(screen.queryByText(/SYNTHETIC PRIVATE/)).not.toBeInTheDocument();
- await fireEvent.click(screen.getByRole('button', { name: /Organization org-a/ }));
+ await fireEvent.click(
+ screen.getByRole('button', { name: 'Organization org-a org-a', exact: true }),
+ );
expect(screen.getByRole('status')).toHaveTextContent(BILLING_ADMIN_READ_ERROR);
expect(screen.queryByText(/"loading": true/)).not.toBeInTheDocument();
const before = mocks.put.mock.calls.length;
diff --git a/frontend-modern/src/components/Settings/useBillingAdminPanelState.ts b/frontend-modern/src/components/Settings/useBillingAdminPanelState.ts
index a70e77048a..9e3fb5cfe9 100644
--- a/frontend-modern/src/components/Settings/useBillingAdminPanelState.ts
+++ b/frontend-modern/src/components/Settings/useBillingAdminPanelState.ts
@@ -106,10 +106,10 @@ export function useBillingAdminPanelState() {
const clearSnapshot = () => {
setOrgs([]);
setOrgsError(null);
- setBillingByOrgID(emptyRecord());
- setBillingLoadingByOrgID(emptyRecord());
- setBillingErrorByOrgID(emptyRecord());
- setSavingByOrgID(emptyRecord());
+ setBillingByOrgID(emptyRecord<BillingState | undefined>());
+ setBillingLoadingByOrgID(emptyRecord<boolean>());
+ setBillingErrorByOrgID(emptyRecord<string>());
+ setSavingByOrgID(emptyRecord<boolean>());
setExpandedOrgID(null);
};
@@ -133,7 +133,7 @@ export function useBillingAdminPanelState() {
const state = await BillingAdminAPI.getBillingState(orgID, { signal: controller.signal });
if (!readIsCurrent()) return;
if (!isBillingState(state)) throw new Error('Billing state returned invalid data');
- setBillingByOrgID((prev) => withEntry(prev, orgID, state));
+ setBillingByOrgID((prev) => withEntry<BillingState | undefined>(prev, orgID, state));
} catch (err) {
if (!readIsCurrent()) return;
logger.error('Failed to fetch billing state', { orgID, err });
@@ -231,13 +231,13 @@ export function useBillingAdminPanelState() {
if (!isBillingState(saved) || saved.subscription_state.toLowerCase() !== nextState) {
throw new Error('Billing update did not confirm the requested subscription state');
}
- setBillingByOrgID((prev) => withEntry(prev, orgID, saved));
+ setBillingByOrgID((prev) => withEntry<BillingState | undefined>(prev, orgID, saved));
notificationStore.success(getBillingAdminStateUpdateSuccessMessage(nextState), 2500);
} catch (err) {
if (!writeIsCurrent()) return;
logger.error('Failed to update billing state', { orgID, err });
batch(() => {
- setBillingByOrgID((prev) => withEntry(prev, orgID, undefined));
+ setBillingByOrgID((prev) => withEntry<BillingState | undefined>(prev, orgID, undefined));
setBillingErrorByOrgID((prev) => withEntry(prev, orgID, BILLING_ADMIN_UNCONFIRMED_CHANGE));
});
} finally {
@@ -261,7 +261,7 @@ export function useBillingAdminPanelState() {
billingReads.get(orgID)?.abort();
billingReads.delete(orgID);
batch(() => {
- setBillingByOrgID((prev) => withEntry(prev, orgID, undefined));
+ setBillingByOrgID((prev) => withEntry<BillingState | undefined>(prev, orgID, undefined));
setBillingErrorByOrgID((prev) => {
const next = Object.assign(emptyRecord<string>(), prev);
delete next[orgID];