fix: default action schema settings (#3146)

* fix: default action schema settings

* fix: customRequest
This commit is contained in:
chenos 2023-12-06 12:48:21 +08:00 committed by GitHub
parent ad25fe704c
commit e418d31eb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 23 deletions

View File

@ -1,7 +1,14 @@
import i18next from 'i18next';
import i18next, { TFuncKey, TOptions } from 'i18next';
import { initReactI18next } from 'react-i18next';
import locale from '../locale';
export function tval(text: TFuncKey | TFuncKey[], options?: TOptions) {
if (options) {
return `{{t(${JSON.stringify(text)}, ${JSON.stringify(options)})}}`;
}
return `{{t(${JSON.stringify(text)})}}`;
}
export const i18n = i18next.createInstance();
const resources = {};

View File

@ -1,4 +1,4 @@
import { ConfigProvider } from 'antd';
import { App, ConfigProvider } from 'antd';
import dayjs from 'dayjs';
import { loadConstrueLocale } from '../../antd-config-provider/loadConstrueLocale';
import { Plugin } from '../../application/Plugin';
@ -19,6 +19,7 @@ export class LocalePlugin extends Plugin {
const data = res?.data;
this.locales = data?.data || {};
this.app.use(ConfigProvider, { locale: this.locales.antd, popupMatchSelectWidth: false });
this.app.use(App);
if (data?.data?.lang && !locale) {
api.auth.setLocale(data?.data?.lang);
this.app.i18n.changeLanguage(data?.data?.lang);

View File

@ -7,9 +7,10 @@ import { cloneDeep } from 'lodash';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { RemoteSelect, useCompile, useDesignable } from '../..';
import { useApp } from '../../../application';
import { usePlugin } from '../../../application/hooks';
import { SchemaSettingOptions, SchemaSettings } from '../../../application/schema-settings';
import { useSchemaToolbar } from '../../../application/schema-toolbar';
import { SchemaSettings, SchemaSettingOptions } from '../../../application/schema-settings';
import { CollectionOptions, useCollection, useCollectionManager } from '../../../collection-manager';
import { FlagProvider } from '../../../flag-provider';
import { useRecord } from '../../../record-provider';
@ -30,7 +31,6 @@ import {
import { DefaultValueProvider } from '../../../schema-settings/hooks/useIsAllowToSetDefaultValue';
import { useLinkageAction } from './hooks';
import { requestSettingsSchema } from './utils';
import { useApp } from '../../../application';
const Tree = connect(
AntdTree,
@ -1089,7 +1089,7 @@ export const ActionDesigner = (props) => {
const fieldSchema = useFieldSchema();
const isDraggable = fieldSchema?.parent['x-component'] !== 'CollectionField';
const settingsName = `ActionSettings:${fieldSchema['x-action']}`;
const defaultActionSettings = 'ActionSettings';
const defaultActionSettings = schemaSettings || 'ActionSettings';
const hasAction = app.schemaSettingsManager.has(settingsName);
return (

View File

@ -222,7 +222,7 @@ export const gridCardItemActionInitializers = new SchemaInitializer({
},
},
{
name: 'custom-request',
name: 'customRequest',
title: '{{t("Custom request")}}',
Component: 'CustomRequestInitializer',
schema: {

View File

@ -275,26 +275,11 @@ export const tableActionColumnInitializers = new SchemaInitializer({
},
},
{
type: 'item',
title: '{{t("Custom request")}}',
name: 'customRequest',
Component: 'CustomizeActionInitializer',
title: '{{t("Custom request")}}',
Component: 'CustomRequestInitializer',
schema: {
title: '{{ t("Custom request") }}',
'x-component': 'Action.Link',
'x-action': 'customize:table:request',
'x-designer': 'Action.Designer',
'x-action-settings': {
requestSettings: {},
onSuccess: {
manualClose: false,
redirecting: false,
successMessage: '{{t("Request success")}}',
},
},
'x-component-props': {
useProps: '{{ useCustomizeRequestActionProps }}',
},
},
useVisible() {
const collection = useCollection();