refactor(data-source-external): rename package name (#1578)
Co-authored-by: sealday <sealday@gmail.com> Reviewed-on: daoyoucloud/tachybase#1578
This commit is contained in:
parent
71caef1b2b
commit
128c26aa10
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "@tachybase/plugin-external-data-source",
|
"name": "@tachybase/plugin-data-source-external",
|
||||||
"version": "0.22.5",
|
"version": "0.22.5",
|
||||||
"main": "dist/server/index.js",
|
"main": "dist/server/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
@ -4,11 +4,11 @@ import { uid } from '@tachybase/schema';
|
|||||||
import lodash from 'lodash';
|
import lodash from 'lodash';
|
||||||
|
|
||||||
import { NAMESPACE, tval } from '../../../locale';
|
import { NAMESPACE, tval } from '../../../locale';
|
||||||
|
import { useSchemaRequestAction } from './getSchemaRequestAction';
|
||||||
import { PreviewComponent } from './PreviewComponent';
|
import { PreviewComponent } from './PreviewComponent';
|
||||||
import { PreviewFields } from './PreviewFields';
|
import { PreviewFields } from './PreviewFields';
|
||||||
import { getSchemaRequestAction } from './getSchemaRequestAction';
|
|
||||||
|
|
||||||
export function getSchemaCollection(title, useAction, item: Record<string, any> = {}) {
|
export function useSchemaCollection(title, useAction, item: Record<string, any> = {}) {
|
||||||
const cloneItem = lodash.cloneDeep(item);
|
const cloneItem = lodash.cloneDeep(item);
|
||||||
|
|
||||||
const data: Record<string, any> = {
|
const data: Record<string, any> = {
|
||||||
@ -20,6 +20,12 @@ export function getSchemaCollection(title, useAction, item: Record<string, any>
|
|||||||
data.reverseField.name = `f_${uid()}`;
|
data.reverseField.name = `f_${uid()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const list = useSchemaRequestAction('list', `{{t("List",{ ns: "${NAMESPACE}" })}}`);
|
||||||
|
const get = useSchemaRequestAction('get', `{{t("Get",{ ns: "${NAMESPACE}" })}}`);
|
||||||
|
const create = useSchemaRequestAction('create', `{{t("Create",{ ns: "${NAMESPACE}" })}}`);
|
||||||
|
const update = useSchemaRequestAction('update', `{{t("Update",{ ns: "${NAMESPACE}" })}}`);
|
||||||
|
const destroy = useSchemaRequestAction('destroy', `{{t("Destroy",{ ns: "${NAMESPACE}" })}}`);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
@ -73,11 +79,11 @@ export function getSchemaCollection(title, useAction, item: Record<string, any>
|
|||||||
defaultActiveKey: [],
|
defaultActiveKey: [],
|
||||||
},
|
},
|
||||||
properties: {
|
properties: {
|
||||||
list: getSchemaRequestAction('list', `{{t("List",{ ns: "${NAMESPACE}" })}}`),
|
list,
|
||||||
get: getSchemaRequestAction('get', `{{t("Get",{ ns: "${NAMESPACE}" })}}`),
|
get,
|
||||||
create: getSchemaRequestAction('create', `{{t("Create",{ ns: "${NAMESPACE}" })}}`),
|
create,
|
||||||
update: getSchemaRequestAction('update', `{{t("Update",{ ns: "${NAMESPACE}" })}}`),
|
update,
|
||||||
destroy: getSchemaRequestAction('destroy', `{{t("Destroy",{ ns: "${NAMESPACE}" })}}`),
|
destroy,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
fields: {
|
fields: {
|
@ -3,13 +3,13 @@ import { FormItem, SchemaComponent, TemplateSummary, useCancelAction } from '@ta
|
|||||||
import { ArrayItems, ArrayTable, FormCollapse, FormLayout } from '@tachybase/components';
|
import { ArrayItems, ArrayTable, FormCollapse, FormLayout } from '@tachybase/components';
|
||||||
|
|
||||||
import { tval } from '../../../locale';
|
import { tval } from '../../../locale';
|
||||||
import { getSchemaCollection } from './CreateCollection.schema';
|
import { useSchemaCollection } from './CreateCollection.schema';
|
||||||
import { useActionCreateCollection } from './useActionCreateCollection';
|
import { useActionCreateCollection } from './useActionCreateCollection';
|
||||||
|
|
||||||
export const ViewCreateCollection = (props) => {
|
export const ViewCreateCollection = (props) => {
|
||||||
const { scope, getContainer, item } = props;
|
const { scope, getContainer, item } = props;
|
||||||
const title = tval('Create collection', true);
|
const title = tval('Create collection', true);
|
||||||
const schema = getSchemaCollection(title, useActionCreateCollection);
|
const schema = useSchemaCollection(title, useActionCreateCollection);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SchemaComponent
|
<SchemaComponent
|
@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useRef } from 'react';
|
||||||
import { css, useRequest } from '@tachybase/client';
|
import { css, useRequest } from '@tachybase/client';
|
||||||
import { onFieldChange, uid, useForm } from '@tachybase/schema';
|
import { onFieldChange, uid, useForm } from '@tachybase/schema';
|
||||||
import { unflatten } from '@tachybase/utils/client';
|
import { unflatten } from '@tachybase/utils/client';
|
||||||
@ -12,8 +12,8 @@ import { RequestTab } from '../request-configs/request-tab/RequestTab';
|
|||||||
import { ResponseTransformerComponent } from '../request-configs/request-transformer/ResponseTransformerComponent';
|
import { ResponseTransformerComponent } from '../request-configs/request-transformer/ResponseTransformerComponent';
|
||||||
import { ProviderRequestActionItems } from './RequestActionItems.provider';
|
import { ProviderRequestActionItems } from './RequestActionItems.provider';
|
||||||
|
|
||||||
export const getSchemaRequestAction = (key, header) => {
|
export const useSchemaRequestAction = (key, header) => {
|
||||||
const ref: any = React.useRef();
|
const ref: any = useRef();
|
||||||
return {
|
return {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
'x-decorator': ProviderRequestActionItems,
|
'x-decorator': ProviderRequestActionItems,
|
@ -16,7 +16,9 @@ export const DeleteCollectionAction = (props) => {
|
|||||||
const { item, isBulk, children, ...restProps } = props;
|
const { item, isBulk, children, ...restProps } = props;
|
||||||
const targetProps = _.omit(restProps, ['scope', 'getContainer', 'useAction']);
|
const targetProps = _.omit(restProps, ['scope', 'getContainer', 'useAction']);
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const { run } = isBulk ? useBulkDestroyActionAndRefreshCM() : useDestroyActionAndRefreshCM();
|
const { run: runBulkDestroy } = useBulkDestroyActionAndRefreshCM();
|
||||||
|
const { run: runDestroy } = useDestroyActionAndRefreshCM();
|
||||||
|
const run = isBulk ? runBulkDestroy : runDestroy;
|
||||||
const onClick = () => {
|
const onClick = () => {
|
||||||
modal.confirm({
|
modal.confirm({
|
||||||
title: t('Delete collection'),
|
title: t('Delete collection'),
|
||||||
@ -28,7 +30,9 @@ export const DeleteCollectionAction = (props) => {
|
|||||||
<RecordProvider record={item}>
|
<RecordProvider record={item}>
|
||||||
<ActionContextProvider value={{ visible, setVisible }}>
|
<ActionContextProvider value={{ visible, setVisible }}>
|
||||||
{isBulk ? (
|
{isBulk ? (
|
||||||
<Button icon={<DeleteOutlined />} onClick={onClick} children={children || t('Delete')} />
|
<Button icon={<DeleteOutlined />} onClick={onClick}>
|
||||||
|
{children || t('Delete')}
|
||||||
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
<a onClick={onClick} {...targetProps}>
|
<a onClick={onClick} {...targetProps}>
|
||||||
{children || t('Delete')}
|
{children || t('Delete')}
|
@ -1,5 +1,13 @@
|
|||||||
import { useCollectionManager_deprecated, useAPIClient, useActionContext, useResourceContext, useRecord, useResourceActionContext } from "@tachybase/client";
|
import {
|
||||||
import { useParams } from "react-router-dom";
|
useActionContext,
|
||||||
|
useAPIClient,
|
||||||
|
useCollectionManager_deprecated,
|
||||||
|
useRecord,
|
||||||
|
useResourceActionContext,
|
||||||
|
useResourceContext,
|
||||||
|
} from '@tachybase/client';
|
||||||
|
|
||||||
|
import { useParams } from 'react-router-dom';
|
||||||
|
|
||||||
export function useDestroyActionAndRefreshCM() {
|
export function useDestroyActionAndRefreshCM() {
|
||||||
const { run: runFunc } = useDestroyAction();
|
const { run: runFunc } = useDestroyAction();
|
@ -2,12 +2,12 @@ import React from 'react';
|
|||||||
import { FormItem, SchemaComponent, TemplateSummary, useCancelAction } from '@tachybase/client';
|
import { FormItem, SchemaComponent, TemplateSummary, useCancelAction } from '@tachybase/client';
|
||||||
import { ArrayItems, ArrayTable, FormCollapse, FormLayout } from '@tachybase/components';
|
import { ArrayItems, ArrayTable, FormCollapse, FormLayout } from '@tachybase/components';
|
||||||
|
|
||||||
import { getSchemaCollection } from '../collection-add/CreateCollection.schema';
|
import { useSchemaCollection } from '../collection-add/CreateCollection.schema';
|
||||||
import { useActionEditCollection } from './useActionEditCollection';
|
import { useActionEditCollection } from './useActionEditCollection';
|
||||||
|
|
||||||
export const ViewEditCollectionForm = (props) => {
|
export const ViewEditCollectionForm = (props) => {
|
||||||
const { scope, getContainer, item } = props;
|
const { scope, getContainer, item } = props;
|
||||||
const schema = getSchemaCollection('{{ t("Edit collection") }}', useActionEditCollection, item);
|
const schema = useSchemaCollection('{{ t("Edit collection") }}', useActionEditCollection, item);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SchemaComponent
|
<SchemaComponent
|
@ -5,17 +5,17 @@ import { unflatten } from '@tachybase/utils/client';
|
|||||||
import lodash from 'lodash';
|
import lodash from 'lodash';
|
||||||
|
|
||||||
import { useTranslation } from '../../../../locale';
|
import { useTranslation } from '../../../../locale';
|
||||||
import { AlertError } from './components/AlertError';
|
|
||||||
import { DebugResponseTabs } from './components/DebugResponseTabs';
|
|
||||||
import { ResponseTab } from './components/ResponseTab';
|
|
||||||
import { ExtractFieldMetadata } from './components/ExtractFieldMetadata';
|
|
||||||
import { useContextRequestInfo } from '../../contexts/RequestForm.context';
|
import { useContextRequestInfo } from '../../contexts/RequestForm.context';
|
||||||
import { getSchemaParam } from './schemas/getSchemaParam';
|
|
||||||
import { MethodPathComponent } from '../method-path/MethodPathComponent';
|
import { MethodPathComponent } from '../method-path/MethodPathComponent';
|
||||||
import { RequestTab } from '../request-tab/RequestTab';
|
import { RequestTab } from '../request-tab/RequestTab';
|
||||||
import { ResponseTransformerComponent } from '../request-transformer/ResponseTransformerComponent';
|
import { ResponseTransformerComponent } from '../request-transformer/ResponseTransformerComponent';
|
||||||
|
import { AlertError } from './components/AlertError';
|
||||||
|
import { DebugResponseTabs } from './components/DebugResponseTabs';
|
||||||
|
import { ExtractFieldMetadata } from './components/ExtractFieldMetadata';
|
||||||
|
import { ResponseTab } from './components/ResponseTab';
|
||||||
|
import { getSchemaParam } from './schemas/getSchemaParam';
|
||||||
|
|
||||||
export const getSchemaDebug = () => {
|
export const useSchemaDebug = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { actionKey, form, requestActionForm } = useContextRequestInfo();
|
const { actionKey, form, requestActionForm } = useContextRequestInfo();
|
||||||
const schemaChild = getSchemaParam(actionKey, form);
|
const schemaChild = getSchemaParam(actionKey, form);
|
@ -6,13 +6,13 @@ import { Card, Col, Row, Select } from 'antd';
|
|||||||
|
|
||||||
import { useTranslation } from '../../../../locale';
|
import { useTranslation } from '../../../../locale';
|
||||||
import { useVariableOptions } from '../../scopes/useVariableOptions';
|
import { useVariableOptions } from '../../scopes/useVariableOptions';
|
||||||
import { getSchemaDebug } from './Debug.schema';
|
import { useSchemaDebug } from './Debug.schema';
|
||||||
import { useCancelAction } from './scopes/useCancelAction';
|
import { useCancelAction } from './scopes/useCancelAction';
|
||||||
import { useDebugAction } from './scopes/useDebugAction';
|
import { useDebugAction } from './scopes/useDebugAction';
|
||||||
|
|
||||||
export const ViewDebug = () => {
|
export const ViewDebug = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const schema = getSchemaDebug();
|
const schema = useSchemaDebug();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SchemaComponent
|
<SchemaComponent
|
@ -7,9 +7,9 @@ import lodash from 'lodash';
|
|||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
|
|
||||||
import { useTranslation } from '../../../../../locale';
|
import { useTranslation } from '../../../../../locale';
|
||||||
import { TooltipContainer } from './TooltipContainer';
|
|
||||||
import { useContextRequestInfo } from '../../../contexts/RequestForm.context';
|
import { useContextRequestInfo } from '../../../contexts/RequestForm.context';
|
||||||
import { useContextResponseInfo } from '../../../contexts/ResponseInfo.context';
|
import { useContextResponseInfo } from '../../../contexts/ResponseInfo.context';
|
||||||
|
import { TooltipContainer } from './TooltipContainer';
|
||||||
|
|
||||||
export const ExtractFieldMetadata = () => {
|
export const ExtractFieldMetadata = () => {
|
||||||
const form = useForm();
|
const form = useForm();
|
@ -8,7 +8,7 @@ export function getSchemaParam(actionKey, form) {
|
|||||||
|
|
||||||
const schemaMap = getSchemaAction(form, actionKey);
|
const schemaMap = getSchemaAction(form, actionKey);
|
||||||
|
|
||||||
for (let param of targetParams) {
|
for (const param of targetParams) {
|
||||||
schemaChild[param] = schemaMap[param];
|
schemaChild[param] = schemaMap[param];
|
||||||
}
|
}
|
||||||
|
|
@ -3,8 +3,8 @@ import { useCollectionRecord, Variable } from '@tachybase/client';
|
|||||||
|
|
||||||
import { useContextRequestInfo } from '../../contexts/RequestForm.context';
|
import { useContextRequestInfo } from '../../contexts/RequestForm.context';
|
||||||
import { useVariableOptions } from '../../scopes/useVariableOptions';
|
import { useVariableOptions } from '../../scopes/useVariableOptions';
|
||||||
import { setFormValue } from '../../utils/setFormValue';
|
|
||||||
import { responseTransformerAe } from '../../utils/responseTransformerAe';
|
import { responseTransformerAe } from '../../utils/responseTransformerAe';
|
||||||
|
import { setFormValue } from '../../utils/setFormValue';
|
||||||
|
|
||||||
export const ResponseTransformerComponent = () => {
|
export const ResponseTransformerComponent = () => {
|
||||||
const { form, actionKey, responseTransformer, setResponseTransformer } = useContextRequestInfo();
|
const { form, actionKey, responseTransformer, setResponseTransformer } = useContextRequestInfo();
|
||||||
@ -24,6 +24,7 @@ export const ResponseTransformerComponent = () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
const options = useVariableOptions(true);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Variable.JSON
|
<Variable.JSON
|
||||||
@ -39,7 +40,7 @@ export const ResponseTransformerComponent = () => {
|
|||||||
value: 'name',
|
value: 'name',
|
||||||
label: 'title',
|
label: 'title',
|
||||||
}}
|
}}
|
||||||
scope={() => useVariableOptions(true)}
|
scope={() => options}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user