* fix(custom-request-plugin): cannot see custom request action in non-root role when acl doesn't set * fix: list all roles * feat: display all roles * feat: support * fix: remove unused code * fix: options is null * fix: translation * fix: migration error --------- Co-authored-by: chenos <chenlinxh@gmail.com>
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { uid } from '@formily/shared';
|
|
import { BlockInitializer, useSchemaInitializerItem } from '@nocobase/client';
|
|
import React from 'react';
|
|
import { useCustomRequestsResource } from '../hooks/useCustomRequestsResource';
|
|
|
|
export const CustomRequestInitializer: React.FC<any> = (props) => {
|
|
const customRequestsResource = useCustomRequestsResource();
|
|
|
|
const schema = {
|
|
title: '{{ t("Custom request") }}',
|
|
'x-component': 'CustomRequestAction',
|
|
'x-action': 'customize:form:request',
|
|
'x-designer': 'CustomRequestAction.Designer',
|
|
'x-decorator': 'CustomRequestAction.Decorator',
|
|
'x-uid': uid(),
|
|
'x-action-settings': {
|
|
onSuccess: {
|
|
manualClose: false,
|
|
redirecting: false,
|
|
successMessage: '{{t("Request success")}}',
|
|
},
|
|
},
|
|
};
|
|
|
|
const itemConfig = useSchemaInitializerItem();
|
|
return (
|
|
<BlockInitializer
|
|
{...itemConfig}
|
|
item={itemConfig}
|
|
onClick={async (s) => {
|
|
// create a custom request
|
|
await customRequestsResource.create({
|
|
values: {
|
|
key: s['x-uid'],
|
|
},
|
|
});
|
|
}}
|
|
schema={schema}
|
|
/>
|
|
);
|
|
};
|