Browse Source

[Fix-10890] fix some bugs in the Resource page (#10907)

* [Fix-10890] fix some bugs in the Resource page

* fix: cancel the unnecessary verifications and reset the form when canceling FileUploadModal

* fix: use se `resetForm` method to reset the form
3.0.0/version-upgrade
rockfang 2 years ago committed by caishunfeng
parent
commit
6880a72984
  1. 6
      dolphinscheduler-ui/src/views/resource/file/upload/index.tsx
  2. 2
      dolphinscheduler-ui/src/views/resource/udf/function/components/function-modal.tsx
  3. 17
      dolphinscheduler-ui/src/views/resource/udf/resource/components/folder-modal.tsx
  4. 9
      dolphinscheduler-ui/src/views/resource/udf/resource/components/upload-modal.tsx
  5. 9
      dolphinscheduler-ui/src/views/resource/udf/resource/components/use-form.ts
  6. 2
      dolphinscheduler-ui/src/views/resource/udf/resource/components/use-modal.ts

6
dolphinscheduler-ui/src/views/resource/file/upload/index.tsx

@ -38,15 +38,14 @@ export default defineComponent({
const { handleUploadFile } = useUpload(state) const { handleUploadFile } = useUpload(state)
const hideModal = () => { const hideModal = () => {
resetForm()
ctx.emit('update:show') ctx.emit('update:show')
} }
const customRequest = ({ file }: any) => { const customRequest = ({ file }: any) => {
state.uploadForm.name = file.name state.uploadForm.name = file.name
state.uploadForm.file = file.file state.uploadForm.file = file.file
state.uploadFormNameRef.validate({ state.uploadFormRef.validate()
trigger: 'input'
})
} }
const handleFile = () => { const handleFile = () => {
@ -55,6 +54,7 @@ export default defineComponent({
const removeFile = () => { const removeFile = () => {
state.uploadForm.name = '' state.uploadForm.name = ''
state.uploadForm.file = ''
} }
return { return {

2
dolphinscheduler-ui/src/views/resource/udf/function/components/function-modal.tsx

@ -92,7 +92,7 @@ export default defineComponent({
() => props.row, () => props.row,
() => { () => {
variables.uploadShow = false variables.uploadShow = false
state.functionForm.type = props.row.type state.functionForm.type = props.row.type || 'HIVE'
state.functionForm.funcName = props.row.funcName state.functionForm.funcName = props.row.funcName
state.functionForm.className = props.row.className state.functionForm.className = props.row.className
state.functionForm.resourceId = props.row.resourceId || -1 state.functionForm.resourceId = props.row.resourceId || -1

17
dolphinscheduler-ui/src/views/resource/udf/resource/components/folder-modal.tsx

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { defineComponent, toRefs, PropType, watch } from 'vue' import { defineComponent, toRefs, PropType, watch, computed } from 'vue'
import { NForm, NFormItem, NInput } from 'naive-ui' import { NForm, NFormItem, NInput } from 'naive-ui'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import Modal from '@/components/modal' import Modal from '@/components/modal'
@ -62,8 +62,10 @@ export default defineComponent({
state.folderForm.description = props.row.description state.folderForm.description = props.row.description
} }
) )
const fileEdit = computed(() => props.row.id && !props.row.directory)
return { return {
fileEdit,
hideModal, hideModal,
handleCreate, handleCreate,
handleRename, handleRename,
@ -76,7 +78,9 @@ export default defineComponent({
return ( return (
<Modal <Modal
show={this.$props.show} show={this.$props.show}
title={t('resource.udf.create_folder')} title={
this.row.id ? t('resource.udf.edit') : t('resource.udf.create_folder')
}
onCancel={this.hideModal} onCancel={this.hideModal}
onConfirm={this.row.id ? this.handleRename : this.handleCreate} onConfirm={this.row.id ? this.handleRename : this.handleCreate}
confirmClassName='btn-submit' confirmClassName='btn-submit'
@ -84,7 +88,14 @@ export default defineComponent({
confirmLoading={this.saving} confirmLoading={this.saving}
> >
<NForm rules={this.rules} ref='folderFormRef'> <NForm rules={this.rules} ref='folderFormRef'>
<NFormItem label={t('resource.udf.folder_name')} path='name'> <NFormItem
label={
this.fileEdit
? t('resource.udf.file_name')
: t('resource.udf.folder_name')
}
path='name'
>
<NInput <NInput
v-model={[this.folderForm.name, 'value']} v-model={[this.folderForm.name, 'value']}
placeholder={t('resource.udf.enter_name_tips')} placeholder={t('resource.udf.enter_name_tips')}

9
dolphinscheduler-ui/src/views/resource/udf/resource/components/upload-modal.tsx

@ -52,12 +52,19 @@ export default defineComponent({
const customRequest = ({ file }: any) => { const customRequest = ({ file }: any) => {
state.uploadForm.name = file.name state.uploadForm.name = file.name
state.uploadForm.file = file.file state.uploadForm.file = file.file
state.uploadFormRef.validate()
}
const removeFile = () => {
state.uploadForm.name = ''
state.uploadForm.file = ''
} }
return { return {
hideModal, hideModal,
handleFolder, handleFolder,
customRequest, customRequest,
removeFile,
...toRefs(state) ...toRefs(state)
} }
}, },
@ -93,7 +100,9 @@ export default defineComponent({
<NUpload <NUpload
v-model={[this.uploadForm.file, 'value']} v-model={[this.uploadForm.file, 'value']}
customRequest={this.customRequest} customRequest={this.customRequest}
max={1}
class='btn-upload' class='btn-upload'
onRemove={this.removeFile}
> >
<NButton> <NButton>
{t('resource.udf.upload')} {t('resource.udf.upload')}

9
dolphinscheduler-ui/src/views/resource/udf/resource/components/use-form.ts

@ -64,6 +64,15 @@ export const useForm = () => {
return new Error(t('resource.udf.enter_name_tips')) return new Error(t('resource.udf.enter_name_tips'))
} }
} }
},
file: {
required: true,
trigger: ['input', 'blur'],
validator() {
if (uploadState.uploadForm.file === '') {
return new Error(t('resource.file.enter_content_tips'))
}
}
} }
} as FormRules } as FormRules
}) })

2
dolphinscheduler-ui/src/views/resource/udf/resource/components/use-modal.ts

@ -105,7 +105,7 @@ export function useModal(
ctx.emit('updateList') ctx.emit('updateList')
ctx.emit('update:show') ctx.emit('update:show')
resetUploadForm() resetUploadForm()
} catch (err) { } finally {
state.saving = false state.saving = false
} }
} }

Loading…
Cancel
Save