mirror of
https://github.com/hex248/sprint.git
synced 2026-02-09 02:33:02 +00:00
max status length of 24
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { ISSUE_STATUS_MAX_LENGTH } from "@issue/shared";
|
||||||
import type { BunRequest } from "bun";
|
import type { BunRequest } from "bun";
|
||||||
import { getOrganisationById, updateOrganisation } from "../../db/queries";
|
import { getOrganisationById, updateOrganisation } from "../../db/queries";
|
||||||
|
|
||||||
@@ -20,6 +21,12 @@ export default async function organisationUpdate(req: BunRequest) {
|
|||||||
if (statuses.length === 0) {
|
if (statuses.length === 0) {
|
||||||
return new Response("statuses must have at least one status", { status: 400 });
|
return new Response("statuses must have at least one status", { status: 400 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (statuses.some((s) => s.length > ISSUE_STATUS_MAX_LENGTH)) {
|
||||||
|
return new Response(`status must be <= ${ISSUE_STATUS_MAX_LENGTH} characters`, {
|
||||||
|
status: 400,
|
||||||
|
});
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
return new Response("invalid statuses format (must be JSON array)", { status: 400 });
|
return new Response("invalid statuses format (must be JSON array)", { status: 400 });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
import type { OrganisationMemberResponse, OrganisationResponse } from "@issue/shared";
|
import {
|
||||||
|
ISSUE_STATUS_MAX_LENGTH,
|
||||||
|
type OrganisationMemberResponse,
|
||||||
|
type OrganisationResponse,
|
||||||
|
} from "@issue/shared";
|
||||||
import { ChevronDown, ChevronUp, Plus, X } from "lucide-react";
|
import { ChevronDown, ChevronUp, Plus, X } from "lucide-react";
|
||||||
import type { ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
@@ -36,6 +40,7 @@ function OrganisationsDialog({
|
|||||||
const [statuses, setStatuses] = useState<string[]>([]);
|
const [statuses, setStatuses] = useState<string[]>([]);
|
||||||
const [isCreatingStatus, setIsCreatingStatus] = useState(false);
|
const [isCreatingStatus, setIsCreatingStatus] = useState(false);
|
||||||
const [newStatusName, setNewStatusName] = useState("");
|
const [newStatusName, setNewStatusName] = useState("");
|
||||||
|
const [statusError, setStatusError] = useState<string | null>(null);
|
||||||
const [statusToRemove, setStatusToRemove] = useState<string | null>(null);
|
const [statusToRemove, setStatusToRemove] = useState<string | null>(null);
|
||||||
const [reassignToStatus, setReassignToStatus] = useState<string>("");
|
const [reassignToStatus, setReassignToStatus] = useState<string>("");
|
||||||
|
|
||||||
@@ -185,9 +190,16 @@ function OrganisationsDialog({
|
|||||||
const handleCreateStatus = async () => {
|
const handleCreateStatus = async () => {
|
||||||
const trimmed = newStatusName.trim().toUpperCase();
|
const trimmed = newStatusName.trim().toUpperCase();
|
||||||
if (!trimmed) return;
|
if (!trimmed) return;
|
||||||
|
|
||||||
|
if (trimmed.length > ISSUE_STATUS_MAX_LENGTH) {
|
||||||
|
setStatusError(`status must be <= ${ISSUE_STATUS_MAX_LENGTH} characters`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (statuses.includes(trimmed)) {
|
if (statuses.includes(trimmed)) {
|
||||||
setNewStatusName("");
|
setNewStatusName("");
|
||||||
setIsCreatingStatus(false);
|
setIsCreatingStatus(false);
|
||||||
|
setStatusError(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,6 +207,7 @@ function OrganisationsDialog({
|
|||||||
await updateStatuses(newStatuses);
|
await updateStatuses(newStatuses);
|
||||||
setNewStatusName("");
|
setNewStatusName("");
|
||||||
setIsCreatingStatus(false);
|
setIsCreatingStatus(false);
|
||||||
|
setStatusError(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRemoveStatusClick = (status: string) => {
|
const handleRemoveStatusClick = (status: string) => {
|
||||||
@@ -440,10 +453,15 @@ function OrganisationsDialog({
|
|||||||
</div>
|
</div>
|
||||||
{isAdmin &&
|
{isAdmin &&
|
||||||
(isCreatingStatus ? (
|
(isCreatingStatus ? (
|
||||||
|
<div className="flex flex-col gap-2">
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Input
|
<Input
|
||||||
value={newStatusName}
|
value={newStatusName}
|
||||||
onChange={(e) => setNewStatusName(e.target.value)}
|
maxLength={ISSUE_STATUS_MAX_LENGTH}
|
||||||
|
onChange={(e) => {
|
||||||
|
setNewStatusName(e.target.value);
|
||||||
|
if (statusError) setStatusError(null);
|
||||||
|
}}
|
||||||
placeholder="Status name"
|
placeholder="Status name"
|
||||||
className="flex-1"
|
className="flex-1"
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
@@ -452,6 +470,7 @@ function OrganisationsDialog({
|
|||||||
} else if (e.key === "Escape") {
|
} else if (e.key === "Escape") {
|
||||||
setIsCreatingStatus(false);
|
setIsCreatingStatus(false);
|
||||||
setNewStatusName("");
|
setNewStatusName("");
|
||||||
|
setStatusError(null);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
autoFocus
|
autoFocus
|
||||||
@@ -460,14 +479,27 @@ function OrganisationsDialog({
|
|||||||
variant="outline"
|
variant="outline"
|
||||||
size="icon"
|
size="icon"
|
||||||
onClick={() => void handleCreateStatus()}
|
onClick={() => void handleCreateStatus()}
|
||||||
|
disabled={
|
||||||
|
newStatusName.trim().length >
|
||||||
|
ISSUE_STATUS_MAX_LENGTH
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<Plus className="size-4" />
|
<Plus className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
{statusError && (
|
||||||
|
<p className="text-xs text-destructive">
|
||||||
|
{statusError}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
onClick={() => setIsCreatingStatus(true)}
|
onClick={() => {
|
||||||
|
setIsCreatingStatus(true);
|
||||||
|
setStatusError(null);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Create status <Plus className="size-4" />
|
Create status <Plus className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -42,4 +42,6 @@ export {
|
|||||||
UserSelectSchema,
|
UserSelectSchema,
|
||||||
} from "./schema";
|
} from "./schema";
|
||||||
|
|
||||||
|
export const ISSUE_STATUS_MAX_LENGTH = 24;
|
||||||
|
|
||||||
export { calculateBreakTimeMs, calculateWorkTimeMs, isTimerRunning } from "./utils/time-tracking";
|
export { calculateBreakTimeMs, calculateWorkTimeMs, isTimerRunning } from "./utils/time-tracking";
|
||||||
|
|||||||
Reference in New Issue
Block a user