mirror of https://github.com/halo-dev/halo
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
parent
8773f94a8d
commit
2ee51b0c56
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue