From 85fc3cd5146f76027037ac739d627948dbd962ef Mon Sep 17 00:00:00 2001 From: Jack Andrews Date: Thu, 7 Nov 2024 00:03:52 +0000 Subject: [PATCH] feat: lock issue --- apps/client/components/Combo/index.tsx | 25 ++++++-- .../client/components/TicketDetails/index.tsx | 57 +++++++++++++++++-- 2 files changed, 70 insertions(+), 12 deletions(-) diff --git a/apps/client/components/Combo/index.tsx b/apps/client/components/Combo/index.tsx index 98cbafaeb..738ac27e1 100644 --- a/apps/client/components/Combo/index.tsx +++ b/apps/client/components/Combo/index.tsx @@ -33,6 +33,7 @@ export function UserCombo({ defaultName, hideInitial, showIcon, + disabled, }) { const [open, setOpen] = React.useState(false); const [selectedStatus, setSelectedStatus] = React.useState(null); @@ -45,6 +46,7 @@ export function UserCombo({ variant="outline" size="sm" className="w-[180px] justify-start border-none" + disabled={disabled} > {selectedStatus ? (
@@ -117,11 +119,19 @@ export function UserCombo({ ); } -export function IconCombo({ value, update, defaultName, hideInitial }) { +export function IconCombo({ + value, + update, + defaultName, + hideInitial, + disabled, +}) { const [open, setOpen] = React.useState(false); const [selectedStatus, setSelectedStatus] = React.useState(null); const defaultIcon = value.find((k) => k.value === defaultName); + console.log(disabled); + return (
@@ -130,16 +140,17 @@ export function IconCombo({ value, update, defaultName, hideInitial }) { variant="outline" size="sm" className="w-[180px] justify-start border-none" + disabled={disabled} > {selectedStatus ? (
{!hideInitial && (
- - - + + + + -
)} @@ -151,7 +162,9 @@ export function IconCombo({ value, update, defaultName, hideInitial }) {
- {defaultIcon && } + {defaultIcon && ( + + )}
diff --git a/apps/client/components/TicketDetails/index.tsx b/apps/client/components/TicketDetails/index.tsx index 2768d2679..75464595f 100644 --- a/apps/client/components/TicketDetails/index.tsx +++ b/apps/client/components/TicketDetails/index.tsx @@ -134,6 +134,8 @@ export default function Ticket() { const { id } = history.query; async function update() { + if (data && data.ticket && data.ticket.locked) return; + await fetch(`/api/v1/ticket/update`, { method: "PUT", headers: { @@ -157,6 +159,8 @@ export default function Ticket() { } async function updateStatus() { + if (data && data.ticket && data.ticket.locked) return; + await fetch(`/api/v1/ticket/status/update`, { method: "PUT", headers: { @@ -173,6 +177,8 @@ export default function Ticket() { } async function hide(hidden) { + if (data && data.ticket && data.ticket.locked) return; + await fetch(`/api/v1/ticket/status/hide`, { method: "PUT", headers: { @@ -229,6 +235,8 @@ export default function Ticket() { } async function addComment() { + if (data && data.ticket && data.ticket.locked) return; + await fetch(`/api/v1/ticket/comment`, { method: "POST", headers: { @@ -246,6 +254,8 @@ export default function Ticket() { } async function addTime() { + if (data && data.ticket && data.ticket.locked) return; + await fetch(`/api/v1/time/new`, { method: "POST", headers: { @@ -290,6 +300,8 @@ export default function Ticket() { } async function transferTicket() { + if (data && data.ticket && data.ticket.locked) return; + if (n !== undefined) { await fetch(`/api/v1/ticket/transfer`, { method: "POST", @@ -426,6 +438,7 @@ export default function Ticket() { } const handleInputChange = (editor) => { + if (data.ticket.locked) return; setIssue(editor.document); }; @@ -465,6 +478,7 @@ export default function Ticket() { defaultValue={data.ticket.title} onChange={(e) => setTitle(e.target.value)} key={data.ticket.id} + disabled={data.ticket.locked} />
@@ -584,6 +598,7 @@ export default function Ticket() { ? data.ticket.assignedTo.name : "" } + disabled={data.ticket.locked} /> )}
@@ -594,6 +609,7 @@ export default function Ticket() { defaultName={ data.ticket.priority ? data.ticket.priority : "" } + disabled={data.ticket.locked} />
@@ -662,6 +679,7 @@ export default function Ticket() { sideMenu={false} className="m-0 p-0 bg-transparent dark:text-white" onChange={handleInputChange} + editable={!data.ticket.locked} /> ) : ( @@ -773,9 +791,14 @@ export default function Ticket() { name="comment" rows={3} className="block w-full bg-transparent rounded-md border-0 py-1.5 shadow-sm ring-1 ring-inset ring-background focus:ring-0 focus:ring-inset focus:ring-gray-900 sm:text-sm sm:leading-6" - placeholder="Leave a comment" + placeholder={ + data.ticket.locked + ? "This ticket is locked" + : "Leave a comment" + } defaultValue={""} onChange={(e) => setComment(e.target.value)} + disabled={data.ticket.locked} />
@@ -811,8 +834,15 @@ export default function Ticket() { {data.ticket.isComplete ? ( @@ -862,6 +904,7 @@ export default function Ticket() { defaultName={ data.ticket.assignedTo ? data.ticket.assignedTo.name : "" } + disabled={data.ticket.locked} /> )} @@ -869,12 +912,14 @@ export default function Ticket() { value={priorityOptions} update={setPriority} defaultName={data.ticket.priority ? data.ticket.priority : ""} + disabled={data.ticket.locked} /> {/*