From 403ff2480019e0f6dc71629acc109bd02c5aecf5 Mon Sep 17 00:00:00 2001 From: YANG QIA <2013xile@gmail.com> Date: Wed, 9 Apr 2025 12:33:47 +0800 Subject: [PATCH] fix(users): issue with parsing the user profile form schema (#6635) --- .../plugin-users/src/server/actions/users.ts | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-users/src/server/actions/users.ts b/packages/plugins/@nocobase/plugin-users/src/server/actions/users.ts index ae2ab602bc..a002aaa929 100644 --- a/packages/plugins/@nocobase/plugin-users/src/server/actions/users.ts +++ b/packages/plugins/@nocobase/plugin-users/src/server/actions/users.ts @@ -12,16 +12,39 @@ import { UiSchemaRepository } from '@nocobase/plugin-ui-schema-storage'; import _ from 'lodash'; import { namespace } from '..'; import { ValidationError, ValidationErrorItem } from 'sequelize'; -import PluginSystemSettingsServer from '@nocobase/plugin-system-settings'; + +function findNonVoidTypeObjects(obj: any, path = '', results = []): { name: string; props: any }[] { + for (const key in obj) { + const value = obj[key]; + + const currentPath = path ? `${path}.${key}` : key; + + if (value && typeof value === 'object') { + if (value.type && value.type !== 'void') { + results.push({ + name: key, + props: value, + }); + } + + if (value.properties) { + findNonVoidTypeObjects(value.properties, `${currentPath}.properties`, results); + } else { + findNonVoidTypeObjects(value, currentPath, results); + } + } + } + + return results; +} function parseProfileFormSchema(schema: any) { const properties = _.get(schema, 'properties.form.properties.edit.properties.grid.properties') || {}; const fields = []; const requiredFields = []; - Object.values(properties).forEach((row: any) => { - const col = Object.values(row.properties)[0] as any; - const [name, props] = Object.entries(col.properties)[0]; - if (props['x-read-pretty'] || props['x-disable']) { + const configs = findNonVoidTypeObjects(properties); + Object.values(configs).forEach(({ name, props }) => { + if (props['x-read-pretty'] || props['x-disabled']) { return; } if (props['required']) {