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);
|
// handleInputChange('group', localGroupOptions[0].value);
|
||||||
|
|
||||||
if (localGroupOptions.length > 0) {
|
if (localGroupOptions.length > 0) {
|
||||||
// set default group at first
|
// set user group at first
|
||||||
localGroupOptions.unshift({
|
if (userState.user && userState.user.group) {
|
||||||
label: '用户分组',
|
let userGroup = userState.user.group;
|
||||||
value: '',
|
// 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 {
|
} else {
|
||||||
localGroupOptions = [{
|
localGroupOptions = [{
|
||||||
label: '用户分组',
|
label: '用户分组',
|
||||||
|
|||||||
Reference in New Issue
Block a user