mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 06:55:50 +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 { CompatibleSchemaInitializer } from '../../../../application/schema-initializer/CompatibleSchemaInitializer';
|
||||||
import { useCollection } from '../../../../data-source';
|
|
||||||
import { useActionAvailable } from '../../useActionAvailable';
|
import { useActionAvailable } from '../../useActionAvailable';
|
||||||
const commonOptions = {
|
const commonOptions = {
|
||||||
title: "{{t('Configure actions')}}",
|
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 { CompatibleSchemaInitializer } from '../../../../application/schema-initializer/CompatibleSchemaInitializer';
|
||||||
import { useCollection } from '../../../../data-source';
|
|
||||||
import { useActionAvailable } from '../../useActionAvailable';
|
import { useActionAvailable } from '../../useActionAvailable';
|
||||||
|
|
||||||
const commonOptions = {
|
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;
|
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,
|
DEFAULT_DATA_SOURCE_KEY,
|
||||||
useCollection_deprecated,
|
useCollection_deprecated,
|
||||||
useCollectionFilterOptions,
|
useCollectionFilterOptions,
|
||||||
|
useCollectionRecordData,
|
||||||
useCompile,
|
useCompile,
|
||||||
} from '@nocobase/client';
|
} from '@nocobase/client';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
@ -22,13 +23,14 @@ export const useCustomRequestVariableOptions = () => {
|
|||||||
const fieldsOptions = useCollectionFilterOptions(collection);
|
const fieldsOptions = useCollectionFilterOptions(collection);
|
||||||
const userFieldOptions = useCollectionFilterOptions('users', DEFAULT_DATA_SOURCE_KEY);
|
const userFieldOptions = useCollectionFilterOptions('users', DEFAULT_DATA_SOURCE_KEY);
|
||||||
const compile = useCompile();
|
const compile = useCompile();
|
||||||
|
const recordData = useCollectionRecordData();
|
||||||
|
|
||||||
const [fields, userFields] = useMemo(() => {
|
const [fields, userFields] = useMemo(() => {
|
||||||
return [compile(fieldsOptions), compile(userFieldOptions)];
|
return [compile(fieldsOptions), compile(userFieldOptions)];
|
||||||
}, [fieldsOptions, userFieldOptions]);
|
}, [fieldsOptions, userFieldOptions]);
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
return [
|
return [
|
||||||
{
|
recordData && {
|
||||||
name: 'currentRecord',
|
name: 'currentRecord',
|
||||||
title: t('Current record', { ns: 'client' }),
|
title: t('Current record', { ns: 'client' }),
|
||||||
children: [...fields],
|
children: [...fields],
|
||||||
@ -48,6 +50,6 @@ export const useCustomRequestVariableOptions = () => {
|
|||||||
title: 'API token',
|
title: 'API token',
|
||||||
children: null,
|
children: null,
|
||||||
},
|
},
|
||||||
];
|
].filter(Boolean);
|
||||||
}, [fields, userFields]);
|
}, [recordData, t, fields, userFields]);
|
||||||
};
|
};
|
||||||
|
@ -7,20 +7,20 @@
|
|||||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { useFieldSchema } from '@formily/react';
|
||||||
import {
|
import {
|
||||||
AfterSuccess,
|
AfterSuccess,
|
||||||
ButtonEditor,
|
ButtonEditor,
|
||||||
|
RefreshDataBlockRequest,
|
||||||
RemoveButton,
|
RemoveButton,
|
||||||
SchemaSettings,
|
SchemaSettings,
|
||||||
SchemaSettingsLinkageRules,
|
SchemaSettingsLinkageRules,
|
||||||
SecondConFirm,
|
SecondConFirm,
|
||||||
useCollection,
|
useCollection,
|
||||||
useSchemaToolbar,
|
|
||||||
RefreshDataBlockRequest,
|
|
||||||
useCollectionRecord,
|
useCollectionRecord,
|
||||||
|
useSchemaToolbar,
|
||||||
} from '@nocobase/client';
|
} from '@nocobase/client';
|
||||||
import { CustomRequestACL, CustomRequestSettingsItem } from './components/CustomRequestActionDesigner';
|
import { CustomRequestACL, CustomRequestSettingsItem } from './components/CustomRequestActionDesigner';
|
||||||
import { useFieldSchema } from '@formily/react';
|
|
||||||
|
|
||||||
export const customizeCustomRequestActionSettings = new SchemaSettings({
|
export const customizeCustomRequestActionSettings = new SchemaSettings({
|
||||||
name: 'actionSettings:customRequest',
|
name: 'actionSettings:customRequest',
|
||||||
@ -48,7 +48,7 @@ export const customizeCustomRequestActionSettings = new SchemaSettings({
|
|||||||
},
|
},
|
||||||
useVisible() {
|
useVisible() {
|
||||||
const record = useCollectionRecord();
|
const record = useCollectionRecord();
|
||||||
return record && !record?.isNew;
|
return record && record.data && !record?.isNew;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -92,6 +92,14 @@ const commonOptions = {
|
|||||||
},
|
},
|
||||||
useVisible: () => useActionAvailable('create'),
|
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;
|
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.
|
* 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 = {
|
const commonOptions = {
|
||||||
title: "{{t('Configure actions')}}",
|
title: "{{t('Configure actions')}}",
|
||||||
@ -37,6 +37,14 @@ const commonOptions = {
|
|||||||
},
|
},
|
||||||
useVisible: () => useActionAvailable('create'),
|
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',
|
'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