MCPcopy Create free account
hub / github.com/bytebase/bytebase / UserTable

Function UserTable

frontend/src/react/pages/settings/UsersPage.tsx:74–400  ·  view source on GitHub ↗
({
  users,
  onUserUpdated,
  onUserSelected,
  onGroupSelected,
}: {
  users: User[];
  onUserUpdated: (user: User) => void;
  onUserSelected?: (user: User) => void;
  onGroupSelected?: (group: Group) => void;
})

Source from the content-addressed store, hash-verified

72// ============================================================
73
74function UserTable({
75 users,
76 onUserUpdated,
77 onUserSelected,
78 onGroupSelected,
79}: {
80 users: User[];
81 onUserUpdated: (user: User) => void;
82 onUserSelected?: (user: User) => void;
83 onGroupSelected?: (group: Group) => void;
84}) {
85 const { t } = useTranslation();
86 const currentUser = useCurrentUser();
87 const archiveUser = useAppStore((state) => state.archiveUser);
88 const restoreUser = useAppStore((state) => state.restoreUser);
89 const batchGetOrFetchGroups = useAppStore(
90 (state) => state.batchGetOrFetchGroups
91 );
92 const deleteServiceAccount = useAppStore(
93 (state) => state.deleteServiceAccount
94 );
95 const undeleteServiceAccount = useAppStore(
96 (state) => state.undeleteServiceAccount
97 );
98 const deleteWorkloadIdentity = useAppStore(
99 (state) => state.deleteWorkloadIdentity
100 );
101 const undeleteWorkloadIdentity = useAppStore(
102 (state) => state.undeleteWorkloadIdentity
103 );
104
105 // Batch fetch groups when user list changes
106 useEffect(() => {
107 const allGroupNames = users.flatMap((u) => u.groups);
108 if (allGroupNames.length > 0) {
109 batchGetOrFetchGroups(allGroupNames);
110 }
111 }, [users, batchGetOrFetchGroups]);
112
113 const handleDeactivate = async (user: User) => {
114 const accountType = getAccountTypeByEmail(user.email);
115 const fullName = getUserFullNameByType(user);
116
117 const confirmed = window.confirm(
118 t("settings.members.action.deactivate-confirm-title")
119 );
120 if (!confirmed) return;
121
122 try {
123 if (accountType === AccountType.SERVICE_ACCOUNT) {
124 await deleteServiceAccount(fullName);
125 } else if (accountType === AccountType.WORKLOAD_IDENTITY) {
126 await deleteWorkloadIdentity(fullName);
127 } else {
128 await archiveUser(fullName);
129 }
130
131 const updated = create(UserSchema, { ...user, state: State.DELETED });

Callers

nothing calls this directly

Calls 13

useCurrentUserFunction · 0.90
getAccountTypeByEmailFunction · 0.90
cnFunction · 0.90
hasWorkspacePermissionV2Function · 0.90
getViewPermissionFunction · 0.85
handleViewFunction · 0.85
getAccountTypeLabelFunction · 0.85
getDeletePermissionFunction · 0.85
getUndeletePermissionFunction · 0.85
useAppStoreFunction · 0.70
handleDeactivateFunction · 0.70
handleRestoreFunction · 0.70

Tested by

no test coverage detected