2024-08-20 17:55:43 +05:30
|
|
|
import { useParams } from "next/navigation";
|
2024-06-28 18:37:38 +05:30
|
|
|
import { Control, Controller } from "react-hook-form";
|
2024-08-20 17:55:43 +05:30
|
|
|
// types
|
2024-06-28 18:37:38 +05:30
|
|
|
import { IProjectView, IWorkspaceView } from "@plane/types";
|
2024-08-20 17:55:43 +05:30
|
|
|
// components
|
2024-06-28 18:37:38 +05:30
|
|
|
import { AccessField } from "@/components/common/access-field";
|
2024-08-20 17:55:43 +05:30
|
|
|
// constants
|
2024-06-28 18:37:38 +05:30
|
|
|
import { VIEW_ACCESS_SPECIFIERS } from "@/constants/views";
|
2024-08-20 17:55:43 +05:30
|
|
|
import { useFlag } from "@/plane-web/hooks/store";
|
2024-06-28 18:37:38 +05:30
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
control: Control<IProjectView, any> | Control<IWorkspaceView, any>;
|
|
|
|
|
};
|
|
|
|
|
export const AccessController = (props: Props) => {
|
|
|
|
|
const { control } = props;
|
2024-08-20 17:55:43 +05:30
|
|
|
// router
|
|
|
|
|
const { workspaceSlug } = useParams();
|
|
|
|
|
// plane web hooks
|
|
|
|
|
const isPrivateViewsEnabled = useFlag(workspaceSlug?.toString(), "VIEW_ACCESS_PRIVATE");
|
|
|
|
|
|
|
|
|
|
if (!isPrivateViewsEnabled) return null;
|
|
|
|
|
|
2024-06-28 18:37:38 +05:30
|
|
|
return (
|
|
|
|
|
<Controller
|
|
|
|
|
control={control as Control<IProjectView, any>}
|
|
|
|
|
name="access"
|
|
|
|
|
render={({ field: { onChange, value } }) => (
|
|
|
|
|
<AccessField onChange={onChange} value={value} accessSpecifiers={VIEW_ACCESS_SPECIFIERS} />
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
};
|