mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 04:39:34 +00:00
feat(custom-request): support adding custom request in more places (#5320)
* feat(custom-request): support adding custom request buttons in more places * fix: fix known issues
This commit is contained in:
parent
ef2811f148
commit
058e7e320d
@ -8,7 +8,6 @@
|
||||
*/
|
||||
|
||||
import { CompatibleSchemaInitializer } from '../../../../application/schema-initializer/CompatibleSchemaInitializer';
|
||||
import { useCollection } from '../../../../data-source';
|
||||
import { useActionAvailable } from '../../useActionAvailable';
|
||||
const commonOptions = {
|
||||
title: "{{t('Configure actions')}}",
|
||||
@ -73,6 +72,14 @@ const commonOptions = {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'customRequest',
|
||||
title: '{{t("Custom request")}}',
|
||||
Component: 'CustomRequestInitializer',
|
||||
schema: {
|
||||
'x-action': 'customize:table:request:global',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
*/
|
||||
|
||||
import { CompatibleSchemaInitializer } from '../../../../application/schema-initializer/CompatibleSchemaInitializer';
|
||||
import { useCollection } from '../../../../data-source';
|
||||
import { useActionAvailable } from '../../useActionAvailable';
|
||||
|
||||
const commonOptions = {
|
||||
@ -74,6 +73,14 @@ const commonOptions = {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'customRequest',
|
||||
title: '{{t("Custom request")}}',
|
||||
Component: 'CustomRequestInitializer',
|
||||
schema: {
|
||||
'x-action': 'customize:table:request:global',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
|
@ -90,6 +90,14 @@ const commonOptions = {
|
||||
return collection.tree && treeTable;
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'customRequest',
|
||||
title: '{{t("Custom request")}}',
|
||||
Component: 'CustomRequestInitializer',
|
||||
schema: {
|
||||
'x-action': 'customize:table:request:global',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
|
@ -11,6 +11,7 @@ import {
|
||||
DEFAULT_DATA_SOURCE_KEY,
|
||||
useCollection_deprecated,
|
||||
useCollectionFilterOptions,
|
||||
useCollectionRecordData,
|
||||
useCompile,
|
||||
} from '@nocobase/client';
|
||||
import { useMemo } from 'react';
|
||||
@ -22,13 +23,14 @@ export const useCustomRequestVariableOptions = () => {
|
||||
const fieldsOptions = useCollectionFilterOptions(collection);
|
||||
const userFieldOptions = useCollectionFilterOptions('users', DEFAULT_DATA_SOURCE_KEY);
|
||||
const compile = useCompile();
|
||||
const recordData = useCollectionRecordData();
|
||||
|
||||
const [fields, userFields] = useMemo(() => {
|
||||
return [compile(fieldsOptions), compile(userFieldOptions)];
|
||||
}, [fieldsOptions, userFieldOptions]);
|
||||
return useMemo(() => {
|
||||
return [
|
||||
{
|
||||
recordData && {
|
||||
name: 'currentRecord',
|
||||
title: t('Current record', { ns: 'client' }),
|
||||
children: [...fields],
|
||||
@ -48,6 +50,6 @@ export const useCustomRequestVariableOptions = () => {
|
||||
title: 'API token',
|
||||
children: null,
|
||||
},
|
||||
];
|
||||
}, [fields, userFields]);
|
||||
].filter(Boolean);
|
||||
}, [recordData, t, fields, userFields]);
|
||||
};
|
||||
|
@ -7,20 +7,20 @@
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import { useFieldSchema } from '@formily/react';
|
||||
import {
|
||||
AfterSuccess,
|
||||
ButtonEditor,
|
||||
RefreshDataBlockRequest,
|
||||
RemoveButton,
|
||||
SchemaSettings,
|
||||
SchemaSettingsLinkageRules,
|
||||
SecondConFirm,
|
||||
useCollection,
|
||||
useSchemaToolbar,
|
||||
RefreshDataBlockRequest,
|
||||
useCollectionRecord,
|
||||
useSchemaToolbar,
|
||||
} from '@nocobase/client';
|
||||
import { CustomRequestACL, CustomRequestSettingsItem } from './components/CustomRequestActionDesigner';
|
||||
import { useFieldSchema } from '@formily/react';
|
||||
|
||||
export const customizeCustomRequestActionSettings = new SchemaSettings({
|
||||
name: 'actionSettings:customRequest',
|
||||
@ -48,7 +48,7 @@ export const customizeCustomRequestActionSettings = new SchemaSettings({
|
||||
},
|
||||
useVisible() {
|
||||
const record = useCollectionRecord();
|
||||
return record && !record?.isNew;
|
||||
return record && record.data && !record?.isNew;
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -92,6 +92,14 @@ const commonOptions = {
|
||||
},
|
||||
useVisible: () => useActionAvailable('create'),
|
||||
},
|
||||
{
|
||||
name: 'customRequest',
|
||||
title: '{{t("Custom request")}}',
|
||||
Component: 'CustomRequestInitializer',
|
||||
schema: {
|
||||
'x-action': 'customize:table:request:global',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
|
@ -75,6 +75,14 @@ const commonOptions = {
|
||||
return collection.tree && treeTable;
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'customRequest',
|
||||
title: '{{t("Custom request")}}',
|
||||
Component: 'CustomRequestInitializer',
|
||||
schema: {
|
||||
'x-action': 'customize:table:request:global',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import { CompatibleSchemaInitializer, useCollection, useActionAvailable } from '@nocobase/client';
|
||||
import { CompatibleSchemaInitializer, useActionAvailable } from '@nocobase/client';
|
||||
|
||||
const commonOptions = {
|
||||
title: "{{t('Configure actions')}}",
|
||||
@ -37,6 +37,14 @@ const commonOptions = {
|
||||
},
|
||||
useVisible: () => useActionAvailable('create'),
|
||||
},
|
||||
{
|
||||
name: 'customRequest',
|
||||
title: '{{t("Custom request")}}',
|
||||
Component: 'CustomRequestInitializer',
|
||||
schema: {
|
||||
'x-action': 'customize:table:request:global',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
|
@ -45,6 +45,14 @@ const commonOptions = {
|
||||
'x-align': 'right',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'customRequest',
|
||||
title: '{{t("Custom request")}}',
|
||||
Component: 'CustomRequestInitializer',
|
||||
schema: {
|
||||
'x-action': 'customize:table:request:global',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user