Skip to content

Commit af14425

Browse files
authored
fix: make users table scrollable (#10311)
* scrollable * simplify * scroll * test * clean * fix it * clean * types
1 parent 0d2d397 commit af14425

File tree

15 files changed

+619
-213
lines changed

15 files changed

+619
-213
lines changed

app/schema.graphql

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,10 @@ input DeleteUsersInput {
940940
userIds: [ID!]!
941941
}
942942

943+
type DeleteUsersPayload {
944+
userIds: [ID!]!
945+
}
946+
943947
type Dimension implements Node {
944948
"""The Globally Unique ID of this object"""
945949
id: ID!
@@ -1880,7 +1884,7 @@ type Mutation {
18801884
createUser(input: CreateUserInput!): UserMutationPayload!
18811885
patchUser(input: PatchUserInput!): UserMutationPayload!
18821886
patchViewer(input: PatchViewerInput!): UserMutationPayload!
1883-
deleteUsers(input: DeleteUsersInput!): Void
1887+
deleteUsers(input: DeleteUsersInput!): DeleteUsersPayload!
18841888
}
18851889

18861890
"""An object with a Globally Unique ID"""
@@ -3384,7 +3388,4 @@ type ValidationResult {
33843388

33853389
enum VectorDriftMetric {
33863390
euclideanDistance
3387-
}
3388-
3389-
"""Represents NULL values"""
3390-
scalar Void
3391+
}

app/src/pages/settings/DeleteUserDialog.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useCallback } from "react";
2-
import { graphql, useMutation } from "react-relay";
2+
import { type DataID, graphql, useMutation } from "react-relay";
33

44
import {
55
Button,
@@ -18,16 +18,23 @@ import { getErrorMessagesFromRelayMutationError } from "@phoenix/utils/errorUtil
1818

1919
export function DeleteUserDialog({
2020
userId,
21+
connectionIds,
2122
onDeleted,
2223
onClose,
2324
}: {
2425
userId: string;
26+
connectionIds: DataID[];
2527
onDeleted: () => void;
2628
onClose: () => void;
2729
}) {
2830
const [commit, isCommitting] = useMutation(graphql`
29-
mutation DeleteUserDialogMutation($input: DeleteUsersInput!) {
30-
deleteUsers(input: $input)
31+
mutation DeleteUserDialogMutation(
32+
$input: DeleteUsersInput!
33+
$connectionIds: [ID!]!
34+
) {
35+
deleteUsers(input: $input) {
36+
userIds @deleteEdge(connections: $connectionIds)
37+
}
3138
}
3239
`);
3340

@@ -40,6 +47,7 @@ export function DeleteUserDialog({
4047
input: {
4148
userIds: [userId],
4249
},
50+
connectionIds,
4351
},
4452
onCompleted: () => {
4553
notifySuccess({
@@ -57,7 +65,15 @@ export function DeleteUserDialog({
5765
});
5866
},
5967
});
60-
}, [commit, notifyError, notifySuccess, onClose, onDeleted, userId]);
68+
}, [
69+
commit,
70+
connectionIds,
71+
notifyError,
72+
notifySuccess,
73+
onClose,
74+
onDeleted,
75+
userId,
76+
]);
6177

6278
return (
6379
<Dialog>

app/src/pages/settings/UserActionMenu.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useMemo, useState } from "react";
2+
import { type DataID } from "relay-runtime";
23

34
import {
45
Button,
@@ -21,8 +22,8 @@ import { ResetPasswordDialog } from "./ResetPasswordDialog";
2122

2223
type UserActionMenuProps = {
2324
userId: string;
24-
onUserDeleted: () => void;
2525
authMethod: AuthMethod;
26+
connectionIds: DataID[];
2627
};
2728

2829
enum UserAction {
@@ -35,7 +36,7 @@ function isLocalAuth(authMethod: AuthMethod): authMethod is "LOCAL" {
3536
}
3637

3738
export function UserActionMenu(props: UserActionMenuProps) {
38-
const { userId, onUserDeleted, authMethod } = props;
39+
const { userId, authMethod, connectionIds } = props;
3940
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
4041
const [showResetPasswordDialog, setShowResetPasswordDialog] = useState(false);
4142

@@ -109,8 +110,8 @@ export function UserActionMenu(props: UserActionMenuProps) {
109110
<DeleteUserDialog
110111
userId={userId}
111112
onClose={() => setShowDeleteDialog(false)}
113+
connectionIds={connectionIds}
112114
onDeleted={() => {
113-
onUserDeleted();
114115
setShowDeleteDialog(false);
115116
}}
116117
/>

app/src/pages/settings/UserRoleChangeDialog.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,25 @@ export function UserRoleChangeDialog({
2222
email,
2323
currentRole,
2424
newRole,
25-
onRoleChanged,
2625
onClose,
2726
}: {
2827
userId: string;
2928
email: string;
3029
newRole: UserRoleInput;
3130
currentRole: string;
32-
onRoleChanged: () => void;
3331
onClose: () => void;
3432
}) {
3533
const [commit, isCommitting] = useMutation<UserRoleChangeDialogMutation>(
3634
graphql`
3735
mutation UserRoleChangeDialogMutation($input: PatchUserInput!) {
3836
patchUser(input: $input) {
39-
__typename
37+
user {
38+
id
39+
role {
40+
id
41+
name
42+
}
43+
}
4044
}
4145
}
4246
`
@@ -58,7 +62,6 @@ export function UserRoleChangeDialog({
5862
title: "Role Changed",
5963
message: "Users role has been changed.",
6064
});
61-
onRoleChanged();
6265
onClose();
6366
},
6467
onError: (error) => {
@@ -68,15 +71,7 @@ export function UserRoleChangeDialog({
6871
});
6972
},
7073
});
71-
}, [
72-
commit,
73-
newRole,
74-
notifyError,
75-
notifySuccess,
76-
onClose,
77-
onRoleChanged,
78-
userId,
79-
]);
74+
}, [commit, newRole, notifyError, notifySuccess, onClose, userId]);
8075
return (
8176
<Dialog>
8277
<DialogContent>

app/src/pages/settings/UsersCard.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,15 @@ export function UsersCard() {
6666
</Button>
6767
}
6868
>
69-
<View overflow="auto">
70-
<Suspense
71-
fallback={
72-
<View padding="size-200">
73-
<Loading />
74-
</View>
75-
}
76-
>
77-
<UsersTable query={data} />
78-
</Suspense>
79-
</View>
69+
<Suspense
70+
fallback={
71+
<View padding="size-200">
72+
<Loading />
73+
</View>
74+
}
75+
>
76+
<UsersTable query={data} />
77+
</Suspense>
8078
{dialog}
8179
</Card>
8280
);

0 commit comments

Comments
 (0)