Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

refactor([confirm-ux-button-pair-popover-audit]): migrate CatalogTypesTab, show spinner whenever busy

[._.]/ Adam Eivy703d05fa0f66
diff --git a/client/src/components/settings/CatalogTypesTab.jsx b/client/src/components/settings/CatalogTypesTab.jsx
index 4e5b212d92..4f68ba4d1d 100644
--- a/client/src/components/settings/CatalogTypesTab.jsx
+++ b/client/src/components/settings/CatalogTypesTab.jsx
@@ -1,6 +1,7 @@
import { useState } from 'react';
import { Sparkles, Plus, Trash2, Save, X, Loader2 } from 'lucide-react';
import toast from '../ui/Toast';
+import ConfirmButtonPair from '../ui/ConfirmButtonPair';
import { createCatalogType, updateCatalogType, deleteCatalogType } from '../../services/apiCatalogTypes';
import { useCatalogTypes } from '../../hooks/useCatalogTypes.jsx';
import { USER_TYPE_FIELD_KINDS } from '../../lib/catalogTypes';
@@ -154,15 +155,13 @@ export function CatalogTypesTab() {
Edit
</button>
{armedDeleteId === t.id || armedDeleteId === `force:${t.id}` ? (
- <span className="inline-flex items-center gap-1">
- <button type="button" disabled={busy}
- onClick={() => confirmDelete(t.id, { force: armedDeleteId === `force:${t.id}` })}
- className="inline-flex items-center gap-1 px-2 py-1.5 rounded bg-port-error/20 text-port-error hover:bg-port-error/30 text-sm">
- {busy ? <Loader2 size={13} className="animate-spin" /> : <Trash2 size={13} />} Confirm
- </button>
- <button type="button" onClick={() => setArmedDeleteId(null)}
- className="px-2 py-1.5 rounded text-gray-400 hover:text-white text-sm">Cancel</button>
- </span>
+ <ConfirmButtonPair
+ confirmText="Confirm"
+ confirmIcon={Trash2}
+ busy={busy}
+ onConfirm={() => confirmDelete(t.id, { force: armedDeleteId === `force:${t.id}` })}
+ onCancel={() => setArmedDeleteId(null)}
+ />
) : (
<button type="button" onClick={() => setArmedDeleteId(t.id)} disabled={editing !== null}
aria-label={`Delete ${t.label}`}
diff --git a/client/src/components/ui/ConfirmButtonPair.jsx b/client/src/components/ui/ConfirmButtonPair.jsx
index 6c84bc48a7..3e7b6f813c 100644
--- a/client/src/components/ui/ConfirmButtonPair.jsx
+++ b/client/src/components/ui/ConfirmButtonPair.jsx
@@ -27,10 +27,10 @@ export default function ConfirmButtonPair({
className = '',
}) {
const confirmTone = TONES[tone] || TONES.error;
- // While busy with a busyText, swap the confirm icon for a spinner and the
- // label for the in-flight word ("Deleting"); otherwise keep the resting
- // icon/label and just disable both buttons.
- const showSpinner = busy && busyText;
+ // While in-flight, the confirm icon becomes a spinner and both buttons
+ // disable; the label additionally swaps to the in-flight word ("Deleting")
+ // when a busyText is supplied, otherwise it stays put.
+ const confirmLabel = busy && busyText ? busyText : confirmText;
return (
<div
@@ -45,12 +45,12 @@ export default function ConfirmButtonPair({
disabled={busy}
className={`inline-flex items-center gap-1 px-2 py-1 text-xs rounded transition-colors disabled:opacity-50 ${confirmTone}`}
>
- {showSpinner ? (
+ {busy ? (
<Loader2 size={12} className="animate-spin" />
) : ConfirmIcon ? (
<ConfirmIcon size={12} />
) : null}
- {showSpinner ? busyText : confirmText}
+ {confirmLabel}
</button>
<button
type="button"
diff --git a/client/src/components/ui/ConfirmButtonPair.test.jsx b/client/src/components/ui/ConfirmButtonPair.test.jsx
index 13b3bf3e18..6f3100f669 100644
--- a/client/src/components/ui/ConfirmButtonPair.test.jsx
+++ b/client/src/components/ui/ConfirmButtonPair.test.jsx
@@ -42,10 +42,11 @@ describe('ConfirmButtonPair', () => {
expect(confirm.querySelector('svg')).not.toBeNull();
});
- it('disables both buttons while busy', () => {
- render(<ConfirmButtonPair busy />);
+ it('disables both buttons and shows a spinner while busy, keeping the label without busyText', () => {
+ const { container } = render(<ConfirmButtonPair busy />);
expect(screen.getByRole('button', { name: 'Delete' }).disabled).toBe(true);
expect(screen.getByRole('button', { name: 'Cancel' }).disabled).toBe(true);
+ expect(container.querySelector('.animate-spin')).not.toBeNull();
});
it('swaps the confirm label to busyText and shows a spinner when busy with busyText', () => {