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,32 +373,34 @@ const GeneralSettings: NextPage = () => {
|
|||||||
</Loader>
|
</Loader>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-12 gap-4 sm:gap-16">
|
{memberDetails?.role === 20 && (
|
||||||
<div className="col-span-12 sm:col-span-6">
|
<div className="grid grid-cols-12 gap-4 sm:gap-16">
|
||||||
<h4 className="text-lg font-semibold">Danger Zone</h4>
|
<div className="col-span-12 sm:col-span-6">
|
||||||
<p className="text-sm text-custom-text-200">
|
<h4 className="text-lg font-semibold">Danger Zone</h4>
|
||||||
The danger zone of the project delete page is a critical area that requires careful
|
<p className="text-sm text-custom-text-200">
|
||||||
consideration and attention. When deleting a project, all of the data and resources
|
The danger zone of the project delete page is a critical area that requires
|
||||||
within that project will be permanently removed and cannot be recovered.
|
careful consideration and attention. When deleting a project, all of the data and
|
||||||
</p>
|
resources within that project will be permanently removed and cannot be recovered.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className="col-span-12 sm:col-span-6">
|
||||||
|
{projectDetails ? (
|
||||||
|
<div>
|
||||||
|
<DangerButton
|
||||||
|
onClick={() => setSelectedProject(projectDetails.id ?? null)}
|
||||||
|
outline
|
||||||
|
>
|
||||||
|
Delete Project
|
||||||
|
</DangerButton>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<Loader className="mt-2 w-full">
|
||||||
|
<Loader.Item height="46px" width="100px" />
|
||||||
|
</Loader>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-span-12 sm:col-span-6">
|
)}
|
||||||
{projectDetails ? (
|
|
||||||
<div>
|
|
||||||
<DangerButton
|
|
||||||
onClick={() => setSelectedProject(projectDetails.id ?? null)}
|
|
||||||
outline
|
|
||||||
>
|
|
||||||
Delete Project
|
|
||||||
</DangerButton>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<Loader className="mt-2 w-full">
|
|
||||||
<Loader.Item height="46px" width="100px" />
|
|
||||||
</Loader>
|
|
||||||
)}
|
|
||||||
</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,26 +321,32 @@ 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>
|
||||||
<div className="grid grid-cols-12 gap-4 sm:gap-16">
|
{memberDetails?.role === 20 && (
|
||||||
<div className="col-span-12 sm:col-span-6">
|
<div className="grid grid-cols-12 gap-4 sm:gap-16">
|
||||||
<h4 className="text-lg font-semibold">Danger Zone</h4>
|
<div className="col-span-12 sm:col-span-6">
|
||||||
<p className="text-sm text-custom-text-200">
|
<h4 className="text-lg font-semibold">Danger Zone</h4>
|
||||||
The danger zone of the workspace delete page is a critical area that requires
|
<p className="text-sm text-custom-text-200">
|
||||||
careful consideration and attention. When deleting a workspace, all of the data
|
The danger zone of the workspace delete page is a critical area that requires
|
||||||
and resources within that workspace will be permanently removed and cannot be
|
careful consideration and attention. When deleting a workspace, all of the data
|
||||||
recovered.
|
and resources within that workspace will be permanently removed and cannot be
|
||||||
</p>
|
recovered.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className="col-span-12 sm:col-span-6">
|
||||||
|
<DangerButton onClick={() => setIsOpen(true)} outline>
|
||||||
|
Delete the workspace
|
||||||
|
</DangerButton>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-span-12 sm:col-span-6">
|
)}
|
||||||
<DangerButton onClick={() => setIsOpen(true)} outline>
|
|
||||||
Delete the workspace
|
|
||||||
</DangerButton>
|
|
||||||
</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