mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-05-19 16:20:05 +02:00
Small improvement to persona table
This commit is contained in:
parent
733626f277
commit
77b0d76f53
@ -138,130 +138,6 @@ export function PersonasTable({ personas }: { personas: Persona[] }) {
|
|||||||
})}
|
})}
|
||||||
setRows={updatePersonaOrder}
|
setRows={updatePersonaOrder}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Divider />
|
|
||||||
|
|
||||||
{/* <TableBody>
|
|
||||||
{sortedPersonas.map((persona) => {
|
|
||||||
return (
|
|
||||||
<DraggableRow key={persona.id}>
|
|
||||||
<TableCell className="whitespace-normal break-none">
|
|
||||||
<p className="text font-medium">{persona.name}</p>
|
|
||||||
</TableCell>
|
|
||||||
<TableCell className="whitespace-normal break-all max-w-2xl">
|
|
||||||
{persona.description}
|
|
||||||
</TableCell>
|
|
||||||
<TableCell>{persona.default_persona ? "Yes" : "No"}</TableCell>
|
|
||||||
<TableCell>
|
|
||||||
{" "}
|
|
||||||
<div
|
|
||||||
onClick={async () => {
|
|
||||||
const response = await fetch(
|
|
||||||
`/api/admin/persona/${persona.id}/visible`,
|
|
||||||
{
|
|
||||||
method: "PATCH",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
is_visible: !persona.is_visible,
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
if (response.ok) {
|
|
||||||
router.refresh();
|
|
||||||
} else {
|
|
||||||
setPopup({
|
|
||||||
type: "error",
|
|
||||||
message: `Failed to update persona - ${await response.text()}`,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
className="px-1 py-0.5 hover:bg-hover-light rounded flex cursor-pointer select-none w-fit"
|
|
||||||
>
|
|
||||||
<div className="my-auto w-12">
|
|
||||||
{!persona.is_visible ? (
|
|
||||||
<div className="text-error">Hidden</div>
|
|
||||||
) : (
|
|
||||||
"Visible"
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className="ml-1 my-auto">
|
|
||||||
<CustomCheckbox checked={persona.is_visible} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</TableCell>
|
|
||||||
<TableCell>
|
|
||||||
{persona.is_visible ? (
|
|
||||||
<EditableValue
|
|
||||||
emptyDisplay="-"
|
|
||||||
initialValue={
|
|
||||||
persona.display_priority !== null
|
|
||||||
? persona.display_priority.toString()
|
|
||||||
: ""
|
|
||||||
}
|
|
||||||
onSubmit={async (value) => {
|
|
||||||
if (
|
|
||||||
value === (persona.display_priority || "").toString()
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const numericDisplayPriority = Number(value);
|
|
||||||
if (isNaN(numericDisplayPriority)) {
|
|
||||||
setPopup({
|
|
||||||
message: "Display priority must be a number",
|
|
||||||
type: "error",
|
|
||||||
});
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await fetch(
|
|
||||||
`/api/admin/persona/${persona.id}/display-priority`,
|
|
||||||
{
|
|
||||||
method: "PATCH",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
display_priority: numericDisplayPriority,
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
);
|
|
||||||
if (!response.ok) {
|
|
||||||
setPopup({
|
|
||||||
message: `Failed to update display priority - ${await response.text()}`,
|
|
||||||
type: "error",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
router.refresh();
|
|
||||||
return true;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
"-"
|
|
||||||
)}
|
|
||||||
</TableCell>
|
|
||||||
<TableCell>
|
|
||||||
<div className="flex">
|
|
||||||
<div className="mx-auto">
|
|
||||||
{!persona.default_persona ? (
|
|
||||||
<EditButton
|
|
||||||
onClick={() =>
|
|
||||||
router.push(`/admin/personas/${persona.id}`)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
"-"
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</TableCell>
|
|
||||||
</DraggableRow>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</TableBody> */}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user