mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-02 03:02:19 +08:00
* fix: sort field with table dose not have primary key * feat: fixed params merger * chore(plugins/acl): fixed params * chore(plugins/acl): allowConfigure of collections * chore(plugins/china-region): disable actions other than list * chore(plugins/collection-manager): allowConfigure permission * chore(plugins/file-manager): acl fixed params * chore: acl fixed params * chore: rolesResourcesScopes onDelete cascade * fix: install error * chore: test * fix: root user fixed params * fix: role resource scope onDelete * chore: test * chore: test * fix: acl * chore: disable index.html cache * chore: disable index.html cache * test: destory user role * test: destory throught table * fix: test * fix: test * chore: add rolesUsers to fixed params * feat: permission logging * feat: permission logging * fix: test * fix: test * chore: disable grant target action * fix: appends with fields * fix: get action params * fix: associationActions * chore: change AssociationField using relation type * chore: typo * refactor: allow to skip * fix: prettier * chore: attachments association action * fix: allowConfigure condition * fix: deprecated allow * fix: please use skip instead * feat: table column aclcheck * chore: test * feat: throw error when detory no permission record * chore: test * chore: acl test * feat: field acl * chore: after action middleware * fix: destory permission check * chore: middleware use * fix: test * feat: filter match * feat: subform/subtable field acl check * feat: action permision by scope * feat: action permision by scope * feat: list action with allowedActions * chore: all allowed action * fix: pk error * fix: merge error * fix: create query sql * fix: skip permission * fix: scope with association field * feat: action acl fix * feat: action acl fix * fix: update submodule * Feat: setting center permission (#1214) * feat: add setting center permissions * feat: setting center permissions backlist * feat: setting center permissions BLACKLIST * feat: setting center permissions blacklist * feat: setting center permissions blacklist * feat: setting center permission * feat: configure plugin tab expand Co-authored-by: chenos <chenlinxh@gmail.com> * Feat :field acl (#1211) Co-authored-by: chenos <chenlinxh@gmail.com> * fix: build error * test: acl snippet * feat: set field * fix: test * fix: build error * fix: utils Dependency cycles * feat: general permissions * feat: delete pluginTabBlacklist * fix: test * feat: snippetManager allow method * feat: acl role snippetAllowed method * feat: array field repository * feat: ArrayFieldRepository * fix: test * fix: ci * fix: ci error * fix: add set parse * test: array field repository * chore: addSnippetPatten * fix: start * feat: sync role snippets * feat: snippets check * feat: snippets check * chore: acl role snippet api * fix: test * fix: test * refactor: acl role snippets * chore: registerACLSettingSnippet * chore: default snippets * feat: snippets match * feat: snippets check * feat: snippets check * feat: pm permision check * feat: pm permision check * feat: snippet pattern match * feat: pluginManagerToolbar check * feat: pluginManagerToolbar check * chore: snippets default value * feat: set role snippets migration * chore: snippets * feat: acl local * feat: acl local * feat: bookmask fix * feat: plugin-manger & ui-editor snippet * feat: set allowConfigure to false when upgrade to snippets * feat: destory action acl fix * feat: destory action acl fix * fix: association resource params merge * fix: ui editor snippet * feat: action acl fix * chore: move list meta middleware into plugins/acl * fix: test * feat: action acl fix * feat: action acl check fix * feat: plugins toolbar fix * feat: gitmodules * fix: subproject * chore: add avaiableActions to snippet * chore: change plugin-manager snippet * feat: configure action acl fix * feat: plugin tab acl check fix * chore: roles snippets * fix: add actions to snippet * feat: allowconfigure fix * fix: count with filterBy * fix: build error * feat: get action with allowedActions * feat: acl route check fix * feat: aclActionProvider fix * feat: actionscpe fix * feat: actionname alias * feat: setting center fix * feat: acl provider fix * fix: role collection * feat: associate resource acl * feat: associate resource acl * feat: redirect to 403 * feat: route redirct * feat: acl scope check by record * fix: fields appends fix * fix: fields appends fix * fix: fields appends fix * fix: allowedActions fix * fix: menu items * fix: rename * fix: improve code * fix: improve code * fix: improve code * fix: ctx?.data?.data * fix: styling * fix: allowAll after ignore scope * chore: allowConfigure condition * fix: collections.fields:* * fix: acl test * fix: update submodule * fix: acl test * fix: acl snippet * fix: updates * fix: only load history for logged-in users * fix: this.app.acl.registerSnippet * fix: downloadXlsxTemplate * fix: 404 * feat: allowedAction in association list response * fix: listData get * fix: test * fix: x-collection-field * fix: update record error * fix: calendar template * test: allow manager * fix: fetch action step * fix: update submodule * fix: refresh * fix: refresh * fix: rolesResourcesScopes * test: snippets * fix: snippets * fix: test * fix: omit filter.createdById * fix: improve code * fix: collections path * fix: test error * fix: upgrade error * fix: errors * fix: read allowed actions error * fix: kanban error * fix: error Co-authored-by: chenos <chenlinxh@gmail.com> Co-authored-by: katherinehhh <katherine_15995@163.com>
188 lines
6.0 KiB
TypeScript
188 lines
6.0 KiB
TypeScript
import { css } from '@emotion/css';
|
|
import type { ISchema } from '@formily/react';
|
|
import { Schema, useFieldSchema } from '@formily/react';
|
|
import { merge } from '@formily/shared';
|
|
import { SchemaInitializer, useCollection, useDesignable } from '@nocobase/client';
|
|
import React from 'react';
|
|
import { NAMESPACE } from './constants';
|
|
import { useFields } from './useFields';
|
|
|
|
const findSchema = (schema: Schema, key: string, action: string) => {
|
|
return schema.reduceProperties((buf, s) => {
|
|
if (s[key] === action) {
|
|
return s;
|
|
}
|
|
const c = findSchema(s, key, action);
|
|
if (c) {
|
|
return c;
|
|
}
|
|
return buf;
|
|
});
|
|
};
|
|
const removeSchema = (schema, cb) => {
|
|
return cb(schema);
|
|
};
|
|
export const useCurrentSchema = (action: string, key: string, find = findSchema, rm = removeSchema) => {
|
|
const fieldSchema = useFieldSchema();
|
|
const { remove } = useDesignable();
|
|
const schema = find(fieldSchema, key, action);
|
|
return {
|
|
schema,
|
|
exists: !!schema,
|
|
remove() {
|
|
schema && rm(schema, remove);
|
|
},
|
|
};
|
|
};
|
|
|
|
const initImportSettings = (fields) => {
|
|
const importColumns = fields?.filter((f) => !f.children).map((f) => ({ dataIndex: [f.name] }));
|
|
return { importColumns, explain: '' };
|
|
};
|
|
|
|
export const ImportActionInitializer = (props) => {
|
|
const { item, insert } = props;
|
|
const { exists, remove } = useCurrentSchema('importXlsx', 'x-action', item.find, item.remove);
|
|
const { name } = useCollection();
|
|
const fields = useFields(name);
|
|
|
|
const schema: ISchema = {
|
|
type: 'void',
|
|
title: '{{ t("Import") }}',
|
|
'x-action': 'importXlsx',
|
|
'x-action-settings': {
|
|
importSettings: { importColumns: [], explain: '' },
|
|
},
|
|
'x-designer': 'ImportDesigner',
|
|
'x-component': 'Action',
|
|
'x-component-props': {
|
|
icon: 'CloudUploadOutlined',
|
|
openMode: 'modal',
|
|
},
|
|
properties: {
|
|
modal: {
|
|
type: 'void',
|
|
title: `{{ t("Import Data", {ns: "${NAMESPACE}" }) }}`,
|
|
'x-component': 'Action.Container',
|
|
'x-decorator': 'Form',
|
|
'x-component-props': {
|
|
width: '50%',
|
|
className: css`
|
|
.ant-formily-item-label {
|
|
height: 30px;
|
|
}
|
|
`,
|
|
},
|
|
properties: {
|
|
formLayout: {
|
|
type: 'void',
|
|
'x-component': 'FormLayout',
|
|
properties: {
|
|
download: {
|
|
type: 'void',
|
|
title: `{{ t("Step 1: Download template", {ns: "${NAMESPACE}" }) }}`,
|
|
'x-component': 'FormItem',
|
|
properties: {
|
|
tip: {
|
|
type: 'void',
|
|
'x-component': 'Markdown.Void',
|
|
'x-editable': false,
|
|
'x-component-props': {
|
|
className: css`
|
|
padding: 8px 15px;
|
|
background-color: #e6f7ff;
|
|
border: 1px solid #91d5ff;
|
|
margin-bottom: 10px;
|
|
li {
|
|
line-height: 26px;
|
|
}
|
|
`,
|
|
content: `{{ t("Download tip", {ns: "${NAMESPACE}" }) }}`,
|
|
},
|
|
},
|
|
downloadAction: {
|
|
type: 'void',
|
|
title: `{{ t("Download template", {ns: "${NAMESPACE}" }) }}`,
|
|
'x-component': 'Action',
|
|
'x-component-props': {
|
|
className: css`
|
|
margin-top: 5px;
|
|
`,
|
|
useAction: '{{ useDownloadXlsxTemplateAction }}',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
upload: {
|
|
type: 'array',
|
|
title: `{{ t("Step 2: Upload Excel", {ns: "${NAMESPACE}" }) }}`,
|
|
'x-decorator': 'FormItem',
|
|
'x-component': 'Upload.Dragger',
|
|
'x-validator': '{{ uploadValidator }}',
|
|
'x-component-props': {
|
|
action: '',
|
|
height: '150px',
|
|
tipContent: `{{ t("Upload placeholder", {ns: "${NAMESPACE}" }) }}`,
|
|
beforeUpload: '{{ beforeUploadHandler }}',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
footer: {
|
|
'x-component': 'Action.Container.Footer',
|
|
'x-component-props': {},
|
|
properties: {
|
|
actions: {
|
|
type: 'void',
|
|
'x-component': 'ActionBar',
|
|
'x-component-props': {},
|
|
properties: {
|
|
cancel: {
|
|
type: 'void',
|
|
title: '{{ t("Cancel") }}',
|
|
'x-component': 'Action',
|
|
'x-component-props': {
|
|
useAction: '{{ cm.useCancelAction }}',
|
|
},
|
|
},
|
|
startImport: {
|
|
type: 'void',
|
|
title: `{{ t("Start import", {ns: "${NAMESPACE}" }) }}`,
|
|
'x-component': 'Action',
|
|
'x-component-props': {
|
|
type: 'primary',
|
|
htmlType: 'submit',
|
|
useAction: '{{ useImportStartAction }}',
|
|
},
|
|
'x-reactions': {
|
|
dependencies: ['upload'],
|
|
fulfill: {
|
|
run: 'validateUpload($form, $self, $deps)',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
return (
|
|
<SchemaInitializer.SwitchItem
|
|
checked={exists}
|
|
title={item.title}
|
|
onClick={() => {
|
|
if (exists) {
|
|
return remove();
|
|
}
|
|
schema['x-action-settings']['importSettings'] = initImportSettings(fields);
|
|
const s = merge(schema || {}, item.schema || {});
|
|
item?.schemaInitialize?.(s);
|
|
insert(s);
|
|
}}
|
|
/>
|
|
);
|
|
};
|