forked from github/plane
add errors for duplicate labels (#2706)
Co-authored-by: rahulramesha <rahul@appsmith.com>
This commit is contained in:
parent
8d3853b129
commit
b56d188a83
@ -18,6 +18,7 @@ import { Plus, X } from "lucide-react";
|
|||||||
import { IIssue, IIssueLabels } from "types";
|
import { IIssue, IIssueLabels } from "types";
|
||||||
// fetch-keys
|
// fetch-keys
|
||||||
import { PROJECT_ISSUE_LABELS } from "constants/fetch-keys";
|
import { PROJECT_ISSUE_LABELS } from "constants/fetch-keys";
|
||||||
|
import useToast from "hooks/use-toast";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
issueDetails: IIssue | undefined;
|
issueDetails: IIssue | undefined;
|
||||||
@ -44,6 +45,9 @@ export const SidebarLabelSelect: React.FC<Props> = ({
|
|||||||
const [createLabelForm, setCreateLabelForm] = useState(false);
|
const [createLabelForm, setCreateLabelForm] = useState(false);
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
const { setToastAlert } = useToast();
|
||||||
|
|
||||||
const { workspaceSlug, projectId } = router.query;
|
const { workspaceSlug, projectId } = router.query;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -79,6 +83,14 @@ export const SidebarLabelSelect: React.FC<Props> = ({
|
|||||||
submitChanges({ labels: [...(issueDetails?.labels ?? []), res.id] });
|
submitChanges({ labels: [...(issueDetails?.labels ?? []), res.id] });
|
||||||
|
|
||||||
setCreateLabelForm(false);
|
setCreateLabelForm(false);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
setToastAlert({
|
||||||
|
title: "Oops!",
|
||||||
|
type: "error",
|
||||||
|
message: error?.error ?? "Error while adding the label",
|
||||||
|
});
|
||||||
|
reset(formData);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ import { ChevronDown } from "lucide-react";
|
|||||||
import type { IIssueLabels, IState } from "types";
|
import type { IIssueLabels, IState } from "types";
|
||||||
// constants
|
// constants
|
||||||
import { LABEL_COLOR_OPTIONS, getRandomLabelColor } from "constants/label";
|
import { LABEL_COLOR_OPTIONS, getRandomLabelColor } from "constants/label";
|
||||||
|
import useToast from "hooks/use-toast";
|
||||||
|
|
||||||
// types
|
// types
|
||||||
type Props = {
|
type Props = {
|
||||||
@ -58,6 +59,8 @@ export const CreateLabelModal: React.FC<Props> = observer((props) => {
|
|||||||
reset(defaultValues);
|
reset(defaultValues);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const { setToastAlert } = useToast();
|
||||||
|
|
||||||
const onSubmit = async (formData: IIssueLabels) => {
|
const onSubmit = async (formData: IIssueLabels) => {
|
||||||
if (!workspaceSlug) return;
|
if (!workspaceSlug) return;
|
||||||
|
|
||||||
@ -68,7 +71,12 @@ export const CreateLabelModal: React.FC<Props> = observer((props) => {
|
|||||||
if (onSuccess) onSuccess(res);
|
if (onSuccess) onSuccess(res);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log(error);
|
setToastAlert({
|
||||||
|
title: "Oops!",
|
||||||
|
type: "error",
|
||||||
|
message: error?.error ?? "Error while adding the label",
|
||||||
|
});
|
||||||
|
reset(formData);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import { Button, Input } from "@plane/ui";
|
|||||||
import { IIssueLabels } from "types";
|
import { IIssueLabels } from "types";
|
||||||
// fetch-keys
|
// fetch-keys
|
||||||
import { getRandomLabelColor, LABEL_COLOR_OPTIONS } from "constants/label";
|
import { getRandomLabelColor, LABEL_COLOR_OPTIONS } from "constants/label";
|
||||||
|
import useToast from "hooks/use-toast";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
labelForm: boolean;
|
labelForm: boolean;
|
||||||
@ -39,6 +40,8 @@ export const CreateUpdateLabelInline = observer(
|
|||||||
// store
|
// store
|
||||||
const { projectLabel: projectLabelStore } = useMobxStore();
|
const { projectLabel: projectLabelStore } = useMobxStore();
|
||||||
|
|
||||||
|
const { setToastAlert } = useToast();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
control,
|
control,
|
||||||
@ -60,9 +63,19 @@ export const CreateUpdateLabelInline = observer(
|
|||||||
const handleLabelCreate: SubmitHandler<IIssueLabels> = async (formData) => {
|
const handleLabelCreate: SubmitHandler<IIssueLabels> = async (formData) => {
|
||||||
if (!workspaceSlug || !projectId || isSubmitting) return;
|
if (!workspaceSlug || !projectId || isSubmitting) return;
|
||||||
|
|
||||||
await projectLabelStore.createLabel(workspaceSlug.toString(), projectId.toString(), formData).then(() => {
|
await projectLabelStore
|
||||||
|
.createLabel(workspaceSlug.toString(), projectId.toString(), formData)
|
||||||
|
.then(() => {
|
||||||
handleClose();
|
handleClose();
|
||||||
reset(defaultValues);
|
reset(defaultValues);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
setToastAlert({
|
||||||
|
title: "Oops!",
|
||||||
|
type: "error",
|
||||||
|
message: error?.error ?? "Error while adding the label",
|
||||||
|
});
|
||||||
|
reset(formData);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -74,6 +87,14 @@ export const CreateUpdateLabelInline = observer(
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
reset(defaultValues);
|
reset(defaultValues);
|
||||||
handleClose();
|
handleClose();
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
setToastAlert({
|
||||||
|
title: "Oops!",
|
||||||
|
type: "error",
|
||||||
|
message: error?.error ?? "Error while updating the label",
|
||||||
|
});
|
||||||
|
reset(formData);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user