fix: improve local storage options (#2943)

* fix: improve local storage options

* test: revision of test cases for file manager

* test: revision of test cases for file manager

---------

Co-authored-by: hongboji <j414562100@qq.com>
This commit is contained in:
chenos 2023-11-01 22:23:19 +08:00 committed by GitHub
parent 6449e2fdb8
commit c6fe9366ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 28 additions and 15 deletions

View File

@ -168,7 +168,7 @@ export const FileStoragePane = () => {
<Card bordered={false}> <Card bordered={false}>
<SchemaComponent <SchemaComponent
components={{ StorageOptions, CreateStorage, EditStorage }} components={{ StorageOptions, CreateStorage, EditStorage }}
scope={{ storageTypes, xStyleProcessDesc }} scope={{ useNewId: (prefix) => `${prefix}${uid()}`, storageTypes, xStyleProcessDesc }}
schema={storageSchema} schema={storageSchema}
/> />
</Card> </Card>

View File

@ -18,10 +18,10 @@ test.describe('file manager', () => {
await page.getByRole('menuitem', { name: 'Local storage' }).click(); await page.getByRole('menuitem', { name: 'Local storage' }).click();
const createLocalStorage = new CreateLocalStorage(page); const createLocalStorage = new CreateLocalStorage(page);
await createLocalStorage.title.fill(caseTitle); await createLocalStorage.title.fill(caseTitle);
const storageName = caseNum + dayjs().format('YYYYMMDDHHmmss.SSS').toString(); const storageName = caseNum + dayjs().format('YYYYMMDDHHmmssSSS').toString();
await createLocalStorage.storageName.fill(storageName); await createLocalStorage.storageName.fill(storageName);
await createLocalStorage.storagebaseURL.fill('/storage/uploadsFM01AA'); // await createLocalStorage.storagebaseURL.fill('/storage/uploadsFM01AA');
await createLocalStorage.destination.fill('storage/uploadsFM01AA'); // await createLocalStorage.destination.fill('storage/uploadsFM01AA');
// await createLocalStorage.path.fill(''); // await createLocalStorage.path.fill('');
// await createLocalStorage.defaultStorage.check(); // await createLocalStorage.defaultStorage.check();
// await createLocalStorage.deleteRecordRetentionFile.check(); // await createLocalStorage.deleteRecordRetentionFile.check();

View File

@ -17,11 +17,11 @@ test.describe('File manager', () => {
const createLocalStorage = new CreateLocalStorage(page); const createLocalStorage = new CreateLocalStorage(page);
await createLocalStorage.title.fill(caseTitle); await createLocalStorage.title.fill(caseTitle);
const storageName = caseNum + dayjs().format('YYYYMMDDHHmmss.SSS').toString(); const storageName = caseNum + dayjs().format('YYYYMMDDHHmmssSSS').toString();
await createLocalStorage.storageName.fill(storageName); await createLocalStorage.storageName.fill(storageName);
await createLocalStorage.storagebaseURL.fill('/storage/uploadsFM02AA'); // await createLocalStorage.storagebaseURL.fill('/storage/uploadsFM02AA');
await createLocalStorage.destination.fill('storage/uploadsFM02AA'); // await createLocalStorage.destination.fill('storage/uploadsFM02AA');
// await createLocalStorage.path.fill(''); // // await createLocalStorage.path.fill('');
// await createLocalStorage.defaultStorage.check(); // await createLocalStorage.defaultStorage.check();
// await createLocalStorage.deleteRecordRetentionFile.check(); // await createLocalStorage.deleteRecordRetentionFile.check();
await page.getByLabel('action-Action-Submit-storages').click(); await page.getByLabel('action-Action-Submit-storages').click();
@ -30,7 +30,7 @@ test.describe('File manager', () => {
// 2、测试步骤点击“文件管理器”-“编辑”按钮,编辑标题,点击“确定”按钮 // 2、测试步骤点击“文件管理器”-“编辑”按钮,编辑标题,点击“确定”按钮
await page.getByText('Edit').nth(2).click(); await page.getByText('Edit').nth(2).click();
const editLocalStorage = new EditLocalStorage(page); const editLocalStorage = new EditLocalStorage(page);
caseTitle = caseTitle + dayjs().format('YYYYMMDDHHmmss.SSS').toString(); caseTitle = caseTitle + dayjs().format('YYYYMMDDHHmmssSSS').toString();
await editLocalStorage.title.fill(caseTitle); await editLocalStorage.title.fill(caseTitle);
// await editLocalStorage.path.fill(''); // await editLocalStorage.path.fill('');
// await editLocalStorage.defaultStorage.check(); // await editLocalStorage.defaultStorage.check();

View File

@ -14,8 +14,8 @@ export class CreateLocalStorage {
this.page = page; this.page = page;
this.title = page.getByLabel('block-item-CollectionField-storages-Title').getByRole('textbox'); this.title = page.getByLabel('block-item-CollectionField-storages-Title').getByRole('textbox');
this.storageName = page.getByLabel('block-item-CollectionField-storages-Storage name').getByRole('textbox'); this.storageName = page.getByLabel('block-item-CollectionField-storages-Storage name').getByRole('textbox');
this.storagebaseURL = page.getByLabel('block-item-CollectionField-storages-Storage base URL').getByRole('textbox'); // this.storagebaseURL = page.getByLabel('block-item-CollectionField-storages-Storage base URL').getByRole('textbox');
this.destination = page.getByLabel('block-item-Input-storages-Destination').getByRole('textbox'); // this.destination = page.getByLabel('block-item-Input-storages-Destination').getByRole('textbox');
this.path = page.getByLabel('block-item-CollectionField-storages-Path').getByRole('textbox'); this.path = page.getByLabel('block-item-CollectionField-storages-Path').getByRole('textbox');
this.defaultStorage = page.getByLabel('Default storage'); this.defaultStorage = page.getByLabel('Default storage');
this.deleteRecordRetentionFile = page.getByLabel('Keep file in storage when destroy record'); this.deleteRecordRetentionFile = page.getByLabel('Keep file in storage when destroy record');
@ -37,8 +37,8 @@ export class EditLocalStorage {
this.page = page; this.page = page;
this.title = page.getByLabel('block-item-CollectionField-storages-Title').getByRole('textbox'); this.title = page.getByLabel('block-item-CollectionField-storages-Title').getByRole('textbox');
this.storageName = page.getByLabel('block-item-CollectionField-storages-Storage name').getByRole('textbox'); this.storageName = page.getByLabel('block-item-CollectionField-storages-Storage name').getByRole('textbox');
this.storagebaseURL = page.getByLabel('block-item-CollectionField-storages-Storage base URL').getByRole('textbox'); // this.storagebaseURL = page.getByLabel('block-item-CollectionField-storages-Storage base URL').getByRole('textbox');
this.destination = page.getByLabel('block-item-Input-storages-Destination').getByRole('textbox'); // this.destination = page.getByLabel('block-item-Input-storages-Destination').getByRole('textbox');
this.path = page.getByLabel('block-item-CollectionField-storages-Path').getByRole('textbox'); this.path = page.getByLabel('block-item-CollectionField-storages-Path').getByRole('textbox');
this.defaultStorage = page.getByLabel('Default storage'); this.defaultStorage = page.getByLabel('Default storage');
this.deleteRecordRetentionFile = page.getByLabel('Keep file in storage when destroy record'); this.deleteRecordRetentionFile = page.getByLabel('Keep file in storage when destroy record');

View File

@ -12,6 +12,8 @@ export default {
'x-component': 'CollectionField', 'x-component': 'CollectionField',
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-disabled': '{{ !createOnly }}', 'x-disabled': '{{ !createOnly }}',
required: true,
default: '{{ useNewId("s_") }}',
description: description:
'{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}', '{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}',
}, },

View File

@ -12,12 +12,15 @@ export default {
'x-component': 'CollectionField', 'x-component': 'CollectionField',
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-disabled': '{{ !createOnly }}', 'x-disabled': '{{ !createOnly }}',
required: true,
default: '{{ useNewId("s_") }}',
description: description:
'{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}', '{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}',
}, },
baseUrl: { baseUrl: {
'x-component': 'CollectionField', 'x-component': 'CollectionField',
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-display': 'hidden',
default: '/storage/uploads', default: '/storage/uploads',
}, },
options: { options: {
@ -29,6 +32,7 @@ export default {
type: 'string', type: 'string',
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-component': 'Input', 'x-component': 'Input',
'x-display': 'hidden',
default: 'storage/uploads', default: 'storage/uploads',
}, },
}, },
@ -36,6 +40,9 @@ export default {
path: { path: {
'x-component': 'CollectionField', 'x-component': 'CollectionField',
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-component-props': {
addonBefore: 'storage/uploads/',
},
}, },
default: { default: {
'x-component': 'CollectionField', 'x-component': 'CollectionField',

View File

@ -12,6 +12,8 @@ export default {
'x-component': 'CollectionField', 'x-component': 'CollectionField',
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-disabled': '{{ !createOnly }}', 'x-disabled': '{{ !createOnly }}',
required: true,
default: '{{ useNewId("s_") }}',
description: description:
'{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}', '{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}',
}, },

View File

@ -12,6 +12,8 @@ export default {
'x-component': 'CollectionField', 'x-component': 'CollectionField',
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-disabled': '{{ !createOnly }}', 'x-disabled': '{{ !createOnly }}',
required: true,
default: '{{ useNewId("s_") }}',
description: description:
'{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}', '{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}',
}, },

View File

@ -23,7 +23,7 @@ export default {
'Tencent COS': '腾讯云 COS', 'Tencent COS': '腾讯云 COS',
Region: '区域', Region: '区域',
Bucket: '存储桶', Bucket: '存储桶',
Path: '相对路径', Path: '路径',
Filename: '文件名', Filename: '文件名',
'Will be used for API': '将用于 API', 'Will be used for API': '将用于 API',
'Default storage will be used when not selected': '留空将使用默认存储空间', 'Default storage will be used when not selected': '留空将使用默认存储空间',

View File

@ -16,7 +16,7 @@ export default {
{ {
title: '英文标识', title: '英文标识',
// comment: '英文标识,用于代码层面配置', // comment: '英文标识,用于代码层面配置',
type: 'string', type: 'uid',
name: 'name', name: 'name',
unique: true, unique: true,
}, },