Browse Source

feat(gui-v2): new ssl mode allowed

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/3306/head
mertmit 2 years ago
parent
commit
1eb3299d83
  1. 27
      packages/nc-gui-v2/pages/index/index/create-external.vue
  2. 54
      packages/nc-gui-v2/utils/projectCreateUtils.ts

27
packages/nc-gui-v2/pages/index/index/create-external.vue

@ -1,5 +1,6 @@
<script lang="ts" setup>
import { Form, Modal, message } from 'ant-design-vue'
import type { RawValueType } from 'ant-design-vue'
import {
clientTypes,
computed,
@ -96,6 +97,24 @@ const onClientChange = () => {
populateName(formState.title)
}
const onSSLModeChange = (v: RawValueType) => {
switch (v) {
case 'No':
delete formState.dataSource.connection.ssl
break
case 'Allowed':
formState.dataSource.connection.ssl = true
break
default:
formState.dataSource.connection.ssl = {
ca: '',
cert: '',
key: '',
}
break
}
}
const inflectionTypes = ['camelize', 'none']
const configEditDlg = ref(false)
@ -120,7 +139,7 @@ const onFileSelect = (key: 'ca' | 'cert' | 'key', el: HTMLInputElement) => {
}
const sslFilesRequired = computed<boolean>(() => {
return formState?.sslUse && formState.sslUse !== 'No'
return formState?.sslUse && formState.sslUse !== 'No' && formState.sslUse !== 'Allowed'
})
function getConnectionConfig() {
@ -335,7 +354,7 @@ onMounted(() => {
<a-collapse-panel key="1" :header="$t('title.advancedParameters')">
<!-- todo: add in i18n -->
<a-form-item label="SSL mode">
<a-select v-model:value="formState.sslUse" @change="onClientChange">
<a-select v-model:value="formState.sslUse" @select="onSSLModeChange">
<a-select-option v-for="opt in sslUsage" :key="opt" :value="opt">{{ opt }}</a-select-option>
</a-select>
</a-form-item>
@ -385,13 +404,13 @@ onMounted(() => {
<a-divider />
<a-form-item :label="$t('labels.inflection.tableName')">
<a-select v-model:value="formState.inflection.inflectionTable" @change="onClientChange">
<a-select v-model:value="formState.inflection.inflectionTable">
<a-select-option v-for="type in inflectionTypes" :key="type" :value="type">{{ type }}</a-select-option>
</a-select>
</a-form-item>
<a-form-item :label="$t('labels.inflection.columnName')">
<a-select v-model:value="formState.inflection.inflectionColumn" @change="onClientChange">
<a-select v-model:value="formState.inflection.inflectionColumn">
<a-select-option v-for="type in inflectionTypes" :key="type" :value="type">{{ type }}</a-select-option>
</a-select>
</a-form-item>

54
packages/nc-gui-v2/utils/projectCreateUtils.ts

@ -11,7 +11,7 @@ export interface ProjectCreateForm {
user: string
password: string
port: number | string
ssl?: Record<string, string>
ssl?: Record<string, string> | string
}
| {
client?: ClientType.SQLITE
@ -73,11 +73,6 @@ const sampleConnectionData: Record<ClientType | string, ProjectCreateForm['dataS
user: 'postgres',
password: 'password',
database: '_test',
ssl: {
ca: '',
key: '',
cert: '',
},
},
[ClientType.MYSQL]: {
host: defaultHost,
@ -85,11 +80,6 @@ const sampleConnectionData: Record<ClientType | string, ProjectCreateForm['dataS
user: 'root',
password: 'password',
database: '_test',
ssl: {
ca: '',
key: '',
cert: '',
},
},
[ClientType.VITESS]: {
host: defaultHost,
@ -97,11 +87,6 @@ const sampleConnectionData: Record<ClientType | string, ProjectCreateForm['dataS
user: 'root',
password: 'password',
database: '_test',
ssl: {
ca: '',
key: '',
cert: '',
},
},
[ClientType.MSSQL]: {
host: defaultHost,
@ -109,11 +94,6 @@ const sampleConnectionData: Record<ClientType | string, ProjectCreateForm['dataS
user: 'sa',
password: 'Password123.',
database: '_test',
ssl: {
ca: '',
key: '',
cert: '',
},
},
[ClientType.SQLITE]: {
client: ClientType.SQLITE,
@ -129,11 +109,6 @@ const sampleConnectionData: Record<ClientType | string, ProjectCreateForm['dataS
user: 'root',
password: '',
database: '_test',
ssl: {
ca: '',
key: '',
cert: '',
},
},
yugabyte: {
host: defaultHost,
@ -141,11 +116,6 @@ const sampleConnectionData: Record<ClientType | string, ProjectCreateForm['dataS
user: 'postgres',
password: '',
database: '_test',
ssl: {
ca: '',
key: '',
cert: '',
},
},
citusdb: {
host: defaultHost,
@ -153,11 +123,6 @@ const sampleConnectionData: Record<ClientType | string, ProjectCreateForm['dataS
user: 'postgres',
password: '',
database: '_test',
ssl: {
ca: '',
key: '',
cert: '',
},
},
cockroachdb: {
host: defaultHost,
@ -165,11 +130,6 @@ const sampleConnectionData: Record<ClientType | string, ProjectCreateForm['dataS
user: 'postgres',
password: '',
database: '_test',
ssl: {
ca: '',
key: '',
cert: '',
},
},
greenplum: {
host: defaultHost,
@ -177,11 +137,6 @@ const sampleConnectionData: Record<ClientType | string, ProjectCreateForm['dataS
user: 'postgres',
password: '',
database: '_test',
ssl: {
ca: '',
key: '',
cert: '',
},
},
oracledb: {
host: defaultHost,
@ -189,11 +144,6 @@ const sampleConnectionData: Record<ClientType | string, ProjectCreateForm['dataS
user: 'system',
password: 'Oracle18',
database: '_test',
ssl: {
ca: '',
key: '',
cert: '',
},
},
}
@ -209,4 +159,4 @@ export const getDefaultConnectionConfig = (client: ClientType): ProjectCreateFor
}
}
export const sslUsage = ['No', 'Preferred', 'Required', 'Required-CA', 'Required-IDENTITY']
export const sslUsage = ['No', 'Allowed', 'Preferred', 'Required', 'Required-CA', 'Required-IDENTITY']

Loading…
Cancel
Save