mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
fix(onboarding): wire applyMutation.mutateAsync everywhere and stabilize list keys
Fix 1 (Critical): Replace all 5 direct applyOnboardingDbSettingsAction calls with applyMutation.mutateAsync throughout the component. Removed result.success guards since mutateAsync throws on error (handled by onError hook). Affected locations: - handleApplyToAll loop - Retention section onSave - Scheduling section onSave - Notifications section onSave - Storage section onSave Fix 2 (Minor): Replace unstable index-based keys with policy.channelId fallback in NotificationsSection and StorageSection card maps. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
d309faf819
commit
a6e528d12b
@@ -408,7 +408,7 @@ const NotificationsSection = ({
|
|||||||
const selected = notifiers.find((n) => n.id === policy.channelId);
|
const selected = notifiers.find((n) => n.id === policy.channelId);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card key={index} className="p-4 flex flex-col gap-3">
|
<Card key={policy.channelId || index} className="p-4 flex flex-col gap-3">
|
||||||
<div className="flex items-end gap-2">
|
<div className="flex items-end gap-2">
|
||||||
<div className="flex-1 flex flex-col gap-1.5">
|
<div className="flex-1 flex flex-col gap-1.5">
|
||||||
<Label className="text-[10px] font-bold text-muted-foreground uppercase tracking-widest">
|
<Label className="text-[10px] font-bold text-muted-foreground uppercase tracking-widest">
|
||||||
@@ -594,7 +594,7 @@ const StorageSection = ({
|
|||||||
const selected = storages.find((s) => s.id === policy.channelId);
|
const selected = storages.find((s) => s.id === policy.channelId);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card key={index} className="p-4 flex items-end gap-2">
|
<Card key={policy.channelId || index} className="p-4 flex items-end gap-2">
|
||||||
<div className="flex-1 flex flex-col gap-1.5">
|
<div className="flex-1 flex flex-col gap-1.5">
|
||||||
<Label className="text-[10px] font-bold text-muted-foreground uppercase tracking-widest">
|
<Label className="text-[10px] font-bold text-muted-foreground uppercase tracking-widest">
|
||||||
Storage Channel
|
Storage Channel
|
||||||
@@ -804,7 +804,7 @@ export const StepDbSettings = () => {
|
|||||||
const handleApplyToAll = async () => {
|
const handleApplyToAll = async () => {
|
||||||
const otherDbIds = databaseIds.filter((id) => id !== dbId);
|
const otherDbIds = databaseIds.filter((id) => id !== dbId);
|
||||||
for (const targetId of otherDbIds) {
|
for (const targetId of otherDbIds) {
|
||||||
const result = await applyOnboardingDbSettingsAction({
|
await applyMutation.mutateAsync({
|
||||||
databaseId: targetId,
|
databaseId: targetId,
|
||||||
section: "all",
|
section: "all",
|
||||||
retention: settings.retention,
|
retention: settings.retention,
|
||||||
@@ -813,10 +813,6 @@ export const StepDbSettings = () => {
|
|||||||
notificationPolicies: settings.notificationPolicies as any,
|
notificationPolicies: settings.notificationPolicies as any,
|
||||||
storagePolicies: settings.storagePolicies,
|
storagePolicies: settings.storagePolicies,
|
||||||
});
|
});
|
||||||
if (!result?.data?.success) {
|
|
||||||
toast.error(`Failed to apply settings to one or more databases.`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const updatedSettings = { ...dbSettings };
|
const updatedSettings = { ...dbSettings };
|
||||||
otherDbIds.forEach((id) => {
|
otherDbIds.forEach((id) => {
|
||||||
@@ -939,16 +935,14 @@ export const StepDbSettings = () => {
|
|||||||
isPending={applyMutation.isPending}
|
isPending={applyMutation.isPending}
|
||||||
onBack={back}
|
onBack={back}
|
||||||
onSave={async (retention) => {
|
onSave={async (retention) => {
|
||||||
const result = await applyOnboardingDbSettingsAction({
|
await applyMutation.mutateAsync({
|
||||||
databaseId: dbId,
|
databaseId: dbId,
|
||||||
section: "retention",
|
section: "retention",
|
||||||
retention,
|
retention,
|
||||||
});
|
});
|
||||||
if (result?.data?.success) {
|
|
||||||
await updateDbSettings(dbId, { retention });
|
await updateDbSettings(dbId, { retention });
|
||||||
toast.success("Retention policy saved.");
|
toast.success("Retention policy saved.");
|
||||||
setPhase({ kind: "db", dbId });
|
setPhase({ kind: "db", dbId });
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -959,17 +953,15 @@ export const StepDbSettings = () => {
|
|||||||
isPending={applyMutation.isPending}
|
isPending={applyMutation.isPending}
|
||||||
onBack={back}
|
onBack={back}
|
||||||
onSave={async (backupMethod, backupCron) => {
|
onSave={async (backupMethod, backupCron) => {
|
||||||
const result = await applyOnboardingDbSettingsAction({
|
await applyMutation.mutateAsync({
|
||||||
databaseId: dbId,
|
databaseId: dbId,
|
||||||
section: "scheduling",
|
section: "scheduling",
|
||||||
backupMethod,
|
backupMethod,
|
||||||
backupCron,
|
backupCron,
|
||||||
});
|
});
|
||||||
if (result?.data?.success) {
|
|
||||||
await updateDbSettings(dbId, { backupMethod, backupCron });
|
await updateDbSettings(dbId, { backupMethod, backupCron });
|
||||||
toast.success("Schedule saved.");
|
toast.success("Schedule saved.");
|
||||||
setPhase({ kind: "db", dbId });
|
setPhase({ kind: "db", dbId });
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -981,16 +973,14 @@ export const StepDbSettings = () => {
|
|||||||
isPending={applyMutation.isPending}
|
isPending={applyMutation.isPending}
|
||||||
onBack={back}
|
onBack={back}
|
||||||
onSave={async (notificationPolicies) => {
|
onSave={async (notificationPolicies) => {
|
||||||
const result = await applyOnboardingDbSettingsAction({
|
await applyMutation.mutateAsync({
|
||||||
databaseId: dbId,
|
databaseId: dbId,
|
||||||
section: "notifications",
|
section: "notifications",
|
||||||
notificationPolicies: notificationPolicies as any,
|
notificationPolicies: notificationPolicies as any,
|
||||||
});
|
});
|
||||||
if (result?.data?.success) {
|
|
||||||
await updateDbSettings(dbId, { notificationPolicies });
|
await updateDbSettings(dbId, { notificationPolicies });
|
||||||
toast.success("Notification policies saved.");
|
toast.success("Notification policies saved.");
|
||||||
setPhase({ kind: "db", dbId });
|
setPhase({ kind: "db", dbId });
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -1002,16 +992,14 @@ export const StepDbSettings = () => {
|
|||||||
isPending={applyMutation.isPending}
|
isPending={applyMutation.isPending}
|
||||||
onBack={back}
|
onBack={back}
|
||||||
onSave={async (storagePolicies) => {
|
onSave={async (storagePolicies) => {
|
||||||
const result = await applyOnboardingDbSettingsAction({
|
await applyMutation.mutateAsync({
|
||||||
databaseId: dbId,
|
databaseId: dbId,
|
||||||
section: "storage",
|
section: "storage",
|
||||||
storagePolicies,
|
storagePolicies,
|
||||||
});
|
});
|
||||||
if (result?.data?.success) {
|
|
||||||
await updateDbSettings(dbId, { storagePolicies });
|
await updateDbSettings(dbId, { storagePolicies });
|
||||||
toast.success("Storage policies saved.");
|
toast.success("Storage policies saved.");
|
||||||
setPhase({ kind: "db", dbId });
|
setPhase({ kind: "db", dbId });
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user