[WEB-2682] fix: delete project mutation and workspace draft header validation (#5843)
* fix: workspace draft header action validation * fix: delete project mutation
This commit is contained in:
parent
9b85306359
commit
7d36d63eb1
2 changed files with 16 additions and 12 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { FC, useState } from "react";
|
import { useState } from "react";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { PenSquare } from "lucide-react";
|
import { PenSquare } from "lucide-react";
|
||||||
// ui
|
// ui
|
||||||
|
|
@ -11,16 +11,17 @@ import { CreateUpdateIssueModal } from "@/components/issues";
|
||||||
// constants
|
// constants
|
||||||
import { EIssuesStoreType } from "@/constants/issue";
|
import { EIssuesStoreType } from "@/constants/issue";
|
||||||
// hooks
|
// hooks
|
||||||
import { useUserPermissions, useWorkspaceDraftIssues } from "@/hooks/store";
|
import { useProject, useUserPermissions, useWorkspaceDraftIssues } from "@/hooks/store";
|
||||||
// plane-web
|
// plane-web
|
||||||
import { EUserPermissions, EUserPermissionsLevel } from "@/plane-web/constants/user-permissions";
|
import { EUserPermissions, EUserPermissionsLevel } from "@/plane-web/constants/user-permissions";
|
||||||
|
|
||||||
export const WorkspaceDraftHeader: FC = observer(() => {
|
export const WorkspaceDraftHeader = observer(() => {
|
||||||
// state
|
// state
|
||||||
const [isDraftIssueModalOpen, setIsDraftIssueModalOpen] = useState(false);
|
const [isDraftIssueModalOpen, setIsDraftIssueModalOpen] = useState(false);
|
||||||
// store hooks
|
// store hooks
|
||||||
const { allowPermissions } = useUserPermissions();
|
const { allowPermissions } = useUserPermissions();
|
||||||
const { paginationInfo } = useWorkspaceDraftIssues();
|
const { paginationInfo } = useWorkspaceDraftIssues();
|
||||||
|
const { joinedProjectIds } = useProject();
|
||||||
// check if user is authorized to create draft issue
|
// check if user is authorized to create draft issue
|
||||||
const isAuthorizedUser = allowPermissions(
|
const isAuthorizedUser = allowPermissions(
|
||||||
[EUserPermissions.ADMIN, EUserPermissions.MEMBER],
|
[EUserPermissions.ADMIN, EUserPermissions.MEMBER],
|
||||||
|
|
@ -53,15 +54,17 @@ export const WorkspaceDraftHeader: FC = observer(() => {
|
||||||
</Header.LeftItem>
|
</Header.LeftItem>
|
||||||
|
|
||||||
<Header.RightItem>
|
<Header.RightItem>
|
||||||
<Button
|
{joinedProjectIds && joinedProjectIds.length > 0 && (
|
||||||
variant="primary"
|
<Button
|
||||||
size="sm"
|
variant="primary"
|
||||||
className="items-center gap-1"
|
size="sm"
|
||||||
onClick={() => setIsDraftIssueModalOpen(true)}
|
className="items-center gap-1"
|
||||||
disabled={!isAuthorizedUser}
|
onClick={() => setIsDraftIssueModalOpen(true)}
|
||||||
>
|
disabled={!isAuthorizedUser}
|
||||||
Draft<span className="hidden sm:inline-block"> an issue</span>
|
>
|
||||||
</Button>
|
Draft<span className="hidden sm:inline-block"> an issue</span>
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</Header.RightItem>
|
</Header.RightItem>
|
||||||
</Header>
|
</Header>
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
|
|
@ -404,6 +404,7 @@ export class ProjectStore implements IProjectStore {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
delete this.projectMap[projectId];
|
delete this.projectMap[projectId];
|
||||||
if (this.rootStore.favorite.entityMap[projectId]) this.rootStore.favorite.removeFavoriteFromStore(projectId);
|
if (this.rootStore.favorite.entityMap[projectId]) this.rootStore.favorite.removeFavoriteFromStore(projectId);
|
||||||
|
delete this.rootStore.user.permission.workspaceProjectsPermissions[workspaceSlug][projectId];
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Failed to delete project from project store");
|
console.log("Failed to delete project from project store");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue