Skip to content

Commit

Permalink
fix: enabling guest user to edit his own views
Browse files Browse the repository at this point in the history
  • Loading branch information
mathalav55 committed Dec 23, 2024
1 parent ba1a314 commit 24bb34f
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
useProject,
useProjectState,
useProjectView,
useUser,
useUserPermissions,
} from "@/hooks/store";
import { EUserPermissions, EUserPermissionsLevel } from "@/plane-web/constants/user-permissions";
Expand All @@ -45,6 +46,7 @@ export const ProjectViewIssuesHeader: React.FC = observer(() => {
const { setTrackElement } = useEventTracker();
const { toggleCreateIssueModal } = useCommandPalette();
const { allowPermissions } = useUserPermissions();
const { data } = useUser();

const { currentProjectDetails, loader } = useProject();
const { projectViewIds, getViewById } = useProjectView();
Expand Down Expand Up @@ -127,6 +129,10 @@ export const ProjectViewIssuesHeader: React.FC = observer(() => {

const viewDetails = viewId ? getViewById(viewId.toString()) : null;

// auth
const isOwner = viewDetails?.owned_by === data?.id;
const isAdmin = allowPermissions([EUserPermissions.ADMIN], EUserPermissionsLevel.PROJECT);

const canUserCreateIssue = allowPermissions(
[EUserPermissions.ADMIN, EUserPermissions.MEMBER],
EUserPermissionsLevel.PROJECT
Expand Down Expand Up @@ -247,7 +253,7 @@ export const ProjectViewIssuesHeader: React.FC = observer(() => {
<FiltersDropdown
title="Filters"
placement="bottom-end"
disabled={!canUserCreateIssue}
disabled={!isOwner && !isAdmin}
isFiltersApplied={isIssueFilterActive(issueFilters)}
>
<FilterSelection
Expand Down

0 comments on commit 24bb34f

Please sign in to comment.