mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
220389e74e
* chore: autorun for the issue detail store * fix: labels mutation * chore: remove old peek overview code * chore: move add to cycle and module logic to store * fix: build errors * chore: add peekProjectId query param for the peek overview * chore: update profile layout * fix: multiple workspaces * style: Issue activity and link design improvements in Peek overview. * fix issue with labels not occupying full widht. * fix links overflow issue. * add tooltip in links to display entire link. * add functionality to copy links to clipboard. * chore: peek overview for all the layouts * fix: build errors --------- Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
80 lines
2.1 KiB
TypeScript
80 lines
2.1 KiB
TypeScript
import { useRouter } from "next/router";
|
|
import { observer } from "mobx-react-lite";
|
|
import { Command } from "cmdk";
|
|
import { Check } from "lucide-react";
|
|
// mobx store
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
|
// ui
|
|
import { Avatar } from "@plane/ui";
|
|
// types
|
|
import { IIssue } from "types";
|
|
|
|
type Props = {
|
|
closePalette: () => void;
|
|
issue: IIssue;
|
|
};
|
|
|
|
export const ChangeIssueAssignee: React.FC<Props> = observer((props) => {
|
|
const { closePalette, issue } = props;
|
|
// router
|
|
const router = useRouter();
|
|
const { workspaceSlug, projectId } = router.query;
|
|
// store
|
|
const {
|
|
projectIssues: { updateIssue },
|
|
projectMember: { projectMembers },
|
|
} = useMobxStore();
|
|
|
|
const options =
|
|
projectMembers?.map(({ member }) => ({
|
|
value: member.id,
|
|
query: member.display_name,
|
|
content: (
|
|
<>
|
|
<div className="flex items-center gap-2">
|
|
<Avatar name={member.display_name} src={member.avatar} showTooltip={false} />
|
|
{member.display_name}
|
|
</div>
|
|
{issue.assignees.includes(member.id) && (
|
|
<div>
|
|
<Check className="h-3 w-3" />
|
|
</div>
|
|
)}
|
|
</>
|
|
),
|
|
})) ?? [];
|
|
|
|
const handleUpdateIssue = async (formData: Partial<IIssue>) => {
|
|
if (!workspaceSlug || !projectId || !issue) return;
|
|
|
|
const payload = { ...formData };
|
|
await updateIssue(workspaceSlug.toString(), projectId.toString(), issue.id, payload).catch((e) => {
|
|
console.error(e);
|
|
});
|
|
};
|
|
|
|
const handleIssueAssignees = (assignee: string) => {
|
|
const updatedAssignees = issue.assignees ?? [];
|
|
|
|
if (updatedAssignees.includes(assignee)) updatedAssignees.splice(updatedAssignees.indexOf(assignee), 1);
|
|
else updatedAssignees.push(assignee);
|
|
|
|
handleUpdateIssue({ assignees: updatedAssignees });
|
|
closePalette();
|
|
};
|
|
|
|
return (
|
|
<>
|
|
{options.map((option: any) => (
|
|
<Command.Item
|
|
key={option.value}
|
|
onSelect={() => handleIssueAssignees(option.value)}
|
|
className="focus:outline-none"
|
|
>
|
|
{option.content}
|
|
</Command.Item>
|
|
))}
|
|
</>
|
|
);
|
|
});
|