(user: User)
| 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 }); |
| 132 | onUserUpdated(updated); |
| 133 | |
| 134 | pushNotification({ |
| 135 | module: "bytebase", |
| 136 | style: "SUCCESS", |
| 137 | title: t("common.updated"), |
| 138 | }); |
| 139 | } catch { |
| 140 | // error already shown by store |
| 141 | } |
| 142 | }; |
| 143 | |
| 144 | const handleRestore = async (user: User) => { |
| 145 | const accountType = getAccountTypeByEmail(user.email); |
no test coverage detected