Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(annotation-assignment): allow removing user assignments in UI (#8370)

marliessophie738cbbc8cd7c
diff --git a/web/src/features/annotation-queues/components/UserAssignmentSection.tsx b/web/src/features/annotation-queues/components/UserAssignmentSection.tsx
index 0d214ffce3..cf490d8c48 100644
--- a/web/src/features/annotation-queues/components/UserAssignmentSection.tsx
+++ b/web/src/features/annotation-queues/components/UserAssignmentSection.tsx
@@ -5,6 +5,7 @@ import { Button } from "@/src/components/ui/button";
import { MultiSelectCombobox } from "@/src/components/ui/multi-select-combobox";
import { useUserSearch } from "@/src/features/annotation-queues/hooks/useUserSearch";
import { useSelectedUsers } from "@/src/features/annotation-queues/hooks/useSelectedUsers";
+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";
interface UserAssignmentSectionProps {
projectId: string;
@@ -27,6 +28,7 @@ export const UserAssignmentSection = ({
projectId: projectId,
scope: "annotationQueueAssignments:CUD",
});
+ const utils = api.useUtils();
// Get current assigned users
const queueAssignmentsQuery =
@@ -35,6 +37,18 @@ export const UserAssignmentSection = ({
{ enabled: !!queueId && hasQueueAssignmentsReadAccess },
);
+ const deleteQueueAssignmentMutation =
+ api.annotationQueueAssignments.delete.useMutation({
+ onSuccess: () => {
+ utils.annotationQueueAssignments.invalidate();
+ utils.annotationQueues.invalidate();
+ showSuccessToast({
+ title: "Removed assignment",
+ description: "User removed from queue successfully",
+ });
+ },
+ });
+
// Combine selected users and assigned users for exclusion
const assignedUserIds =
queueAssignmentsQuery.data?.assignments.map((user: any) => user.id) || [];
@@ -56,6 +70,16 @@ export const UserAssignmentSection = ({
onChange(userIds);
};
+ // Handle user removal
+ const handleUserRemove = (userId: string) => {
+ if (!!queueId)
+ deleteQueueAssignmentMutation.mutate({
+ projectId,
+ queueId,
+ userId,
+ });
+ };
+
// Check if there are more assigned users than shown
const hasMoreAssignedUsers =
queueAssignmentsQuery.data &&
@@ -133,9 +157,17 @@ export const UserAssignmentSection = ({
</p>
</div>
</div>
- {/* <Button variant="ghost" size="icon-sm">
+ <Button
+ variant="ghost"
+ size="icon-sm"
+ disabled={
+ !hasQueueAssignmentWriteAccess ||
+ deleteQueueAssignmentMutation.isLoading
+ }
+ onClick={() => handleUserRemove(user.id)}
+ >
<X className="h-3 w-3" />
- </Button> */}
+ </Button>
</div>
{(index <
queueAssignmentsQuery.data?.assignments.length - 1 ||