feat: Update user group handling in Playground component
- Enhanced the Playground component to prioritize the user's group by moving it to the front of the local group options if it exists. - Improved user experience by ensuring the default group selection reflects the user's current group, if available.
This commit is contained in:
@@ -103,11 +103,16 @@ const Playground = () => {
|
||||
// handleInputChange('group', localGroupOptions[0].value);
|
||||
|
||||
if (localGroupOptions.length > 0) {
|
||||
// set default group at first
|
||||
localGroupOptions.unshift({
|
||||
label: '用户分组',
|
||||
value: '',
|
||||
});
|
||||
// set user group at first
|
||||
if (userState.user && userState.user.group) {
|
||||
let userGroup = userState.user.group;
|
||||
// Find and move user's group to the front
|
||||
const userGroupIndex = localGroupOptions.findIndex(g => g.value === userGroup);
|
||||
if (userGroupIndex > -1) {
|
||||
const userGroupOption = localGroupOptions.splice(userGroupIndex, 1)[0];
|
||||
localGroupOptions.unshift(userGroupOption);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
localGroupOptions = [{
|
||||
label: '用户分组',
|
||||
|
||||
Reference in New Issue
Block a user