revert: add restriction callback to restrict visibility and modification of widget kinds (#2746)

This reverts commit 84f73d33a0.
This commit is contained in:
Meier Lukas
2025-03-29 12:43:10 +01:00
parent d1b14aca8b
commit 98515312a2
16 changed files with 253 additions and 292 deletions

View File

@@ -1,3 +1,2 @@
export * from "./board-permissions";
export * from "./integration-permissions";
export * from "./widget-restriction";

View File

@@ -1,14 +0,0 @@
import type { Session } from "next-auth";
import type { WidgetDefinition } from "../../widgets/src";
import type { RestrictionLevel } from "../../widgets/src/definition";
export const isWidgetRestricted = <TDefinition extends WidgetDefinition>(props: {
definition: TDefinition;
user: Session["user"] | null;
check: (level: RestrictionLevel) => boolean;
}) => {
if (!("restrict" in props.definition)) return false;
if (props.definition.restrict === undefined) return false;
return props.check(props.definition.restrict({ user: props.user ?? null }));
};