fix(gui): wire create modal onSuccess callbacks and fix short-lived profile UX

- All 5 create modals (Profiles, Teams, Owners, Policies, Agent Groups)
  had no-op onSuccess callbacks — API call fired but modal never closed
  and list never refreshed. Wired invalidateQueries + setShowCreate.
- Removed silent try/catch error swallowing so API errors surface in UI.
- Profile create: auto-set TTL to 300s when short-lived checkbox enabled
  with TTL >= 3600, added validation hint and warning text.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Shankar
2026-03-28 14:28:56 -04:00
parent b908937583
commit ff7e15043c
5 changed files with 73 additions and 66 deletions
+12 -13
View File
@@ -40,18 +40,14 @@ function CreatePolicyModal({ isOpen, onClose, onSuccess, isLoading, error }: Cre
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
if (!name.trim()) return;
try {
const config = JSON.parse(configStr);
await createPolicy({ name: name.trim(), type, severity, config, enabled });
setName('');
setType('key_algorithm');
setSeverity('medium');
setConfigStr('{}');
setEnabled(true);
onSuccess();
} catch (err) {
console.error('Create policy error:', err);
}
const config = JSON.parse(configStr);
await createPolicy({ name: name.trim(), type, severity, config, enabled });
setName('');
setType('key_algorithm');
setSeverity('medium');
setConfigStr('{}');
setEnabled(true);
onSuccess();
};
if (!isOpen) return null;
@@ -269,7 +265,10 @@ export default function PoliciesPage() {
<CreatePolicyModal
isOpen={showCreate}
onClose={() => setShowCreate(false)}
onSuccess={() => {}}
onSuccess={() => {
queryClient.invalidateQueries({ queryKey: ['policies'] });
setShowCreate(false);
}}
isLoading={createMutation.isPending}
error={createMutation.error ? (createMutation.error as Error).message : null}
/>