fix: Resource authorization: "Select All" is ineffective#4274
fix: Resource authorization: "Select All" is ineffective#4274shaohuzhang1 merged 1 commit intov2from
Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| } | ||
| const select = (val: any[], active: any) => { | ||
| if (active.resource_type === 'folder') { | ||
| if (!val.some((item) => item.id == active.id)) { |
There was a problem hiding this comment.
The code looks mostly correct, but there are a few minor improvements and suggestions:
-
Suggested Changes:
- Replace the
@select-allevent with a more conventional name likeonSelectAll. ThisChangeEvent makes it clear what this method does.
- Replace the
-
Optimization Suggestions:
- Use
nextTick()before modifying data in lifecycle hooks that depend on DOM rendering to ensure all changes have been applied. In yourselectAllmethod, you can addawait nextTick()after settingmultipleSelection.
- Use
Here's how the updated code could look:
<template>
<div>
<!-- Component template remains unchanged -->
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, computed, nextTick } from 'vue' // Use import statement instead of require
import { useRoute } from 'vue-router'
import type { Provider } from '@/api/type/model'
import { SourceTypeEnum } from '@/enums/common'
// Existing code logic remains intact
const filteredData = computed(() => {
return data.filter(item => !showTrash || item.is_trash !== true);
});
const multipleSelection = ref<any[]>([]);
const selectObj: any = {};
// Update onSelectAll event handler
const onSelectAll = (selection: any[]) => {
await nextTick(); // Ensure DOM updates
multipleSelection.value = selection;
};
// Updated select function
const select = (val: any[], active: any) => {
if (active.resource_type === 'folder') {
if (!val.some((item) => item.id == active.id)) {
val.push(active);
}
} else {
if (!val.includes(active.row)) { // Corrected comparison logic
val.push(Object.assign({}, active));
}
// ... Rest of the update ...These changes should make the code cleaner and potentially enhance performance depending on the complexity of your application.
What this PR does / why we need it?
Summary of your change
Please indicate you've done the following: