diff --git a/web/components/automation/auto-archive-automation.tsx b/web/components/automation/auto-archive-automation.tsx index bb4e72e0cce..d0c9a1be6bf 100644 --- a/web/components/automation/auto-archive-automation.tsx +++ b/web/components/automation/auto-archive-automation.tsx @@ -13,9 +13,14 @@ import { IProject } from "types"; type Props = { projectDetails: IProject | undefined; handleChange: (formData: Partial) => Promise; + disabled?: boolean; }; -export const AutoArchiveAutomation: React.FC = ({ projectDetails, handleChange }) => { +export const AutoArchiveAutomation: React.FC = ({ + projectDetails, + handleChange, + disabled = false, +}) => { const [monthModal, setmonthModal] = useState(false); const initialValues: Partial = { archive_in: 1 }; @@ -49,6 +54,7 @@ export const AutoArchiveAutomation: React.FC = ({ projectDetails, handleC : handleChange({ archive_in: 0 }) } size="sm" + disabled={disabled} /> @@ -70,6 +76,7 @@ export const AutoArchiveAutomation: React.FC = ({ projectDetails, handleC input verticalPosition="bottom" width="w-full" + disabled={disabled} > <> {PROJECT_AUTOMATION_MONTHS.map((month) => ( diff --git a/web/components/automation/auto-close-automation.tsx b/web/components/automation/auto-close-automation.tsx index 868d6455737..063501036cc 100644 --- a/web/components/automation/auto-close-automation.tsx +++ b/web/components/automation/auto-close-automation.tsx @@ -24,9 +24,14 @@ import { getStatesList } from "helpers/state.helper"; type Props = { projectDetails: IProject | undefined; handleChange: (formData: Partial) => Promise; + disabled?: boolean; }; -export const AutoCloseAutomation: React.FC = ({ projectDetails, handleChange }) => { +export const AutoCloseAutomation: React.FC = ({ + projectDetails, + handleChange, + disabled = false, +}) => { const [monthModal, setmonthModal] = useState(false); const router = useRouter(); @@ -98,6 +103,7 @@ export const AutoCloseAutomation: React.FC = ({ projectDetails, handleCha : handleChange({ close_in: 0, default_state: null }) } size="sm" + disabled={disabled} /> @@ -119,6 +125,7 @@ export const AutoCloseAutomation: React.FC = ({ projectDetails, handleCha }} input width="w-full" + disabled={disabled} > <> {PROJECT_AUTOMATION_MONTHS.map((month) => ( diff --git a/web/components/project/member-select.tsx b/web/components/project/member-select.tsx index 64baa945d52..4fcb0426890 100644 --- a/web/components/project/member-select.tsx +++ b/web/components/project/member-select.tsx @@ -16,9 +16,10 @@ import { PROJECT_MEMBERS } from "constants/fetch-keys"; type Props = { value: any; onChange: (val: string) => void; + isDisabled?: boolean; }; -export const MemberSelect: React.FC = ({ value, onChange }) => { +export const MemberSelect: React.FC = ({ value, onChange, isDisabled = false }) => { const router = useRouter(); const { workspaceSlug, projectId } = router.query; @@ -79,6 +80,7 @@ export const MemberSelect: React.FC = ({ value, onChange }) => { position="right" width="w-full" onChange={onChange} + disabled={isDisabled} /> ); }; diff --git a/web/components/ui/dropdowns/custom-menu.tsx b/web/components/ui/dropdowns/custom-menu.tsx index 41450b2b35b..f456804f046 100644 --- a/web/components/ui/dropdowns/custom-menu.tsx +++ b/web/components/ui/dropdowns/custom-menu.tsx @@ -46,6 +46,7 @@ const CustomMenu = ({ type="button" onClick={menuButtonOnClick} className={customButtonClassName} + disabled={disabled} > {customButton} diff --git a/web/components/ui/empty-state.tsx b/web/components/ui/empty-state.tsx index 098c3f15293..e39b10801f2 100644 --- a/web/components/ui/empty-state.tsx +++ b/web/components/ui/empty-state.tsx @@ -16,6 +16,7 @@ type Props = { }; secondaryButton?: React.ReactNode; isFullScreen?: boolean; + disabled?: boolean; }; export const EmptyState: React.FC = ({ @@ -25,6 +26,7 @@ export const EmptyState: React.FC = ({ primaryButton, secondaryButton, isFullScreen = true, + disabled = false, }) => (
= ({ {description &&

{description}

}
{primaryButton && ( - + {primaryButton.icon} {primaryButton.text} diff --git a/web/components/ui/toggle-switch.tsx b/web/components/ui/toggle-switch.tsx index d6c512ad7fd..5ad9377de11 100644 --- a/web/components/ui/toggle-switch.tsx +++ b/web/components/ui/toggle-switch.tsx @@ -21,7 +21,7 @@ export const ToggleSwitch: React.FC = (props) => { size === "sm" ? "h-4 w-6" : size === "md" ? "h-5 w-8" : "h-6 w-10" } flex-shrink-0 cursor-pointer rounded-full border border-custom-border-200 transition-colors duration-200 ease-in-out focus:outline-none ${ value ? "bg-custom-primary-100" : "bg-gray-700" - } ${className || ""}`} + } ${className || ""} ${disabled ? "cursor-not-allowed" : ""}`} > {label} = (props) => { ? "translate-x-4" : "translate-x-5") + " bg-white" : "translate-x-0.5 bg-custom-background-90" - }`} + } ${disabled ? "cursor-not-allowed" : ""}`} /> ); diff --git a/web/pages/[workspaceSlug]/projects/[projectId]/settings/automations.tsx b/web/pages/[workspaceSlug]/projects/[projectId]/settings/automations.tsx index 5dcea083889..1f74a74c32a 100644 --- a/web/pages/[workspaceSlug]/projects/[projectId]/settings/automations.tsx +++ b/web/pages/[workspaceSlug]/projects/[projectId]/settings/automations.tsx @@ -2,7 +2,7 @@ import React from "react"; import { useRouter } from "next/router"; -import { mutate } from "swr"; +import useSWR, { mutate } from "swr"; // services import projectService from "services/project.service"; @@ -21,7 +21,7 @@ import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs"; import type { NextPage } from "next"; import { IProject } from "types"; // constant -import { PROJECTS_LIST, PROJECT_DETAILS } from "constants/fetch-keys"; +import { PROJECTS_LIST, PROJECT_DETAILS, USER_PROJECT_VIEW } from "constants/fetch-keys"; // helper import { truncateText } from "helpers/string.helper"; @@ -34,6 +34,13 @@ const AutomationsSettings: NextPage = () => { const { projectDetails } = useProjectDetails(); + const { data: memberDetails } = useSWR( + workspaceSlug && projectId ? USER_PROJECT_VIEW(projectId.toString()) : null, + workspaceSlug && projectId + ? () => projectService.projectMemberMe(workspaceSlug.toString(), projectId.toString()) + : null + ); + const handleChange = async (formData: Partial) => { if (!workspaceSlug || !projectId || !projectDetails) return; @@ -62,6 +69,8 @@ const AutomationsSettings: NextPage = () => { }); }; + const isAdmin = memberDetails?.role === 20; + return ( {
-
+

Automations

- - + +
diff --git a/web/pages/[workspaceSlug]/projects/[projectId]/settings/features.tsx b/web/pages/[workspaceSlug]/projects/[projectId]/settings/features.tsx index 499aaea866c..ba74cf2a503 100644 --- a/web/pages/[workspaceSlug]/projects/[projectId]/settings/features.tsx +++ b/web/pages/[workspaceSlug]/projects/[projectId]/settings/features.tsx @@ -25,7 +25,7 @@ import { ContrastOutlined } from "@mui/icons-material"; import { IProject } from "types"; import type { NextPage } from "next"; // fetch-keys -import { PROJECTS_LIST, PROJECT_DETAILS } from "constants/fetch-keys"; +import { PROJECTS_LIST, PROJECT_DETAILS, USER_PROJECT_VIEW } from "constants/fetch-keys"; // helper import { truncateText } from "helpers/string.helper"; @@ -102,6 +102,13 @@ const FeaturesSettings: NextPage = () => { : null ); + const { data: memberDetails } = useSWR( + workspaceSlug && projectId ? USER_PROJECT_VIEW(projectId.toString()) : null, + workspaceSlug && projectId + ? () => projectService.projectMemberMe(workspaceSlug.toString(), projectId.toString()) + : null + ); + const handleSubmit = async (formData: Partial) => { if (!workspaceSlug || !projectId || !projectDetails) return; @@ -140,6 +147,8 @@ const FeaturesSettings: NextPage = () => { ); }; + const isAdmin = memberDetails?.role === 20; + return ( {
-
+

Features

@@ -199,6 +208,7 @@ const FeaturesSettings: NextPage = () => { [feature.property]: !projectDetails?.[feature.property as keyof IProject], }); }} + disabled={!isAdmin} size="sm" />
diff --git a/web/pages/[workspaceSlug]/projects/[projectId]/settings/integrations.tsx b/web/pages/[workspaceSlug]/projects/[projectId]/settings/integrations.tsx index ca64b8e220e..181c9f8ec50 100644 --- a/web/pages/[workspaceSlug]/projects/[projectId]/settings/integrations.tsx +++ b/web/pages/[workspaceSlug]/projects/[projectId]/settings/integrations.tsx @@ -22,7 +22,7 @@ import emptyIntegration from "public/empty-state/integration.svg"; import { IProject } from "types"; import type { NextPage } from "next"; // fetch-keys -import { PROJECT_DETAILS, WORKSPACE_INTEGRATIONS } from "constants/fetch-keys"; +import { PROJECT_DETAILS, USER_PROJECT_VIEW, WORKSPACE_INTEGRATIONS } from "constants/fetch-keys"; // helper import { truncateText } from "helpers/string.helper"; @@ -45,6 +45,15 @@ const ProjectIntegrations: NextPage = () => { : null ); + const { data: memberDetails } = useSWR( + workspaceSlug && projectId ? USER_PROJECT_VIEW(projectId.toString()) : null, + workspaceSlug && projectId + ? () => projectService.projectMemberMe(workspaceSlug.toString(), projectId.toString()) + : null + ); + + const isAdmin = memberDetails?.role === 20; + return ( {
-
+

Integrations

@@ -85,6 +94,7 @@ const ProjectIntegrations: NextPage = () => { text: "Configure now", onClick: () => router.push(`/${workspaceSlug}/settings/integrations`), }} + disabled={!isAdmin} /> ) ) : ( diff --git a/web/pages/[workspaceSlug]/projects/[projectId]/settings/members.tsx b/web/pages/[workspaceSlug]/projects/[projectId]/settings/members.tsx index 59e218ee498..51143d86811 100644 --- a/web/pages/[workspaceSlug]/projects/[projectId]/settings/members.tsx +++ b/web/pages/[workspaceSlug]/projects/[projectId]/settings/members.tsx @@ -43,6 +43,7 @@ import { PROJECT_INVITATIONS_WITH_EMAIL, PROJECT_MEMBERS, PROJECT_MEMBERS_WITH_EMAIL, + USER_PROJECT_VIEW, WORKSPACE_DETAILS, } from "constants/fetch-keys"; // constants @@ -111,6 +112,13 @@ const MembersSettings: NextPage = () => { : null ); + const { data: memberDetails } = useSWR( + workspaceSlug && projectId ? USER_PROJECT_VIEW(projectId.toString()) : null, + workspaceSlug && projectId + ? () => projectService.projectMemberMe(workspaceSlug.toString(), projectId.toString()) + : null + ); + const members = [ ...(projectMembers?.map((item) => ({ id: item.id, @@ -212,6 +220,8 @@ const MembersSettings: NextPage = () => { }); }; + const isAdmin = memberDetails?.role === 20; + return ( {
-
+

Defaults

@@ -296,6 +306,7 @@ const MembersSettings: NextPage = () => { onChange={(val: string) => { submitChanges({ project_lead: val }); }} + isDisabled={!isAdmin} /> )} /> @@ -320,6 +331,7 @@ const MembersSettings: NextPage = () => { onChange={(val: string) => { submitChanges({ default_assignee: val }); }} + isDisabled={!isAdmin} /> )} /> @@ -467,7 +479,7 @@ const MembersSettings: NextPage = () => { ); })} - + { if (member.member) setSelectedRemoveMember(member.id);