Skip to content

Commit 9851531

Browse files
committed
revert: add restriction callback to restrict visibility and modification of widget kinds (#2746)
This reverts commit 84f73d3.
1 parent d1b14ac commit 9851531

File tree

16 files changed

+252
-291
lines changed

16 files changed

+252
-291
lines changed

apps/nextjs/src/components/board/items/item-content.tsx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import combineClasses from "clsx";
55
import { NoIntegrationSelectedError } from "node_modules/@homarr/widgets/src/errors";
66
import { ErrorBoundary } from "react-error-boundary";
77

8-
import { useSession } from "@homarr/auth/client";
9-
import { isWidgetRestricted } from "@homarr/auth/shared";
108
import { useRequiredBoard } from "@homarr/boards/context";
119
import { useEditMode } from "@homarr/boards/edit-mode";
1210
import { useSettings } from "@homarr/settings";
@@ -17,7 +15,6 @@ import type { SectionItem } from "~/app/[locale]/boards/_types";
1715
import classes from "../sections/item.module.css";
1816
import { useItemActions } from "./item-actions";
1917
import { BoardItemMenu } from "./item-menu";
20-
import { RestrictedWidgetContent } from "./restricted";
2118

2219
interface BoardItemContentProps {
2320
item: SectionItem;
@@ -62,7 +59,6 @@ interface InnerContentProps {
6259
const InnerContent = ({ item, ...dimensions }: InnerContentProps) => {
6360
const settings = useSettings();
6461
const board = useRequiredBoard();
65-
const { data: session } = useSession();
6662
const [isEditMode] = useEditMode();
6763
const Comp = loadWidgetDynamic(item.kind);
6864
const { definition } = widgetImports[item.kind];
@@ -74,16 +70,6 @@ const InnerContent = ({ item, ...dimensions }: InnerContentProps) => {
7470
const widgetSupportsIntegrations =
7571
"supportedIntegrations" in definition && definition.supportedIntegrations.length >= 1;
7672

77-
if (
78-
isWidgetRestricted({
79-
definition,
80-
user: session?.user ?? null,
81-
check: (level) => level === "all",
82-
})
83-
) {
84-
return <RestrictedWidgetContent kind={item.kind} />;
85-
}
86-
8773
return (
8874
<QueryErrorResetBoundary>
8975
{({ reset }) => (

apps/nextjs/src/components/board/items/item-menu.tsx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { ActionIcon, Menu } from "@mantine/core";
33
import { IconCopy, IconDotsVertical, IconLayoutKanban, IconPencil, IconTrash } from "@tabler/icons-react";
44

55
import { clientApi } from "@homarr/api/client";
6-
import { useSession } from "@homarr/auth/client";
7-
import { isWidgetRestricted } from "@homarr/auth/shared";
86
import { useEditMode } from "@homarr/boards/edit-mode";
97
import { useConfirmModal, useModalAction } from "@homarr/modals";
108
import { useSettings } from "@homarr/settings";
@@ -39,7 +37,6 @@ export const BoardItemMenu = ({
3937
const currentDefinition = useMemo(() => widgetImports[item.kind].definition, [item.kind]);
4038
const { gridstack } = useSectionContext().refs;
4139
const settings = useSettings();
42-
const { data: session } = useSession();
4340

4441
// Reset error boundary on next render if item has been edited
4542
useEffect(() => {
@@ -94,16 +91,6 @@ export const BoardItemMenu = ({
9491
});
9592
};
9693

97-
if (
98-
isWidgetRestricted({
99-
definition: currentDefinition,
100-
user: session?.user ?? null,
101-
check: (level) => level !== "none",
102-
})
103-
) {
104-
return null;
105-
}
106-
10794
return (
10895
<Menu withinPortal withArrow position="right-start" arrowPosition="center">
10996
<Menu.Target>

apps/nextjs/src/components/board/items/item-select-modal.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { useMemo, useState } from "react";
22
import { Button, Card, Center, Grid, Input, Stack, Text } from "@mantine/core";
33
import { IconSearch } from "@tabler/icons-react";
44

5-
import { useSession } from "@homarr/auth/client";
6-
import { isWidgetRestricted } from "@homarr/auth/shared";
75
import { objectEntries } from "@homarr/common";
86
import type { WidgetKind } from "@homarr/definitions";
97
import { createModal } from "@homarr/modals";
@@ -17,26 +15,18 @@ export const ItemSelectModal = createModal<void>(({ actions }) => {
1715
const [search, setSearch] = useState("");
1816
const t = useI18n();
1917
const { createItem } = useItemActions();
20-
const { data: session } = useSession();
2118

2219
const items = useMemo(
2320
() =>
2421
objectEntries(widgetImports)
25-
.filter(([, value]) => {
26-
return !isWidgetRestricted({
27-
definition: value.definition,
28-
user: session?.user ?? null,
29-
check: (level) => level !== "none",
30-
});
31-
})
3222
.map(([kind, value]) => ({
3323
kind,
3424
icon: value.definition.icon,
3525
name: t(`widget.${kind}.name`),
3626
description: t(`widget.${kind}.description`),
3727
}))
3828
.sort((itemA, itemB) => itemA.name.localeCompare(itemB.name)),
39-
[t, session?.user],
29+
[t],
4030
);
4131

4232
const filteredItems = useMemo(

apps/nextjs/src/components/board/items/restricted.tsx

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)