fix(users): issue with parsing the user profile form schema (#6635)

This commit is contained in:
YANG QIA 2025-04-09 12:33:47 +08:00 committed by GitHub
parent 773ee94db4
commit 403ff24800
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,16 +12,39 @@ import { UiSchemaRepository } from '@nocobase/plugin-ui-schema-storage';
import _ from 'lodash'; import _ from 'lodash';
import { namespace } from '..'; import { namespace } from '..';
import { ValidationError, ValidationErrorItem } from 'sequelize'; 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) { function parseProfileFormSchema(schema: any) {
const properties = _.get(schema, 'properties.form.properties.edit.properties.grid.properties') || {}; const properties = _.get(schema, 'properties.form.properties.edit.properties.grid.properties') || {};
const fields = []; const fields = [];
const requiredFields = []; const requiredFields = [];
Object.values(properties).forEach((row: any) => { const configs = findNonVoidTypeObjects(properties);
const col = Object.values(row.properties)[0] as any; Object.values(configs).forEach(({ name, props }) => {
const [name, props] = Object.entries(col.properties)[0]; if (props['x-read-pretty'] || props['x-disabled']) {
if (props['x-read-pretty'] || props['x-disable']) {
return; return;
} }
if (props['required']) { if (props['required']) {