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

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

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