fix(acl): add roles.users field

This commit is contained in:
chenos 2023-06-30 12:02:08 +08:00
parent 6cfd586175
commit 7e0ac57057
2 changed files with 16 additions and 3 deletions

View File

@ -10,7 +10,8 @@ import { useBlockRequestContext } from '../../../block-provider/BlockProvider';
import { mergeFilter } from '../../../block-provider/SharedFilterProvider'; import { mergeFilter } from '../../../block-provider/SharedFilterProvider';
import { useCollection, useCollectionManager } from '../../../collection-manager'; import { useCollection, useCollectionManager } from '../../../collection-manager';
import { getInnermostKeyAndValue } from '../../common/utils/uitls'; import { getInnermostKeyAndValue } from '../../common/utils/uitls';
import { defaultFieldNames, Select } from '../select'; import { useCompile } from '../../hooks';
import { Select, defaultFieldNames } from '../select';
import { ReadPretty } from './ReadPretty'; import { ReadPretty } from './ReadPretty';
import { extractFilterfield, extractValuesByPattern, generatePattern, parseVariables } from './utils'; import { extractFilterfield, extractValuesByPattern, generatePattern, parseVariables } from './utils';
const EMPTY = 'N/A'; const EMPTY = 'N/A';
@ -64,13 +65,14 @@ const InternalRemoteSelect = connect(
} }
return '$includes'; return '$includes';
}, [targetField]); }, [targetField]);
const compile = useCompile();
const mapOptionsToTags = useCallback( const mapOptionsToTags = useCallback(
(options) => { (options) => {
try { try {
return options return options
.map((option) => { .map((option) => {
let label = option[fieldNames.label]; let label = compile(option[fieldNames.label]);
if (targetField?.uiSchema?.enum) { if (targetField?.uiSchema?.enum) {
if (Array.isArray(label)) { if (Array.isArray(label)) {

View File

@ -84,6 +84,17 @@ export default {
type: 'set', type: 'set',
name: 'snippets', name: 'snippets',
defaultValue: ['!ui.*', '!pm', '!pm.*'], defaultValue: ['!ui.*', '!pm', '!pm.*'],
} },
{
type: 'belongsToMany',
name: 'users',
target: 'users',
foreignKey: 'roleName',
otherKey: 'userId',
onDelete: 'CASCADE',
sourceKey: 'name',
targetKey: 'id',
through: 'rolesUsers',
},
], ],
} as CollectionOptions; } as CollectionOptions;