Skip to content

Commit

Permalink
fix: actions user has no permission to are shown in spotlight (#1452)
Browse files Browse the repository at this point in the history
  • Loading branch information
Meierschlumpf authored Nov 9, 2024
1 parent 747922f commit 04895da
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/spotlight/src/modes/command/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
IconUsersGroup,
} from "@tabler/icons-react";

import { useSession } from "@homarr/auth/client";
import { useModalAction } from "@homarr/modals";
import { AddBoardModal, AddGroupModal, ImportBoardModal, InviteCreateModal } from "@homarr/modals-collection";
import { useScopedI18n } from "@homarr/translation/client";
Expand Down Expand Up @@ -56,6 +57,7 @@ export const commandMode = {
useOptions() {
const tOption = useScopedI18n("search.mode.command.group.globalCommand.option");
const { colorScheme } = useMantineColorScheme();
const { data: session } = useSession();

const commands: (Command & { hidden?: boolean })[] = [
{
Expand Down Expand Up @@ -91,6 +93,7 @@ export const commandMode = {
},
};
},
hidden: !session?.user.permissions.includes("board-create"),
},
{
commandKey: "importBoard",
Expand All @@ -106,6 +109,7 @@ export const commandMode = {
},
};
},
hidden: !session?.user.permissions.includes("board-create"),
},
{
commandKey: "newApp",
Expand All @@ -118,12 +122,14 @@ export const commandMode = {
icon: IconPlug,
name: tOption("newIntegration.label"),
useInteraction: interaction.children(newIntegrationChildrenOptions),
hidden: !session?.user.permissions.includes("integration-create"),
},
{
commandKey: "newUser",
icon: IconUserPlus,
name: tOption("newUser.label"),
useInteraction: interaction.link(() => ({ href: "/manage/users/new" })),
hidden: !session?.user.permissions.includes("admin"),
},
{
commandKey: "newInvite",
Expand All @@ -139,6 +145,7 @@ export const commandMode = {
},
};
},
hidden: !session?.user.permissions.includes("admin"),
},
{
commandKey: "newGroup",
Expand All @@ -154,6 +161,7 @@ export const commandMode = {
},
};
},
hidden: !session?.user.permissions.includes("admin"),
},
];

Expand Down

0 comments on commit 04895da

Please sign in to comment.