mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: updated user permission for project and workspace settings (#1807)
* fix: updated user permission for project and workspace settings * chore: workspace delete modal fix
This commit is contained in:
parent
7becec4ee9
commit
ac6d2b0139
@ -50,8 +50,10 @@ export const DeleteWorkspaceModal: React.FC<Props> = ({ isOpen, data, onClose, u
|
|||||||
const canDelete = confirmWorkspaceName === data?.name && confirmDeleteMyWorkspace;
|
const canDelete = confirmWorkspaceName === data?.name && confirmDeleteMyWorkspace;
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
onClose();
|
|
||||||
setIsDeleteLoading(false);
|
setIsDeleteLoading(false);
|
||||||
|
setConfirmWorkspaceName("");
|
||||||
|
setConfirmDeleteMyWorkspace(false);
|
||||||
|
onClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeletion = async () => {
|
const handleDeletion = async () => {
|
||||||
|
@ -34,7 +34,7 @@ import { truncateText } from "helpers/string.helper";
|
|||||||
import { IProject, IWorkspace } from "types";
|
import { IProject, IWorkspace } from "types";
|
||||||
import type { NextPage } from "next";
|
import type { NextPage } from "next";
|
||||||
// fetch-keys
|
// fetch-keys
|
||||||
import { PROJECTS_LIST, PROJECT_DETAILS } from "constants/fetch-keys";
|
import { PROJECTS_LIST, PROJECT_DETAILS, USER_PROJECT_VIEW } from "constants/fetch-keys";
|
||||||
// constants
|
// constants
|
||||||
import { NETWORK_CHOICES } from "constants/project";
|
import { NETWORK_CHOICES } from "constants/project";
|
||||||
|
|
||||||
@ -62,6 +62,13 @@ const GeneralSettings: NextPage = () => {
|
|||||||
: null
|
: null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const { data: memberDetails, error } = useSWR(
|
||||||
|
workspaceSlug && projectId ? USER_PROJECT_VIEW(projectId.toString()) : null,
|
||||||
|
workspaceSlug && projectId
|
||||||
|
? () => projectService.projectMemberMe(workspaceSlug.toString(), projectId.toString())
|
||||||
|
: null
|
||||||
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
@ -157,6 +164,8 @@ const GeneralSettings: NextPage = () => {
|
|||||||
|
|
||||||
const currentNetwork = NETWORK_CHOICES.find((n) => n.key === projectDetails?.network);
|
const currentNetwork = NETWORK_CHOICES.find((n) => n.key === projectDetails?.network);
|
||||||
|
|
||||||
|
const isAdmin = memberDetails?.role === 20;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ProjectAuthorizationWrapper
|
<ProjectAuthorizationWrapper
|
||||||
breadcrumbs={
|
breadcrumbs={
|
||||||
@ -355,7 +364,7 @@ const GeneralSettings: NextPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="sm:text-right">
|
<div className="sm:text-right">
|
||||||
{projectDetails ? (
|
{projectDetails ? (
|
||||||
<SecondaryButton type="submit" loading={isSubmitting}>
|
<SecondaryButton type="submit" loading={isSubmitting} disabled={!isAdmin}>
|
||||||
{isSubmitting ? "Updating Project..." : "Update Project"}
|
{isSubmitting ? "Updating Project..." : "Update Project"}
|
||||||
</SecondaryButton>
|
</SecondaryButton>
|
||||||
) : (
|
) : (
|
||||||
@ -364,13 +373,14 @@ const GeneralSettings: NextPage = () => {
|
|||||||
</Loader>
|
</Loader>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
{memberDetails?.role === 20 && (
|
||||||
<div className="grid grid-cols-12 gap-4 sm:gap-16">
|
<div className="grid grid-cols-12 gap-4 sm:gap-16">
|
||||||
<div className="col-span-12 sm:col-span-6">
|
<div className="col-span-12 sm:col-span-6">
|
||||||
<h4 className="text-lg font-semibold">Danger Zone</h4>
|
<h4 className="text-lg font-semibold">Danger Zone</h4>
|
||||||
<p className="text-sm text-custom-text-200">
|
<p className="text-sm text-custom-text-200">
|
||||||
The danger zone of the project delete page is a critical area that requires careful
|
The danger zone of the project delete page is a critical area that requires
|
||||||
consideration and attention. When deleting a project, all of the data and resources
|
careful consideration and attention. When deleting a project, all of the data and
|
||||||
within that project will be permanently removed and cannot be recovered.
|
resources within that project will be permanently removed and cannot be recovered.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-span-12 sm:col-span-6">
|
<div className="col-span-12 sm:col-span-6">
|
||||||
@ -390,6 +400,7 @@ const GeneralSettings: NextPage = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</ProjectAuthorizationWrapper>
|
</ProjectAuthorizationWrapper>
|
||||||
|
@ -28,7 +28,7 @@ import { copyTextToClipboard, truncateText } from "helpers/string.helper";
|
|||||||
import type { IWorkspace } from "types";
|
import type { IWorkspace } from "types";
|
||||||
import type { NextPage } from "next";
|
import type { NextPage } from "next";
|
||||||
// fetch-keys
|
// fetch-keys
|
||||||
import { WORKSPACE_DETAILS, USER_WORKSPACES } from "constants/fetch-keys";
|
import { WORKSPACE_DETAILS, USER_WORKSPACES, WORKSPACE_MEMBERS_ME } from "constants/fetch-keys";
|
||||||
// constants
|
// constants
|
||||||
import { ORGANIZATION_SIZE } from "constants/workspace";
|
import { ORGANIZATION_SIZE } from "constants/workspace";
|
||||||
|
|
||||||
@ -50,6 +50,11 @@ const WorkspaceSettings: NextPage = () => {
|
|||||||
|
|
||||||
const { user } = useUserAuth();
|
const { user } = useUserAuth();
|
||||||
|
|
||||||
|
const { data: memberDetails } = useSWR(
|
||||||
|
workspaceSlug ? WORKSPACE_MEMBERS_ME(workspaceSlug.toString()) : null,
|
||||||
|
workspaceSlug ? () => workspaceService.workspaceMemberMe(workspaceSlug.toString()) : null
|
||||||
|
);
|
||||||
|
|
||||||
const { setToastAlert } = useToast();
|
const { setToastAlert } = useToast();
|
||||||
|
|
||||||
const { data: activeWorkspace } = useSWR(
|
const { data: activeWorkspace } = useSWR(
|
||||||
@ -142,6 +147,8 @@ const WorkspaceSettings: NextPage = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isAdmin = memberDetails?.role === 20;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WorkspaceAuthorizationLayout
|
<WorkspaceAuthorizationLayout
|
||||||
breadcrumbs={
|
breadcrumbs={
|
||||||
@ -314,10 +321,15 @@ const WorkspaceSettings: NextPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="sm:text-right">
|
<div className="sm:text-right">
|
||||||
<SecondaryButton onClick={handleSubmit(onSubmit)} loading={isSubmitting}>
|
<SecondaryButton
|
||||||
|
onClick={handleSubmit(onSubmit)}
|
||||||
|
loading={isSubmitting}
|
||||||
|
disabled={!isAdmin}
|
||||||
|
>
|
||||||
{isSubmitting ? "Updating..." : "Update Workspace"}
|
{isSubmitting ? "Updating..." : "Update Workspace"}
|
||||||
</SecondaryButton>
|
</SecondaryButton>
|
||||||
</div>
|
</div>
|
||||||
|
{memberDetails?.role === 20 && (
|
||||||
<div className="grid grid-cols-12 gap-4 sm:gap-16">
|
<div className="grid grid-cols-12 gap-4 sm:gap-16">
|
||||||
<div className="col-span-12 sm:col-span-6">
|
<div className="col-span-12 sm:col-span-6">
|
||||||
<h4 className="text-lg font-semibold">Danger Zone</h4>
|
<h4 className="text-lg font-semibold">Danger Zone</h4>
|
||||||
@ -334,6 +346,7 @@ const WorkspaceSettings: NextPage = () => {
|
|||||||
</DangerButton>
|
</DangerButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="grid h-full w-full place-items-center px-4 sm:px-0">
|
<div className="grid h-full w-full place-items-center px-4 sm:px-0">
|
||||||
|
Loading…
Reference in New Issue
Block a user