Browse Source

fix: base edit/create modals

pull/6528/head
mertmit 1 year ago
parent
commit
70377493cc
  1. 4
      packages/nc-gui/components/dashboard/settings/DataSources.vue
  2. 4
      packages/nc-gui/components/dashboard/settings/data-sources/CreateBase.vue
  3. 42
      packages/nc-gui/components/dashboard/settings/data-sources/EditBase.vue
  4. 9
      packages/nc-gui/components/general/Modal.vue

4
packages/nc-gui/components/dashboard/settings/DataSources.vue

@ -478,7 +478,7 @@ const isEditBaseModalOpen = computed({
</Draggable> </Draggable>
</div> </div>
</div> </div>
<GeneralModal v-model:visible="isNewBaseModalOpen" size="medium"> <GeneralModal v-model:visible="isNewBaseModalOpen" closable :mask-closable="false" size="medium">
<div class="py-6 px-8"> <div class="py-6 px-8">
<LazyDashboardSettingsDataSourcesCreateBase <LazyDashboardSettingsDataSourcesCreateBase
:connection-type="clientType" :connection-type="clientType"
@ -502,7 +502,7 @@ const isEditBaseModalOpen = computed({
<LazyDashboardSettingsUIAcl :base-id="activeBaseId" /> <LazyDashboardSettingsUIAcl :base-id="activeBaseId" />
</div> </div>
</GeneralModal> </GeneralModal>
<GeneralModal v-model:visible="isEditBaseModalOpen" size="medium"> <GeneralModal v-model:visible="isEditBaseModalOpen" closable :mask-closable="false" size="medium">
<div class="p-6"> <div class="p-6">
<LazyDashboardSettingsDataSourcesEditBase <LazyDashboardSettingsDataSourcesEditBase
:base-id="activeBaseId" :base-id="activeBaseId"

4
packages/nc-gui/components/dashboard/settings/data-sources/CreateBase.vue

@ -615,13 +615,13 @@ watch(
<a-form-item class="flex justify-end !mt-5"> <a-form-item class="flex justify-end !mt-5">
<div class="flex justify-end gap-2"> <div class="flex justify-end gap-2">
<NcButton <NcButton
type="primary" :type="testSuccess ? 'ghost' : 'primary'"
size="small" size="small"
class="nc-extdb-btn-test-connection !rounded-md" class="nc-extdb-btn-test-connection !rounded-md"
:loading="testingConnection" :loading="testingConnection"
@click="testConnection" @click="testConnection"
> >
<GeneralIcon v-if="testSuccess" icon="circleCheck" class="mr-2" /> <GeneralIcon v-if="testSuccess" icon="circleCheck" class="text-primary mr-2" />
{{ $t('activity.testDbConn') }} {{ $t('activity.testDbConn') }}
</NcButton> </NcButton>

42
packages/nc-gui/components/dashboard/settings/data-sources/EditBase.vue

@ -43,6 +43,8 @@ const useForm = Form.useForm
const testSuccess = ref(false) const testSuccess = ref(false)
const testingConnection = ref(false)
const form = ref<typeof Form>() const form = ref<typeof Form>()
const { api } = useApi() const { api } = useApi()
@ -51,6 +53,8 @@ const { $e } = useNuxtApp()
const { t } = useI18n() const { t } = useI18n()
const editingBase = ref(false)
const formState = ref<ProjectCreateForm>({ const formState = ref<ProjectCreateForm>({
title: '', title: '',
dataSource: { ...getDefaultConnectionConfig(ClientType.MYSQL) }, dataSource: { ...getDefaultConnectionConfig(ClientType.MYSQL) },
@ -234,8 +238,6 @@ const editBase = async () => {
} }
} }
const isConnSuccess = ref(false)
const testConnection = async () => { const testConnection = async () => {
try { try {
await validate() await validate()
@ -247,6 +249,8 @@ const testConnection = async () => {
$e('a:base:edit:extdb:test-connection', []) $e('a:base:edit:extdb:test-connection', [])
try { try {
testingConnection.value = true
if (formState.value.dataSource.client === ClientType.SQLITE) { if (formState.value.dataSource.client === ClientType.SQLITE) {
testSuccess.value = true testSuccess.value = true
} else { } else {
@ -263,7 +267,6 @@ const testConnection = async () => {
if (result.code === 0) { if (result.code === 0) {
testSuccess.value = true testSuccess.value = true
isConnSuccess.value = true
} else { } else {
testSuccess.value = false testSuccess.value = false
@ -275,6 +278,8 @@ const testConnection = async () => {
message.error(await extractSdkResponseErrorMsg(e)) message.error(await extractSdkResponseErrorMsg(e))
} }
testingConnection.value = false
} }
const handleImportURL = async () => { const handleImportURL = async () => {
@ -427,7 +432,7 @@ onMounted(async () => {
</a-form-item> </a-form-item>
<!-- Use Connection URL --> <!-- Use Connection URL -->
<div class="flex justify-end gap-2"> <div class="flex justify-end gap-2">
<NcButton size="small" type="primary" class="nc-extdb-btn-import-url !rounded-md" @click.stop="importURLDlg = true"> <NcButton size="small" type="ghost" class="nc-extdb-btn-import-url !rounded-md" @click.stop="importURLDlg = true">
{{ $t('activity.useConnectionUrl') }} {{ $t('activity.useConnectionUrl') }}
</NcButton> </NcButton>
</div> </div>
@ -519,7 +524,7 @@ onMounted(async () => {
v-model:value="formState.inflection.inflectionTable" v-model:value="formState.inflection.inflectionTable"
dropdown-class-name="nc-dropdown-inflection-table-name" dropdown-class-name="nc-dropdown-inflection-table-name"
> >
<a-select-option v-for="type in inflectionTypes" :key="type" :value="type">{{ type }}</a-select-option> <a-select-option v-for="tp in inflectionTypes" :key="tp" :value="tp">{{ tp }}</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
@ -528,7 +533,7 @@ onMounted(async () => {
v-model:value="formState.inflection.inflectionColumn" v-model:value="formState.inflection.inflectionColumn"
dropdown-class-name="nc-dropdown-inflection-column-name" dropdown-class-name="nc-dropdown-inflection-column-name"
> >
<a-select-option v-for="type in inflectionTypes" :key="type" :value="type">{{ type }}</a-select-option> <a-select-option v-for="tp in inflectionTypes" :key="tp" :value="tp">{{ tp }}</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
@ -545,15 +550,23 @@ onMounted(async () => {
<a-form-item class="flex justify-end !mt-5"> <a-form-item class="flex justify-end !mt-5">
<div class="flex justify-end gap-2"> <div class="flex justify-end gap-2">
<NcButton type="secondary" size="small" class="nc-extdb-btn-test-connection !rounded-md" @click="testConnection"> <NcButton
:type="testSuccess ? 'ghost' : 'primary'"
size="small"
class="nc-extdb-btn-test-connection !rounded-md"
:loading="testingConnection"
@click="testConnection"
>
<GeneralIcon v-if="testSuccess" icon="circleCheck" class="text-primary mr-2" />
{{ $t('activity.testDbConn') }} {{ $t('activity.testDbConn') }}
</NcButton> </NcButton>
<NcButton <NcButton
class="nc-extdb-btn-submit !rounded-md"
size="small" size="small"
type="primary" type="primary"
:disabled="!testSuccess" :disabled="!testSuccess"
class="nc-extdb-btn-submit !rounded-md" :loading="editingBase"
@click="editBase" @click="editBase"
> >
{{ $t('general.submit') }} {{ $t('general.submit') }}
@ -569,7 +582,7 @@ onMounted(async () => {
<a-modal <a-modal
v-model:visible="configEditDlg" v-model:visible="configEditDlg"
:title="$t('activity.editConnJson')" :title="$t('activity.editConnJson')"
width="600px" width="500px"
wrap-class-name="nc-modal-edit-connection-json" wrap-class-name="nc-modal-edit-connection-json"
@ok="handleOk" @ok="handleOk"
> >
@ -589,17 +602,6 @@ onMounted(async () => {
<a-input v-model:value="importURL" /> <a-input v-model:value="importURL" />
</a-modal> </a-modal>
</div> </div>
<!-- connection succesfull modal -->
<GeneralModal v-model:visible="isConnSuccess" class="!w-97">
<div class="flex flex-col h-full p-8">
<div class="text-lg font-semibold self-start mb-4">{{ t('msg.info.dbConnected') }}</div>
<div class="flex gap-x-2 mt-5 ml-7 pt-2.5 justify-end">
<NcButton key="back" type="secondary" @click="isConnSuccess = false">{{ $t('general.cancel') }}</NcButton>
<NcButton key="submit" type="primary" @click="editBase">{{ $t('activity.okEditBase') }}</NcButton>
</div>
</div>
</GeneralModal>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>

9
packages/nc-gui/components/general/Modal.vue

@ -5,16 +5,20 @@ const props = withDefaults(
width?: string | number width?: string | number
size?: 'small' | 'medium' | 'large' size?: 'small' | 'medium' | 'large'
destroyOnClose?: boolean destroyOnClose?: boolean
maskClosable?: boolean
closable?: boolean
}>(), }>(),
{ {
size: 'medium', size: 'medium',
destroyOnClose: true, destroyOnClose: true,
maskClosable: true,
closable: false,
}, },
) )
const emits = defineEmits(['update:visible']) const emits = defineEmits(['update:visible'])
const { width: propWidth, destroyOnClose } = props const { width: propWidth, destroyOnClose, closable, maskClosable } = props
const width = computed(() => { const width = computed(() => {
if (propWidth) { if (propWidth) {
@ -60,10 +64,11 @@ const visible = useVModel(props, 'visible', emits)
v-model:visible="visible" v-model:visible="visible"
:class="{ active: visible }" :class="{ active: visible }"
:width="width" :width="width"
:closable="false" :closable="closable"
wrap-class-name="nc-modal-wrapper" wrap-class-name="nc-modal-wrapper"
:footer="null" :footer="null"
:destroy-on-close="destroyOnClose" :destroy-on-close="destroyOnClose"
:mask-closable="maskClosable"
@keydown.esc="visible = false" @keydown.esc="visible = false"
> >
<div :class="`nc-modal max-h-[${height}]`"> <div :class="`nc-modal max-h-[${height}]`">

Loading…
Cancel
Save