Browse Source

support modal close for datasources (#13586)

3.2.0-release
Devosend 2 years ago committed by GitHub
parent
commit
eaf2541018
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      dolphinscheduler-ui/src/components/modal/index.tsx
  2. 34
      dolphinscheduler-ui/src/views/datasource/list/index.tsx
  3. 31
      dolphinscheduler-ui/src/views/datasource/list/source-modal.tsx

20
dolphinscheduler-ui/src/components/modal/index.tsx

@ -74,7 +74,7 @@ const props = {
const Modal = defineComponent({ const Modal = defineComponent({
name: 'Modal', name: 'Modal',
props, props,
emits: ['cancel', 'confirm', 'jumpLink'], emits: ['cancel', 'confirm', 'jumpLink', 'maskClick'],
setup(props, ctx) { setup(props, ctx) {
const { t } = useI18n() const { t } = useI18n()
@ -86,11 +86,22 @@ const Modal = defineComponent({
ctx.emit('confirm') ctx.emit('confirm')
} }
return { t, onCancel, onConfirm } const onMaskClick = () => {
ctx.emit('maskClick')
}
return { t, onCancel, onConfirm, onMaskClick }
}, },
render() { render() {
const { $slots, t, onCancel, onConfirm, confirmDisabled, confirmLoading } = const {
this $slots,
t,
onCancel,
onConfirm,
onMaskClick,
confirmDisabled,
confirmLoading
} = this
return ( return (
<NModal <NModal
@ -98,6 +109,7 @@ const Modal = defineComponent({
class={styles.container} class={styles.container}
mask-closable={false} mask-closable={false}
auto-focus={this.autoFocus} auto-focus={this.autoFocus}
onMaskClick={onMaskClick}
> >
<NCard <NCard
title={this.title} title={this.title}

34
dolphinscheduler-ui/src/views/datasource/list/index.tsx

@ -23,13 +23,7 @@ import {
toRefs, toRefs,
watch watch
} from 'vue' } from 'vue'
import { import { NButton, NIcon, NDataTable, NPagination, NSpace } from 'naive-ui'
NButton,
NIcon,
NDataTable,
NPagination,
NSpace
} from 'naive-ui'
import { SearchOutlined } from '@vicons/antd' import { SearchOutlined } from '@vicons/antd'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useColumns } from './use-columns' import { useColumns } from './use-columns'
@ -56,7 +50,8 @@ const list = defineComponent({
const { data, changePage, changePageSize, deleteRecord, updateList } = const { data, changePage, changePageSize, deleteRecord, updateList } =
useTable() useTable()
const { getColumns } = useColumns((id: number, type: 'edit' | 'delete', row?: any) => { const { getColumns } = useColumns(
(id: number, type: 'edit' | 'delete', row?: any) => {
if (type === 'edit') { if (type === 'edit') {
showDetailModal.value = true showDetailModal.value = true
selectId.value = id selectId.value = id
@ -64,7 +59,8 @@ const list = defineComponent({
} else { } else {
deleteRecord(id) deleteRecord(id)
} }
}) }
)
const onCreate = () => { const onCreate = () => {
selectId.value = null selectId.value = null
@ -83,6 +79,10 @@ const list = defineComponent({
showSourceModal.value = true showSourceModal.value = true
} }
const handleSourceModalClose = () => {
showSourceModal.value = false
}
onMounted(() => { onMounted(() => {
changePage(1) changePage(1)
columns.value = getColumns() columns.value = getColumns()
@ -106,7 +106,8 @@ const list = defineComponent({
trim, trim,
handleSelectSourceType, handleSelectSourceType,
selectType, selectType,
handleSourceModalOpen handleSourceModalOpen,
handleSourceModalClose
} }
}, },
render() { render() {
@ -127,7 +128,8 @@ const list = defineComponent({
onUpdatedList, onUpdatedList,
handleSelectSourceType, handleSelectSourceType,
selectType, selectType,
handleSourceModalOpen handleSourceModalOpen,
handleSourceModalClose
} = this } = this
return ( return (
@ -144,8 +146,8 @@ const list = defineComponent({
</NButton> </NButton>
<NSpace justify='end' wrap={false}> <NSpace justify='end' wrap={false}>
<Search <Search
v-model:value = {this.searchVal} v-model:value={this.searchVal}
placeholder = {t('datasource.search_input_tips')} placeholder={t('datasource.search_input_tips')}
onSearch={onUpdatedList} onSearch={onUpdatedList}
/> />
<NButton type='primary' size='small' onClick={onUpdatedList}> <NButton type='primary' size='small' onClick={onUpdatedList}>
@ -180,7 +182,11 @@ const list = defineComponent({
</NSpace> </NSpace>
</NSpace> </NSpace>
</Card> </Card>
<SourceModal show={showSourceModal} onChange={handleSelectSourceType}></SourceModal> <SourceModal
show={showSourceModal}
onChange={handleSelectSourceType}
onMaskClick={handleSourceModalClose}
></SourceModal>
<DetailModal <DetailModal
show={showDetailModal} show={showDetailModal}
id={id} id={id}

31
dolphinscheduler-ui/src/views/datasource/list/source-modal.tsx

@ -15,14 +15,8 @@
* limitations under the License. * limitations under the License.
*/ */
import { import { defineComponent, PropType, toRefs } from 'vue'
defineComponent, import { NSpace } from 'naive-ui'
PropType,
toRefs
} from 'vue'
import {
NSpace
} from 'naive-ui'
import Modal from '@/components/modal' import Modal from '@/components/modal'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useForm, datasourceTypeList } from './use-form' import { useForm, datasourceTypeList } from './use-form'
@ -41,7 +35,7 @@ const props = {
const SourceModal = defineComponent({ const SourceModal = defineComponent({
name: 'SourceModal', name: 'SourceModal',
props, props,
emits: ['change'], emits: ['change', 'maskClick'],
setup(props, ctx) { setup(props, ctx) {
const { t } = useI18n() const { t } = useI18n()
@ -51,18 +45,19 @@ const SourceModal = defineComponent({
ctx.emit('change', value) ctx.emit('change', value)
} }
const handleMaskClick = () => {
ctx.emit('maskClick')
}
return { return {
t, t,
...toRefs(state), ...toRefs(state),
handleTypeSelect handleTypeSelect,
handleMaskClick
} }
}, },
render() { render() {
const { const { show, t, handleTypeSelect, handleMaskClick } = this
show,
t,
handleTypeSelect
} = this
return ( return (
<Modal <Modal
@ -71,13 +66,17 @@ const SourceModal = defineComponent({
title={t('datasource.choose_datasource_type')} title={t('datasource.choose_datasource_type')}
cancelShow={false} cancelShow={false}
confirmShow={false} confirmShow={false}
onMaskClick={handleMaskClick}
> >
{{ {{
default: () => ( default: () => (
<div class={styles.content}> <div class={styles.content}>
<NSpace> <NSpace>
{datasourceTypeList.map((item) => ( {datasourceTypeList.map((item) => (
<div class={[styles.itemBox, `${item.label}-box`]} onClick={() => handleTypeSelect(item.value)}> <div
class={[styles.itemBox, `${item.label}-box`]}
onClick={() => handleTypeSelect(item.value)}
>
{item.label} {item.label}
</div> </div>
))} ))}

Loading…
Cancel
Save