[WEB-1957] fix: exception error on label creation for unauthorized users. (#5127)

This commit is contained in:
Prateek Shourya
2024-07-15 20:29:20 +05:30
committed by GitHub
parent 0e92cae05f
commit 65caaa14cd
2 changed files with 12 additions and 16 deletions

View File

@@ -8,7 +8,7 @@ import { Plus, X, Loader } from "lucide-react";
import { Popover } from "@headlessui/react";
import { IIssueLabel } from "@plane/types";
// hooks
import { Input, TOAST_TYPE, setToast } from "@plane/ui";
import { Input } from "@plane/ui";
// ui
// types
import { TLabelOperations } from "./root";
@@ -67,19 +67,11 @@ export const LabelCreate: FC<ILabelCreate> = (props) => {
const handleLabel = async (formData: Partial<IIssueLabel>) => {
if (!workspaceSlug || !projectId || isSubmitting) return;
try {
const labelResponse = await labelOperations.createLabel(workspaceSlug, projectId, formData);
const currentLabels = [...(values || []), labelResponse.id];
await labelOperations.updateIssue(workspaceSlug, projectId, issueId, { label_ids: currentLabels });
handleIsCreateToggle();
reset(defaultValues);
} catch (error) {
setToast({
title: "Error!",
type: TOAST_TYPE.ERROR,
message: "Label creation failed. Please try again sometime later.",
});
}
const labelResponse = await labelOperations.createLabel(workspaceSlug, projectId, formData);
const currentLabels = [...(values || []), labelResponse.id];
await labelOperations.updateIssue(workspaceSlug, projectId, issueId, { label_ids: currentLabels });
handleIsCreateToggle();
reset(defaultValues);
};
return (
@@ -160,7 +152,11 @@ export const LabelCreate: FC<ILabelCreate> = (props) => {
<X className="h-3.5 w-3.5 text-white" />
</button>
<button type="submit" className="grid place-items-center rounded bg-green-500 p-1" disabled={isSubmitting}>
{isSubmitting ? <Loader className="spin h-3.5 w-3.5 text-white" /> : <Plus className="h-3.5 w-3.5 text-white" />}
{isSubmitting ? (
<Loader className="spin h-3.5 w-3.5 text-white" />
) : (
<Plus className="h-3.5 w-3.5 text-white" />
)}
</button>
</form>
)}

View File

@@ -67,7 +67,7 @@ export const IssueLabel: FC<TIssueLabel> = observer((props) => {
type: TOAST_TYPE.ERROR,
message: "Label creation failed",
});
return error;
throw error;
}
},
}),