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));
|
||||
|
||||
@@ -10,6 +10,7 @@ const dashboardWidgets: DashboardWidgetsUiCapability = {
|
||||
widgets: [
|
||||
{
|
||||
id: "dashboard.installed-modules",
|
||||
surfaceId: "dashboard.widget.installed-modules",
|
||||
title: "Installed modules",
|
||||
description: "Enabled WebUI modules in this browser session.",
|
||||
moduleId: "dashboard",
|
||||
@@ -33,6 +34,15 @@ export const dashboardModule: PlatformWebModule = {
|
||||
dependencies: ["access"],
|
||||
optionalDependencies: ["ops", "campaigns", "files", "mail", "tasks", "notifications", "reporting"],
|
||||
translations,
|
||||
viewSurfaces: [
|
||||
{
|
||||
id: "dashboard.widget.installed-modules",
|
||||
moduleId: "dashboard",
|
||||
kind: "section",
|
||||
label: "Installed modules widget",
|
||||
order: 10
|
||||
}
|
||||
],
|
||||
navItems: [{ to: "/dashboard", label: "i18n:govoplan-dashboard.dashboard.3f8b4df2", iconName: "dashboard", order: 10 }],
|
||||
routes: [
|
||||
{ path: "/dashboard", order: 10, render: ({ settings, auth }) => createElement(DashboardPage, { settings, auth }) }
|
||||
@@ -43,4 +53,3 @@ export const dashboardModule: PlatformWebModule = {
|
||||
};
|
||||
|
||||
export default dashboardModule;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user