fix: resolve the issue of users being able to delete themselves. (#4355)

#### What type of PR is this?

/kind bug
/area console

#### What this PR does / why we need it:

在用户列表中,禁止用户选中自己,以解决用户能够进行视觉上自我删除的 bug。

<img width="1636" alt="image" src="https://github.com/halo-dev/halo/assets/31335418/d95f7cf5-cfea-49fa-8f68-d13c46bc88c1">

#### Which issue(s) this PR fixes:

Fixes #4350 

#### Special notes for your reviewer:

#### Does this PR introduce a user-facing change?

```release-note
在用户列表中禁用选中当前用户
```
pull/4371/head
Takagi 2023-08-03 15:23:32 +08:00 committed by GitHub
parent 8773f94a8d
commit 2ee51b0c56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 4 deletions

View File

@ -172,7 +172,11 @@ const handleDeleteInBatch = async () => {
};
watch(selectedUserNames, (newValue) => {
checkedAll.value = newValue.length === users.value?.length;
checkedAll.value =
newValue.length ===
users.value?.filter(
(user) => user.user.metadata.name !== userStore.currentUser?.metadata.name
).length;
});
const checkSelection = (user: User) => {
@ -187,9 +191,15 @@ const handleCheckAllChange = (e: Event) => {
if (checked) {
selectedUserNames.value =
users.value?.map((user) => {
return user.user.metadata.name;
}) || [];
users.value
?.filter((user) => {
return (
user.user.metadata.name !== userStore.currentUser?.metadata.name
);
})
.map((user) => {
return user.user.metadata.name;
}) || [];
} else {
selectedUserNames.value.length = 0;
}
@ -407,6 +417,10 @@ onMounted(() => {
class="h-4 w-4 rounded border-gray-300 text-indigo-600"
name="post-checkbox"
type="checkbox"
:disabled="
user.user.metadata.name ===
userStore.currentUser?.metadata.name
"
/>
</template>
<template #start>