Skip to content

Commit 9cde6da

Browse files
sheldonliuSheldon
authored andcommitted
[Feature-11195][UI] Add re-upload feature for resource files and udf files
* fix resource file incorrect button link * add re-upload feature for resource files * add re-upload feature for udf files * modify udf edit button to rename button * fix file resource page button-link constraint * encapsulate file and udf resource code * place the breadcrumbs in the upper left corner * optimized some code * modify relative e2e test * Fix the problem of UDF page breadcrumbs when using the browser to go back or forward * adapt to the latest resource center
1 parent 4f73fe1 commit 9cde6da

File tree

40 files changed

+993
-1832
lines changed

40 files changed

+993
-1832
lines changed

dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/resource/FileManagePage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class FileManagePage extends NavBarPage implements ResourcePage.Tab {
5151
@FindBy(className = "btn-create-file")
5252
private WebElement buttonCreateFile;
5353

54-
@FindBy(className = "btn-upload-file")
54+
@FindBy(className = "btn-upload-resource")
5555
private WebElement buttonUploadFile;
5656

5757
private final CreateDirectoryBox createDirectoryBox;

dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/resource/UdfManagePage.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class UdfManagePage extends NavBarPage implements ResourcePage.Tab {
4040
@FindBy(className = "btn-create-directory")
4141
private WebElement buttonCreateDirectory;
4242

43-
@FindBy(className = "btn-upload-udf")
43+
@FindBy(className = "btn-upload-resource")
4444
private WebElement buttonUploadUdf;
4545

4646
@FindBy(className = "items")
@@ -54,7 +54,7 @@ public class UdfManagePage extends NavBarPage implements ResourcePage.Tab {
5454

5555
private final UploadFileBox uploadFileBox;
5656

57-
private final RenameDirectoryBox renameDirectoryBox;
57+
private final RenameBox renameBox;
5858

5959
private final CreateDirectoryBox createDirectoryBox;
6060

@@ -63,7 +63,7 @@ public UdfManagePage(RemoteWebDriver driver) {
6363

6464
uploadFileBox = new UploadFileBox();
6565

66-
renameDirectoryBox = new RenameDirectoryBox();
66+
renameBox = new RenameBox();
6767

6868
createDirectoryBox = new CreateDirectoryBox();
6969
}
@@ -106,15 +106,15 @@ public UdfManagePage rename(String currentName, String AfterName) {
106106
udfList()
107107
.stream()
108108
.filter(it -> it.getText().contains(currentName))
109-
.flatMap(it -> it.findElements(By.className("btn-edit")).stream())
109+
.flatMap(it -> it.findElements(By.className("btn-rename")).stream())
110110
.filter(WebElement::isDisplayed)
111111
.findFirst()
112112
.orElseThrow(() -> new RuntimeException("No rename button in udf manage list"))
113113
.click();
114114

115-
renameDirectoryBox().inputName().clear();
116-
renameDirectoryBox().inputName().sendKeys(AfterName);
117-
renameDirectoryBox().buttonSubmit().click();
115+
renameBox().inputName().clear();
116+
renameBox().inputName().sendKeys(AfterName);
117+
renameBox().buttonSubmit().click();
118118

119119
return this;
120120
}
@@ -135,20 +135,20 @@ public UdfManagePage delete(String name) {
135135
}
136136

137137
@Getter
138-
public class RenameDirectoryBox {
139-
RenameDirectoryBox() {
138+
public class RenameBox {
139+
RenameBox() {
140140
PageFactory.initElements(driver, this);
141141
}
142142

143143
@FindBys({
144-
@FindBy(className = "input-directory-name"),
145-
@FindBy(tagName = "input"),
144+
@FindBy(className = "input-name"),
145+
@FindBy(tagName = "input"),
146146
})
147147
private WebElement inputName;
148148

149149
@FindBys({
150-
@FindBy(className = "input-description"),
151-
@FindBy(tagName = "textarea"),
150+
@FindBy(className = "input-description"),
151+
@FindBy(tagName = "textarea"),
152152
})
153153
private WebElement inputDescription;
154154

dolphinscheduler-ui/src/locales/en_US/resource.ts

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ export default {
2929
file_name: 'File Name',
3030
description: 'Description',
3131
size: 'Size',
32+
create_time: 'Create Time',
3233
update_time: 'Update Time',
3334
operation: 'Operation',
3435
edit: 'Edit',
36+
reupload: 'ReUpload File',
3537
rename: 'Rename',
3638
download: 'Download',
3739
delete: 'Delete',
@@ -55,33 +57,9 @@ export default {
5557
},
5658
udf: {
5759
udf_resources: 'UDF resources',
58-
create_folder: 'Create Folder',
5960
upload_udf_resources: 'Upload UDF Resources',
6061
udf_source_name: 'UDF Resource Name',
6162
user_name: 'Resource userName',
62-
tenant_name: 'Resource tenantName',
63-
whether_directory: 'Whether directory',
64-
file_name: 'File Name',
65-
file_size: 'File Size',
66-
description: 'Description',
67-
create_time: 'Create Time',
68-
update_time: 'Update Time',
69-
operation: 'Operation',
70-
yes: 'Yes',
71-
no: 'No',
72-
edit: 'Edit',
73-
rename: 'Rename',
74-
download: 'Download',
75-
delete: 'Delete',
76-
delete_confirm: 'Delete?',
77-
success: 'Success',
78-
folder_name: 'Folder Name',
79-
upload: 'Upload',
80-
upload_files: 'Upload Files',
81-
file_upload: 'File Upload',
82-
enter_keyword_tips: 'Please enter keyword',
83-
enter_name_tips: 'Please enter name',
84-
enter_description_tips: 'Please enter description'
8563
},
8664
function: {
8765
udf_function: 'UDF Function',

dolphinscheduler-ui/src/locales/zh_CN/resource.ts

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@ export default {
2424
enter_keyword_tips: '请输入关键词',
2525
name: '名称',
2626
user_name: '所属用户',
27+
tenant_name: '所属租户',
2728
whether_directory: '是否文件夹',
2829
file_name: '文件名称',
2930
description: '描述',
3031
size: '大小',
32+
create_time: '创建时间',
3133
update_time: '更新时间',
3234
operation: '操作',
3335
edit: '编辑',
36+
reupload: '重新上传文件',
3437
rename: '重命名',
3538
download: '下载',
3639
delete: '删除',
@@ -54,31 +57,8 @@ export default {
5457
},
5558
udf: {
5659
udf_resources: 'UDF资源',
57-
create_folder: '创建文件夹',
5860
upload_udf_resources: '上传UDF资源',
59-
udf_source_name: 'UDF资源名称',
60-
user_name: '所属用户',
61-
whether_directory: '是否文件夹',
62-
file_name: '文件名称',
63-
file_size: '文件大小',
64-
description: '描述',
65-
create_time: '创建时间',
66-
update_time: '更新时间',
67-
operation: '操作',
68-
yes: '是',
69-
no: '否',
70-
edit: '编辑',
71-
download: '下载',
72-
delete: '删除',
73-
success: '成功',
74-
folder_name: '文件夹名称',
75-
upload: '上传',
76-
upload_files: '上传文件',
77-
file_upload: '文件上传',
78-
delete_confirm: '确定删除吗?',
79-
enter_keyword_tips: '请输入关键词',
80-
enter_name_tips: '请输入名称',
81-
enter_description_tips: '请输入描述'
61+
udf_source_name: 'UDF资源名称'
8262
},
8363
function: {
8464
udf_function: 'UDF函数',

dolphinscheduler-ui/src/service/modules/resources/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ interface ResourceFile {
103103
fullName: string
104104
description: string
105105
size: number
106+
createTime: string
106107
updateTime: string
107108
}
108109

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import { defineComponent, getCurrentInstance, toRefs } from 'vue'
19+
import { useRouter } from 'vue-router'
20+
import { NForm, NFormItem, NInput, NSelect, NButton } from 'naive-ui'
21+
import { useI18n } from 'vue-i18n'
22+
23+
import Card from '@/components/card'
24+
import MonacoEditor from '@/components/monaco-editor'
25+
import { useCreate } from './use-create'
26+
import { useForm } from './use-form'
27+
import { fileTypeArr } from '@/common/common'
28+
29+
import styles from '../index.module.scss'
30+
31+
import type { Router } from 'vue-router'
32+
33+
export default defineComponent({
34+
name: 'ResourceCreate',
35+
setup() {
36+
const router: Router = useRouter()
37+
38+
const { state } = useForm()
39+
const { handleCreateFile } = useCreate(state)
40+
41+
const fileSuffixOptions = fileTypeArr.map((suffix) => ({
42+
key: suffix,
43+
label: suffix,
44+
value: suffix
45+
}))
46+
47+
const handleFile = () => {
48+
handleCreateFile()
49+
}
50+
51+
const handleReturn = () => {
52+
router.go(-1)
53+
}
54+
55+
const trim = getCurrentInstance()?.appContext.config.globalProperties.trim
56+
57+
return {
58+
fileSuffixOptions,
59+
handleFile,
60+
handleReturn,
61+
...toRefs(state),
62+
trim
63+
}
64+
},
65+
render() {
66+
const { t } = useI18n()
67+
return (
68+
<Card title={t('resource.file.file_details')}>
69+
<NForm
70+
rules={this.rules}
71+
ref='fileFormRef'
72+
class={styles['form-content']}
73+
>
74+
<NFormItem label={t('resource.file.file_name')} path='fileName'>
75+
<NInput
76+
allowInput={this.trim}
77+
v-model={[this.fileForm.fileName, 'value']}
78+
placeholder={t('resource.file.enter_name_tips')}
79+
style={{ width: '300px' }}
80+
class='input-file-name'
81+
/>
82+
</NFormItem>
83+
<NFormItem label={t('resource.file.file_format')} path='suffix'>
84+
<NSelect
85+
defaultValue={[this.fileForm.suffix]}
86+
v-model={[this.fileForm.suffix, 'value']}
87+
options={this.fileSuffixOptions}
88+
style={{ width: '100px' }}
89+
class='select-file-format'
90+
/>
91+
</NFormItem>
92+
<NFormItem label={t('resource.file.description')} path='description'>
93+
<NInput
94+
allowInput={this.trim}
95+
type='textarea'
96+
v-model={[this.fileForm.description, 'value']}
97+
placeholder={t('resource.file.enter_description_tips')}
98+
style={{ width: '430px' }}
99+
class='input-description'
100+
/>
101+
</NFormItem>
102+
<NFormItem label={t('resource.file.file_content')} path='content'>
103+
<div
104+
style={{
105+
width: '90%'
106+
}}
107+
>
108+
<MonacoEditor v-model={[this.fileForm.content, 'value']} />
109+
</div>
110+
</NFormItem>
111+
<div class={styles['file-edit-content']}>
112+
<div class={styles.submit}>
113+
<NButton
114+
type='info'
115+
size='small'
116+
round
117+
onClick={this.handleFile}
118+
class='btn-submit'
119+
>
120+
{t('resource.file.save')}
121+
</NButton>
122+
<NButton
123+
type='info'
124+
size='small'
125+
text
126+
style={{ marginLeft: '15px' }}
127+
onClick={this.handleReturn}
128+
class='btn-cancel'
129+
>
130+
{t('resource.file.return')}
131+
</NButton>
132+
</div>
133+
</div>
134+
</NForm>
135+
</Card>
136+
)
137+
}
138+
})

dolphinscheduler-ui/src/views/resource/file/create/use-create.ts renamed to dolphinscheduler-ui/src/views/resource/components/resource/create/use-create.ts

File renamed without changes.

dolphinscheduler-ui/src/views/resource/file/create/use-form.ts renamed to dolphinscheduler-ui/src/views/resource/components/resource/create/use-form.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
import { useI18n } from 'vue-i18n'
1919
import { reactive, ref, unref } from 'vue'
2020
import type { FormRules } from 'naive-ui'
21+
import { ICreateFileDefaultValue } from "@/views/resource/components/resource/types";
2122

22-
const defaultValue = () => ({
23+
const defaultValue: ICreateFileDefaultValue = () => ({
2324
pid: -1,
2425
type: 'FILE',
2526
suffix: 'sh',

0 commit comments

Comments
 (0)