ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
feat(views): dirty indicator — Update/Reset on modified views
Juan Denisddb557ec1e64
diff --git a/frontend/src/components/ds/ViewMenu.jsx b/frontend/src/components/ds/ViewMenu.jsxindex 7be880ce..15b84615 100644--- a/frontend/src/components/ds/ViewMenu.jsx+++ b/frontend/src/components/ds/ViewMenu.jsx@@ -15,8 +15,8 @@ import { useToast } from '@/contexts/ToastContext';// <ViewMenu views={views} />export function ViewMenu({ views, className }) {const {- builtinViews, userViews, activeView,- applyView, saveView, updateActiveView, toggleDefault, removeView,+ builtinViews, userViews, activeView, isDirty,+ applyView, saveView, updateActiveView, toggleDefault, removeView, resetView,} = views;const toast = useToast();const [open, setOpen] = useState(false);@@ -108,6 +108,7 @@ export function ViewMenu({ views, className }) {><LayoutList aria-hidden="true" />{activeView ? activeView.name : 'Views'}+ {isDirty && <span className="sk-viewmenu__dot" title="Modified — not saved to this view" />}</Button></PopoverTrigger><PopoverContent align="end" className="sk-tablemenu sk-viewmenu">@@ -125,10 +126,15 @@ export function ViewMenu({ views, className }) {) : (<div className="sk-tablemenu__list">{userViews.map(row)}</div>)}- {activeView && !activeView.builtin && (+ {isDirty && activeView && (<div className="sk-viewmenu__update">- <Button variant="ghost" size="sm" onClick={handleUpdate}>- Update “{activeView.name}” with current state+ {!activeView.builtin && (+ <Button variant="ghost" size="sm" onClick={handleUpdate}>+ Update “{activeView.name}” with changes+ </Button>+ )}+ <Button variant="ghost" size="sm" onClick={resetView}>+ Reset to saved</Button></div>)}diff --git a/frontend/src/hooks/useTableViews.js b/frontend/src/hooks/useTableViews.jsindex 96cad4bf..b86d7a83 100644--- a/frontend/src/hooks/useTableViews.js+++ b/frontend/src/hooks/useTableViews.js@@ -28,6 +28,23 @@ export function useTableViews({ page, builtinViews = [], capture, apply }) {];const activeView = allViews.find((v) => keyOf(v) === activeKey) || null;+ // Dirty tracking: is the live table state different from the active view's+ // saved state? Key-order-agnostic, and hiddenKeys compares as a set (its+ // order is meaningless). Sorts stay order-sensitive — order IS priority.+ const normalize = (state) => {+ if (!state || typeof state !== 'object') return {};+ const out = {};+ for (const key of Object.keys(state).sort()) {+ const value = state[key];+ if (value === undefined) continue;+ out[key] = key === 'hiddenKeys' && Array.isArray(value) ? [...value].sort() : value;+ }+ return out;+ };+ const isDirty = !!activeView && (+ JSON.stringify(normalize(capture())) !== JSON.stringify(normalize(activeView.state))+ );+useEffect(() => {if (!page) { setLoading(false); return undefined; }let cancelled = false;@@ -98,16 +115,23 @@ export function useTableViews({ page, builtinViews = [], capture, apply }) {if (activeKey === keyOf(view)) setActiveKey(null);}, [activeKey]);+ // Re-apply the active view's saved state (discards live tweaks).+ const resetView = useCallback(() => {+ if (activeView) applyView(activeView);+ }, [activeView, applyView]);+return {builtinViews: allViews.filter((v) => v.builtin),userViews,activeView,+ isDirty,loading,applyView,saveView,updateActiveView,toggleDefault,removeView,+ resetView,};}