fix(workflow): workflow node variables do not display inherited collection fields (#5415)
Some checks failed
Auto merge main -> next / push-commit (push) Waiting to run
Build docker image / build-and-push (push) Waiting to run
Build pro image / build-and-push (push) Waiting to run
Deploy client docs / Build (push) Waiting to run
E2E / Build (push) Waiting to run
E2E / Core and plugins (push) Blocked by required conditions
E2E / plugin-workflow (push) Blocked by required conditions
E2E / plugin-workflow-approval (push) Blocked by required conditions
E2E / plugin-data-source-main (push) Blocked by required conditions
E2E / Comment on PR (push) Blocked by required conditions
NocoBase frontEnd test / frontend-test (18) (push) Waiting to run
NocoBase backend test / sqlite-test (20, false) (push) Has been cancelled
NocoBase backend test / sqlite-test (20, true) (push) Has been cancelled
NocoBase backend test / postgres-test (public, 20, nocobase, false) (push) Has been cancelled
NocoBase backend test / postgres-test (public, 20, nocobase, true) (push) Has been cancelled
NocoBase backend test / postgres-test (public, 20, public, false) (push) Has been cancelled
NocoBase backend test / postgres-test (public, 20, public, true) (push) Has been cancelled
NocoBase backend test / postgres-test (user_schema, 20, nocobase, false) (push) Has been cancelled
NocoBase backend test / postgres-test (user_schema, 20, nocobase, true) (push) Has been cancelled
NocoBase backend test / postgres-test (user_schema, 20, public, false) (push) Has been cancelled
NocoBase backend test / postgres-test (user_schema, 20, public, true) (push) Has been cancelled
NocoBase backend test / mysql-test (20, false) (push) Has been cancelled
NocoBase backend test / mysql-test (20, true) (push) Has been cancelled
NocoBase backend test / mariadb-test (20, false) (push) Has been cancelled
NocoBase backend test / mariadb-test (20, true) (push) Has been cancelled
Test on Windows / build (push) Has been cancelled

* fix: missing fields in the inherited table

* fix(client): fix hidden collection

* refactor(client): add new api to get all fields on collection manager

---------

Co-authored-by: mytharcher <mytharcher@gmail.com>
This commit is contained in:
chenos 2024-10-15 09:23:24 +08:00 committed by GitHub
parent 3b04f01025
commit d705877eec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 9 deletions

View File

@ -250,6 +250,10 @@ export class Collection {
return predicate ? filter(this.fields, predicate) : this.fields; return predicate ? filter(this.fields, predicate) : this.fields;
} }
getAllFields(predicate?: GetCollectionFieldPredicate) {
return this.getFields(predicate);
}
protected getFieldsMap() { protected getFieldsMap() {
if (!this.fieldsMap) { if (!this.fieldsMap) {
this.fieldsMap = this.getFields().reduce((memo, field) => { this.fieldsMap = this.getFields().reduce((memo, field) => {

View File

@ -140,6 +140,10 @@ export class CollectionManager {
return this.getCollection(collectionName)?.getFields(predicate) || []; return this.getCollection(collectionName)?.getFields(predicate) || [];
} }
getCollectionAllFields(collectionName: string, predicate?: GetCollectionFieldPredicate) {
return this.getCollection(collectionName)?.getAllFields(predicate) || [];
}
/** /**
* @example * @example
* getFilterByTK('users', { id: 1 }); // 1 * getFilterByTK('users', { id: 1 }); // 1

View File

@ -12,13 +12,7 @@ import { Tag, TreeSelect } from 'antd';
import type { DefaultOptionType, TreeSelectProps } from 'rc-tree-select/es/TreeSelect'; import type { DefaultOptionType, TreeSelectProps } from 'rc-tree-select/es/TreeSelect';
import React, { useCallback, useEffect, useMemo, useState } from 'react'; import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { import { CollectionFieldOptions_deprecated, parseCollectionName, useApp, useCompile } from '../../..';
CollectionFieldOptions_deprecated,
parseCollectionName,
useApp,
useCollectionManager_deprecated,
useCompile,
} from '../../..';
export type AppendsTreeSelectProps = { export type AppendsTreeSelectProps = {
value: string[] | string; value: string[] | string;
@ -106,7 +100,11 @@ export const AppendsTreeSelect: React.FC<TreeSelectProps & AppendsTreeSelectProp
const [dataSourceName, collectionName] = parseCollectionName(collectionString); const [dataSourceName, collectionName] = parseCollectionName(collectionString);
const app = useApp(); const app = useApp();
const { collectionManager } = app.dataSourceManager.getDataSource(dataSourceName); const { collectionManager } = app.dataSourceManager.getDataSource(dataSourceName);
const getCollectionFields = collectionManager.getCollectionFields.bind(collectionManager); const getCollectionFields = (name, predicate) => {
const instance = collectionManager.getCollection(name);
// NOTE: condition for compatibility with hidden collections like "attachments"
return instance ? instance.getAllFields(predicate) : [];
};
const treeData = Object.values(optionsMap); const treeData = Object.values(optionsMap);
const value: string | DefaultOptionType[] = useMemo(() => { const value: string | DefaultOptionType[] = useMemo(() => {
if (props.multiple) { if (props.multiple) {

View File

@ -503,7 +503,7 @@ export function useGetCollectionFields(dataSourceName?) {
const app = useApp(); const app = useApp();
const { collectionManager } = app.dataSourceManager.getDataSource(dataSourceName); const { collectionManager } = app.dataSourceManager.getDataSource(dataSourceName);
return useCallback((collectionName) => collectionManager.getCollectionFields(collectionName), [collectionManager]); return useCallback((collectionName) => collectionManager.getCollectionAllFields(collectionName), [collectionManager]);
} }
export function WorkflowVariableInput({ variableOptions, ...props }): JSX.Element { export function WorkflowVariableInput({ variableOptions, ...props }): JSX.Element {