diff --git a/packages/nc-gui-v2/pages/projects/index/create-external.vue b/packages/nc-gui-v2/pages/projects/index/create-external.vue index efb9bd60d7..53db82dd0f 100644 --- a/packages/nc-gui-v2/pages/projects/index/create-external.vue +++ b/packages/nc-gui-v2/pages/projects/index/create-external.vue @@ -19,14 +19,12 @@ const name = ref('') const loading = ref(false) const valid = ref(false) const testSuccess = ref(true) -const projectDatasource = ref(getDefaultConnectionConfig('mysql2')) +const projectDatasource = ref() const inflection = reactive({ tableName: 'camelize', columnName: 'camelize', }) -const formState = reactive>({ dataSource: {} }) - const { $api, $e } = useNuxtApp() const toast = useToast() const { t } = useI18n() @@ -86,6 +84,8 @@ const testConnection = async () => { } } +const formState = reactive>({ dataSource: { ...getDefaultConnectionConfig('mysql2') } }) + const validators = reactive({ 'title': [ { @@ -95,13 +95,17 @@ const validators = reactive({ projectTitleValidator, ], 'dataSource.client': [fieldRequiredValidator], - 'dataSource.port': [fieldRequiredValidator], - 'dataSource.host': [fieldRequiredValidator], - 'dataSource.user': [fieldRequiredValidator], - 'dataSource.database': [fieldRequiredValidator], + 'dataSource.connection.port': [fieldRequiredValidator], + 'dataSource.connection.host': [fieldRequiredValidator], + 'dataSource.connection.user': [fieldRequiredValidator], + 'dataSource.connection.database': [fieldRequiredValidator], }) const { resetFields, validate, validateInfos } = useForm(formState, validators) + +const onClientChange = () => { + formState.dataSource = { ...getDefaultConnectionConfig(formState.dataSource.client) } +}