Skip to content

Commit 76336c0

Browse files
author
Mohammod Al Amin Ashik
committed
fix: add toast notification for feature set save in FeatureSetPanel
The save button in FeatureSetPanel was silently refreshing the page without confirming the save to the user. Added success/error toasts and cleaned up unused edit state variables.
1 parent c91c357 commit 76336c0

1 file changed

Lines changed: 7 additions & 27 deletions

File tree

apps/desktop/src/features/featuresets/FeatureSetPanel.tsx

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
Shield,
2121
Save,
2222
} from 'lucide-react';
23-
import { Button } from '@mcpmux/ui';
23+
import { Button, useToast, ToastContainer } from '@mcpmux/ui';
2424
import type { FeatureSet, AddMemberInput } from '@/lib/api/featureSets';
2525
import { setFeatureSetMembers } from '@/lib/api/featureSets';
2626
import type { ServerFeature } from '@/lib/api/serverFeatures';
@@ -48,10 +48,7 @@ export function FeatureSetPanel({ featureSet, spaceId, onClose, onDelete, onUpda
4848
const [isSaving, setIsSaving] = useState(false);
4949
const [error, setError] = useState<string | null>(null);
5050
const [expandedServers, setExpandedServers] = useState<Set<string>>(new Set());
51-
// Edit state for custom sets (setters reserved for future metadata edit UI)
52-
const [editName, _setEditName] = useState(featureSet.name);
53-
const [editDescription, _setEditDescription] = useState(featureSet.description || '');
54-
const [editIcon, _setEditIcon] = useState(featureSet.icon || '');
51+
const { toasts, success, error: showError, dismiss } = useToast();
5552

5653
// Collapsible sections - only one expanded at a time, features by default
5754
const [expandedSections, setExpandedSections] = useState({
@@ -221,30 +218,12 @@ export function FeatureSetPanel({ featureSet, spaceId, onClose, onDelete, onUpda
221218

222219
await setFeatureSetMembers(featureSet.id, members);
223220

224-
// Update metadata if custom
225-
if (isCustom) {
226-
// Only update if changed
227-
if (editName !== featureSet.name ||
228-
editDescription !== (featureSet.description || '') ||
229-
editIcon !== (featureSet.icon || '')) {
230-
// Note: Update logic would go here if API supports it.
231-
// Assuming we might not have updateFeatureSet endpoint exposed fully or need to check
232-
// For now, let's assume we can only update members based on the previous file.
233-
// But wait, ClientsPage.tsx imported updateClient.
234-
// FeatureSetsPage.tsx didn't show updateFeatureSet.
235-
// I'll check if updateFeatureSet is available in the library if not I might need to skip metadata update
236-
// or use what's available.
237-
// The read of FeatureSetsPage.tsx showed createFeatureSet.
238-
// I'll assume for now we just save members, but I added the UI for it.
239-
// If I can't update metadata, I'll remove that part or implement it if possible.
240-
// Let's check imports. I added `updateFeatureSet` to imports but I need to verify if it exists.
241-
// I'll leave it out for now to be safe and just focus on members unless I see it exists.
242-
}
243-
}
244-
221+
success('Changes saved', `"${featureSet.name}" has been updated with ${members.length} feature${members.length !== 1 ? 's' : ''}`);
245222
onUpdate?.();
246223
} catch (e) {
247-
setError(e instanceof Error ? e.message : String(e));
224+
const errorMsg = e instanceof Error ? e.message : String(e);
225+
setError(errorMsg);
226+
showError('Failed to save changes', errorMsg);
248227
} finally {
249228
setIsSaving(false);
250229
}
@@ -299,6 +278,7 @@ export function FeatureSetPanel({ featureSet, spaceId, onClose, onDelete, onUpda
299278

300279
return (
301280
<div className="fixed right-0 top-0 bottom-0 w-full max-w-[45%] min-w-[600px] bg-[rgb(var(--surface))] border-l border-[rgb(var(--border))] shadow-2xl flex flex-col animate-in slide-in-from-right duration-300 z-50">
281+
<ToastContainer toasts={toasts} onClose={dismiss} />
302282
{/* Panel Header */}
303283
<div className="flex-shrink-0 p-4 border-b border-[rgb(var(--border))] bg-[rgb(var(--surface-elevated))]">
304284
<div className="flex items-start justify-between mb-3">

0 commit comments

Comments
 (0)