Skip to content

Commit 3d25194

Browse files
authored
Merge pull request #20 from makeplane/stage-release
promote staging branch to master
2 parents 71cd84e + 403d2a9 commit 3d25194

34 files changed

+3850
-599
lines changed

apps/app/components/command-palette/index.tsx

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import React, { useState, useCallback, useEffect } from "react";
22
// next
33
import { useRouter } from "next/router";
4+
// swr
5+
import { mutate } from "swr";
6+
// react hook form
7+
import { SubmitHandler, useForm } from "react-hook-form";
48
// headless ui
59
import { Combobox, Dialog, Transition } from "@headlessui/react";
610
// hooks
@@ -22,9 +26,11 @@ import CreateProjectModal from "components/project/CreateProjectModal";
2226
import CreateUpdateIssuesModal from "components/project/issues/CreateUpdateIssueModal";
2327
import CreateUpdateCycleModal from "components/project/cycles/CreateUpdateCyclesModal";
2428
// types
25-
import { IIssue } from "types";
29+
import { IIssue, IProject, IssueResponse } from "types";
2630
import { Button } from "ui";
27-
import { SubmitHandler, useForm } from "react-hook-form";
31+
import issuesServices from "lib/services/issues.services";
32+
// fetch keys
33+
import { PROJECTS_LIST, PROJECT_ISSUES_LIST } from "constants/fetch-keys";
2834

2935
type ItemType = {
3036
name: string;
@@ -33,7 +39,7 @@ type ItemType = {
3339
};
3440

3541
type FormInput = {
36-
issue: string[];
42+
issue_ids: string[];
3743
};
3844

3945
const CommandPalette: React.FC = () => {
@@ -47,7 +53,7 @@ const CommandPalette: React.FC = () => {
4753
const [isShortcutsModalOpen, setIsShortcutsModalOpen] = useState(false);
4854
const [isCreateCycleModalOpen, setIsCreateCycleModalOpen] = useState(false);
4955

50-
const { issues, activeProject } = useUser();
56+
const { activeWorkspace, activeProject, issues, cycles } = useUser();
5157

5258
const { toggleCollapsed } = useTheme();
5359

@@ -59,6 +65,14 @@ const CommandPalette: React.FC = () => {
5965
: issues?.results.filter((issue) => issue.name.toLowerCase().includes(query.toLowerCase())) ??
6066
[];
6167

68+
const {
69+
register,
70+
formState: { errors, isSubmitting },
71+
handleSubmit,
72+
reset,
73+
setError,
74+
} = useForm<FormInput>();
75+
6276
const quickActions = [
6377
{
6478
name: "Add new issue...",
@@ -81,6 +95,7 @@ const CommandPalette: React.FC = () => {
8195
const handleCommandPaletteClose = () => {
8296
setIsPaletteOpen(false);
8397
setQuery("");
98+
reset();
8499
};
85100

86101
const handleKeyDown = useCallback(
@@ -127,21 +142,42 @@ const CommandPalette: React.FC = () => {
127142
[toggleCollapsed, setToastAlert, router]
128143
);
129144

130-
const {
131-
register,
132-
formState: { errors, isSubmitting },
133-
handleSubmit,
134-
reset,
135-
setError,
136-
control,
137-
} = useForm<FormInput>();
138-
139145
const handleDelete: SubmitHandler<FormInput> = (data) => {
140-
console.log("Deleting... " + JSON.stringify(data));
146+
if (activeWorkspace && activeProject && data.issue_ids) {
147+
issuesServices
148+
.bulkDeleteIssues(activeWorkspace.slug, activeProject.id, data)
149+
.then((res) => {
150+
mutate<IssueResponse>(
151+
PROJECT_ISSUES_LIST(activeWorkspace.slug, activeProject.id),
152+
(prevData) => {
153+
return {
154+
...(prevData as IssueResponse),
155+
count: (prevData?.results ?? []).filter(
156+
(p) => !data.issue_ids.some((id) => p.id === id)
157+
).length,
158+
results: (prevData?.results ?? []).filter(
159+
(p) => !data.issue_ids.some((id) => p.id === id)
160+
),
161+
};
162+
},
163+
false
164+
);
165+
})
166+
.catch((e) => {
167+
console.log(e);
168+
});
169+
}
141170
};
142171

143172
const handleAddToCycle: SubmitHandler<FormInput> = (data) => {
144-
console.log("Adding to cycle...");
173+
if (activeWorkspace && activeProject && data.issue_ids) {
174+
issuesServices
175+
.bulkAddIssuesToCycle(activeWorkspace.slug, activeProject.id, "", data)
176+
.then((res) => {})
177+
.catch((e) => {
178+
console.log(e);
179+
});
180+
}
145181
};
146182

147183
useEffect(() => {
@@ -254,10 +290,16 @@ const CommandPalette: React.FC = () => {
254290
/> */}
255291
<input
256292
type="checkbox"
257-
{...register("issue")}
293+
{...register("issue_ids")}
294+
id={`issue-${issue.id}`}
258295
value={issue.id}
259296
/>
260-
<span className="ml-3 flex-auto truncate">{issue.name}</span>
297+
<label
298+
htmlFor={`issue-${issue.id}`}
299+
className="ml-3 flex-auto truncate"
300+
>
301+
{issue.name}
302+
</label>
261303
{active && (
262304
<span className="ml-3 flex-none text-gray-500">
263305
Jump to...
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { LexicalToolbar } from "./toolbar";
1919
import { initialConfig } from "./config";
2020
// helpers
2121
import { getValidatedValue } from "./helpers/editor";
22+
import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary";
2223

2324
export interface RichTextEditorProps {
2425
onChange: (state: string) => void;
@@ -51,6 +52,7 @@ const RichTextEditor: FC<RichTextEditorProps> = (props) => {
5152
contentEditable={
5253
<ContentEditable className='className="h-[450px] outline-none py-[15px] px-2.5 resize-none overflow-hidden text-ellipsis' />
5354
}
55+
ErrorBoundary={LexicalErrorBoundary}
5456
placeholder={
5557
<div className="absolute top-[15px] left-[10px] pointer-events-none select-none text-gray-400">
5658
Enter some text...
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

components/lexical/toolbar/floating-link-editor.tsx renamed to apps/app/components/lexical/toolbar/floating-link-editor.tsx

File renamed without changes.

0 commit comments

Comments
 (0)