diff --git a/packages/ui/src/form-fields/input.tsx b/packages/ui/src/form-fields/input.tsx index 648b78aa7..501af5c7d 100644 --- a/packages/ui/src/form-fields/input.tsx +++ b/packages/ui/src/form-fields/input.tsx @@ -28,7 +28,7 @@ const Input = React.forwardRef((props, ref) => { name={name} className={`block rounded-md bg-transparent text-sm focus:outline-none placeholder-custom-text-400 ${ mode === "primary" - ? "rounded-md border border-custom-border-200" + ? "rounded-md border-[0.5px] border-custom-border-200" : mode === "transparent" ? "rounded border-none bg-transparent ring-0 transition-all focus:ring-1 focus:ring-custom-primary" : mode === "true-transparent" diff --git a/packages/ui/src/form-fields/textarea.tsx b/packages/ui/src/form-fields/textarea.tsx index 93a850059..e53979edc 100644 --- a/packages/ui/src/form-fields/textarea.tsx +++ b/packages/ui/src/form-fields/textarea.tsx @@ -53,7 +53,7 @@ const TextArea = React.forwardRef( cols={cols} className={`no-scrollbar w-full bg-transparent placeholder-custom-text-400 px-3 py-2 outline-none ${ mode === "primary" - ? "rounded-md border border-custom-border-200" + ? "rounded-md border-[0.5px] border-custom-border-200" : mode === "transparent" ? "rounded border-none bg-transparent ring-0 transition-all focus:ring-1 focus:ring-theme" : "" diff --git a/web/components/cycles/cycle-create-edit-modal.tsx b/web/components/cycles/cycle-create-edit-modal.tsx index 804b6e927..f44b745ce 100644 --- a/web/components/cycles/cycle-create-edit-modal.tsx +++ b/web/components/cycles/cycle-create-edit-modal.tsx @@ -1,4 +1,4 @@ -import { Fragment } from "react"; +import { Fragment, useEffect, useState } from "react"; import { Dialog, Transition } from "@headlessui/react"; import { observer } from "mobx-react-lite"; // components @@ -20,8 +20,10 @@ interface ICycleCreateEdit { export const CycleCreateEditModal: React.FC = observer((props) => { const { modal, modalClose, cycle = null, onSubmit, workspaceSlug, projectId } = props; + const [activeProject, setActiveProject] = useState(null); - const { cycle: cycleStore } = useMobxStore(); + const { project: projectStore, cycle: cycleStore } = useMobxStore(); + const projects = workspaceSlug ? projectStore.projects[workspaceSlug.toString()] : undefined; const { setToastAlert } = useToast(); @@ -96,6 +98,27 @@ export const CycleCreateEditModal: React.FC = observer((props) }); }; + useEffect(() => { + // if modal is closed, reset active project to null + // and return to avoid activeProject being set to some other project + if (!modal) { + setActiveProject(null); + return; + } + + // if data is present, set active project to the project of the + // issue. This has more priority than the project in the url. + if (cycle && cycle.project) { + setActiveProject(cycle.project); + return; + } + + // if data is not present, set active project to the project + // in the url. This has the least priority. + if (projects && projects.length > 0 && !activeProject) + setActiveProject(projects?.find((p) => p.id === projectId)?.id ?? projects?.[0].id ?? null); + }, [activeProject, cycle, projectId, projects, modal]); + return ( @@ -123,7 +146,13 @@ export const CycleCreateEditModal: React.FC = observer((props) leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95" > - + diff --git a/web/components/cycles/form.tsx b/web/components/cycles/form.tsx index c4188ea00..adcee376b 100644 --- a/web/components/cycles/form.tsx +++ b/web/components/cycles/form.tsx @@ -2,17 +2,20 @@ import { Controller, useForm } from "react-hook-form"; // ui import { Button, Input, TextArea } from "@plane/ui"; import { DateSelect } from "components/ui"; +import { IssueProjectSelect } from "components/issues/select"; // types import { ICycle } from "types"; type Props = { handleFormSubmit: (values: Partial) => Promise; handleClose: () => void; + projectId: string; + setActiveProject: React.Dispatch>; data?: ICycle | null; }; export const CycleForm: React.FC = (props) => { - const { handleFormSubmit, handleClose, data } = props; + const { handleFormSubmit, handleClose, projectId, setActiveProject, data } = props; // form data const { formState: { errors, isSubmitting }, @@ -21,6 +24,7 @@ export const CycleForm: React.FC = (props) => { watch, } = useForm({ defaultValues: { + project: projectId, name: data?.name || "", description: data?.description || "", start_date: data?.start_date || null, @@ -40,80 +44,98 @@ export const CycleForm: React.FC = (props) => { return (
-

{status ? "Update" : "Create"} Cycle

+
+ ( + { + onChange(val); + setActiveProject(val); + }} + /> + )} + /> +

{status ? "Update" : "New"} Cycle

+
-
- ( - - )} - /> -
-
- ( -