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