Filter dashboard widgets by View
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
dashboardWidgetsForModules,
|
||||
hasAnyScope,
|
||||
hasScope,
|
||||
useEffectiveView,
|
||||
usePlatformModules,
|
||||
type ApiSettings,
|
||||
type AuthInfo,
|
||||
@@ -23,7 +24,14 @@ type DashboardLayout = {
|
||||
|
||||
export default function DashboardPage({ settings, auth }: { settings: ApiSettings; auth: AuthInfo }) {
|
||||
const modules = usePlatformModules();
|
||||
const widgets = useMemo(() => dashboardWidgetsForModules(modules).filter((widget) => canUseWidget(auth, widget)), [auth, modules]);
|
||||
const effectiveView = useEffectiveView();
|
||||
const widgets = useMemo(
|
||||
() =>
|
||||
dashboardWidgetsForModules(modules, effectiveView).filter((widget) =>
|
||||
canUseWidget(auth, widget)
|
||||
),
|
||||
[auth, effectiveView, modules]
|
||||
);
|
||||
const widgetSignature = widgets.map((widget) => widget.id).join("|");
|
||||
const storageKey = `govoplan.dashboard.layout:${auth.active_tenant?.id ?? auth.tenant.id}:${auth.user.id}`;
|
||||
const [layout, setLayout] = useState<DashboardLayout>(() => defaultLayout(widgets));
|
||||
|
||||
Reference in New Issue
Block a user