Browse Source

fix(nc-gui): allow only 1 db creation per sqlite integration connection

pull/9265/head
Ramesh Mane 3 months ago
parent
commit
1213279bb9
  1. 29
      packages/nc-gui/components/dashboard/settings/data-sources/CreateBase.vue

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

@ -1,6 +1,6 @@
<script lang="ts" setup>
import { Form, message } from 'ant-design-vue'
import { validateAndExtractSSLProp } from 'nocodb-sdk'
import { validateAndExtractSSLProp, type IntegrationType } from 'nocodb-sdk'
import {
ClientType,
type DatabricksConnection,
@ -420,6 +420,22 @@ function handleAutoScroll(scroll: boolean, className: string) {
}
const filterIntegrationCategory = (c: IntegrationCategoryItemType) => [IntegrationCategoryType.DATABASE].includes(c.value)
const isIntgrationDisabled = (integration: IntegrationType = {}) => {
switch (integration.sub_type) {
case ClientType.SQLITE:
return {
isDisabled: integration?.source_count && integration.source_count > 0,
msg: 'Sqlite support only 1 database per integration',
}
default:
return {
isDisabled: false,
msg: '',
}
}
}
</script>
<template>
@ -517,12 +533,17 @@ const filterIntegrationCategory = (c: IntegrationCategoryItemType) => [Integrati
dropdown-match-select-width
@change="changeIntegration()"
>
<a-select-option v-for="integration in integrations" :key="integration.id" :value="integration.id">
<a-select-option
v-for="integration in integrations"
:key="integration.id"
:value="integration.id"
:disabled="isIntgrationDisabled(integration).isDisabled"
>
<div class="w-full flex gap-2 items-center" :data-testid="integration.title">
<GeneralIntegrationIcon v-if="integration?.sub_type" :type="integration.sub_type" />
<NcTooltip class="flex-1 truncate" show-on-truncate-only>
<NcTooltip class="flex-1 truncate" :show-on-truncate-only="!isIntgrationDisabled(integration).isDisabled">
<template #title>
{{ integration.title }}
{{ isIntgrationDisabled(integration).isDisabled ? isIntgrationDisabled(integration).msg : integration.title }}
</template>
{{ integration.title }}
</NcTooltip>

Loading…
Cancel
Save