mirror of
https://github.com/hex248/sprint.git
synced 2026-02-07 18:23:03 +00:00
introduced sprint selection to the create issue dialog
This commit is contained in:
@@ -7,6 +7,7 @@ export async function createIssue(
|
|||||||
title: string,
|
title: string,
|
||||||
description: string,
|
description: string,
|
||||||
creatorId: number,
|
creatorId: number,
|
||||||
|
sprintId?: number,
|
||||||
assigneeId?: number,
|
assigneeId?: number,
|
||||||
status?: string,
|
status?: string,
|
||||||
) {
|
) {
|
||||||
@@ -30,6 +31,7 @@ export async function createIssue(
|
|||||||
description,
|
description,
|
||||||
number: nextNumber,
|
number: nextNumber,
|
||||||
creatorId,
|
creatorId,
|
||||||
|
sprintId,
|
||||||
assigneeId,
|
assigneeId,
|
||||||
...(status && { status }),
|
...(status && { status }),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -23,11 +23,13 @@ export default async function issueCreate(req: AuthedRequest) {
|
|||||||
|
|
||||||
const title = url.searchParams.get("title") || "Untitled Issue";
|
const title = url.searchParams.get("title") || "Untitled Issue";
|
||||||
const description = url.searchParams.get("description") || "";
|
const description = url.searchParams.get("description") || "";
|
||||||
|
const sprintIdParam = url.searchParams.get("sprintId");
|
||||||
|
const sprintId = sprintIdParam ? Number(sprintIdParam) : undefined;
|
||||||
const assigneeIdParam = url.searchParams.get("assigneeId");
|
const assigneeIdParam = url.searchParams.get("assigneeId");
|
||||||
const assigneeId = assigneeIdParam ? Number(assigneeIdParam) : undefined;
|
const assigneeId = assigneeIdParam ? Number(assigneeIdParam) : undefined;
|
||||||
const status = url.searchParams.get("status") || undefined;
|
const status = url.searchParams.get("status") || undefined;
|
||||||
|
|
||||||
const issue = await createIssue(project.id, title, description, req.userId, assigneeId, status);
|
const issue = await createIssue(project.id, title, description, req.userId, sprintId, assigneeId, status);
|
||||||
|
|
||||||
return Response.json(issue);
|
return Response.json(issue);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
import { ISSUE_DESCRIPTION_MAX_LENGTH, ISSUE_TITLE_MAX_LENGTH, type UserRecord } from "@issue/shared";
|
import {
|
||||||
|
ISSUE_DESCRIPTION_MAX_LENGTH,
|
||||||
|
ISSUE_TITLE_MAX_LENGTH,
|
||||||
|
type SprintRecord,
|
||||||
|
type UserRecord,
|
||||||
|
} from "@issue/shared";
|
||||||
|
|
||||||
import { type FormEvent, useState } from "react";
|
import { type FormEvent, useState } from "react";
|
||||||
import { useAuthenticatedSession } from "@/components/session-provider";
|
import { useAuthenticatedSession } from "@/components/session-provider";
|
||||||
import { StatusSelect } from "@/components/status-select";
|
import { StatusSelect } from "@/components/status-select";
|
||||||
@@ -18,15 +24,18 @@ import { SelectTrigger } from "@/components/ui/select";
|
|||||||
import { UserSelect } from "@/components/user-select";
|
import { UserSelect } from "@/components/user-select";
|
||||||
import { issue } from "@/lib/server";
|
import { issue } from "@/lib/server";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
import { SprintSelect } from "./sprint-select";
|
||||||
|
|
||||||
export function CreateIssue({
|
export function CreateIssue({
|
||||||
projectId,
|
projectId,
|
||||||
|
sprints,
|
||||||
members,
|
members,
|
||||||
statuses,
|
statuses,
|
||||||
trigger,
|
trigger,
|
||||||
completeAction,
|
completeAction,
|
||||||
}: {
|
}: {
|
||||||
projectId?: number;
|
projectId?: number;
|
||||||
|
sprints?: SprintRecord[];
|
||||||
members?: UserRecord[];
|
members?: UserRecord[];
|
||||||
statuses: Record<string, string>;
|
statuses: Record<string, string>;
|
||||||
trigger?: React.ReactNode;
|
trigger?: React.ReactNode;
|
||||||
@@ -37,6 +46,7 @@ export function CreateIssue({
|
|||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [title, setTitle] = useState("");
|
const [title, setTitle] = useState("");
|
||||||
const [description, setDescription] = useState("");
|
const [description, setDescription] = useState("");
|
||||||
|
const [sprintId, setSprintId] = useState<string>("unassigned");
|
||||||
const [assigneeId, setAssigneeId] = useState<string>("unassigned");
|
const [assigneeId, setAssigneeId] = useState<string>("unassigned");
|
||||||
const [status, setStatus] = useState<string>(Object.keys(statuses)[0] ?? "");
|
const [status, setStatus] = useState<string>(Object.keys(statuses)[0] ?? "");
|
||||||
const [submitAttempted, setSubmitAttempted] = useState(false);
|
const [submitAttempted, setSubmitAttempted] = useState(false);
|
||||||
@@ -46,6 +56,7 @@ export function CreateIssue({
|
|||||||
const reset = () => {
|
const reset = () => {
|
||||||
setTitle("");
|
setTitle("");
|
||||||
setDescription("");
|
setDescription("");
|
||||||
|
setSprintId("unassigned");
|
||||||
setAssigneeId("unassigned");
|
setAssigneeId("unassigned");
|
||||||
setStatus(statuses?.[0] ?? "");
|
setStatus(statuses?.[0] ?? "");
|
||||||
setSubmitAttempted(false);
|
setSubmitAttempted(false);
|
||||||
@@ -90,6 +101,7 @@ export function CreateIssue({
|
|||||||
projectId,
|
projectId,
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
|
sprintId: sprintId === "unassigned" ? null : Number(sprintId),
|
||||||
assigneeId: assigneeId === "unassigned" ? null : Number(assigneeId),
|
assigneeId: assigneeId === "unassigned" ? null : Number(assigneeId),
|
||||||
status: status.trim() === "" ? undefined : status,
|
status: status.trim() === "" ? undefined : status,
|
||||||
onSuccess: async (data) => {
|
onSuccess: async (data) => {
|
||||||
@@ -131,7 +143,7 @@ export function CreateIssue({
|
|||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
<div className="grid">
|
<div className="grid">
|
||||||
{statuses && Object.keys(statuses).length > 0 && (
|
{statuses && Object.keys(statuses).length > 0 && (
|
||||||
<div className="flex flex-col gap-2 mb-4">
|
<div className="flex items-center gap-2 mb-4">
|
||||||
<Label>Status</Label>
|
<Label>Status</Label>
|
||||||
<StatusSelect
|
<StatusSelect
|
||||||
statuses={statuses}
|
statuses={statuses}
|
||||||
@@ -188,8 +200,15 @@ export function CreateIssue({
|
|||||||
maxLength={ISSUE_DESCRIPTION_MAX_LENGTH}
|
maxLength={ISSUE_DESCRIPTION_MAX_LENGTH}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{sprints && sprints.length > 0 && (
|
||||||
|
<div className="flex items-center gap-2 mt-0">
|
||||||
|
<Label className="text-sm">Sprint</Label>
|
||||||
|
<SprintSelect sprints={sprints} value={sprintId} onChange={setSprintId} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{members && members.length > 0 && (
|
{members && members.length > 0 && (
|
||||||
<div className="flex items-center gap-2 mt-2">
|
<div className="flex items-center gap-2 mt-4">
|
||||||
<Label className="text-sm">Assignee</Label>
|
<Label className="text-sm">Assignee</Label>
|
||||||
<UserSelect users={members} value={assigneeId} onChange={setAssigneeId} />
|
<UserSelect users={members} value={assigneeId} onChange={setAssigneeId} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export async function create({
|
|||||||
projectId,
|
projectId,
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
|
sprintId,
|
||||||
assigneeId,
|
assigneeId,
|
||||||
status,
|
status,
|
||||||
onSuccess,
|
onSuccess,
|
||||||
@@ -13,6 +14,7 @@ export async function create({
|
|||||||
projectId: number;
|
projectId: number;
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
|
sprintId?: number | null;
|
||||||
assigneeId?: number | null;
|
assigneeId?: number | null;
|
||||||
status?: string;
|
status?: string;
|
||||||
} & ServerQueryInput) {
|
} & ServerQueryInput) {
|
||||||
@@ -20,6 +22,7 @@ export async function create({
|
|||||||
url.searchParams.set("projectId", `${projectId}`);
|
url.searchParams.set("projectId", `${projectId}`);
|
||||||
url.searchParams.set("title", title.trim());
|
url.searchParams.set("title", title.trim());
|
||||||
if (description.trim() !== "") url.searchParams.set("description", description.trim());
|
if (description.trim() !== "") url.searchParams.set("description", description.trim());
|
||||||
|
if (sprintId != null) url.searchParams.set("sprintId", `${sprintId}`);
|
||||||
if (assigneeId != null) url.searchParams.set("assigneeId", `${assigneeId}`);
|
if (assigneeId != null) url.searchParams.set("assigneeId", `${assigneeId}`);
|
||||||
if (status != null && status.trim() !== "") url.searchParams.set("status", status.trim());
|
if (status != null && status.trim() !== "") url.searchParams.set("status", status.trim());
|
||||||
|
|
||||||
|
|||||||
@@ -419,6 +419,7 @@ export default function App() {
|
|||||||
<>
|
<>
|
||||||
<CreateIssue
|
<CreateIssue
|
||||||
projectId={selectedProject?.Project.id}
|
projectId={selectedProject?.Project.id}
|
||||||
|
sprints={sprints}
|
||||||
members={members}
|
members={members}
|
||||||
statuses={selectedOrganisation.Organisation.statuses}
|
statuses={selectedOrganisation.Organisation.statuses}
|
||||||
completeAction={async () => {
|
completeAction={async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user