diff --git a/packages/nc-gui-v2/helpers/projectCreateUtils.ts b/packages/nc-gui-v2/helpers/projectCreateUtils.ts new file mode 100644 index 0000000000..9b520ff092 --- /dev/null +++ b/packages/nc-gui-v2/helpers/projectCreateUtils.ts @@ -0,0 +1,170 @@ +const testDataBaseNames = { + mysql2: null, + mysql: null, + pg: 'postgres', + oracledb: 'xe', + mssql: undefined, + sqlite3: 'a.sqlite', +} + +export type ClientType = 'mysql2' | 'mssql' | 'pg' | 'sqlite3' | 'vitess' + +export const getTestDatabaseName = (db: { client: ClientType; connection?: { database?: string } }) => { + if (db.client === 'pg') + return db.connection?.database + return testDataBaseNames[db.client] +} + +export const clientTypes = [{ + text: 'MySql', + value: 'mysql2', +}, { + text: 'MSSQL', + value: 'mssql', +}, { + text: 'PostgreSQL', + value: 'pg', +}, { + text: 'SQLite', + value: 'sqlite', +}, +] + +const homeDir = '' +const sampleConnectionData = { + pg: { + host: 'localhost', + port: '5432', + user: 'postgres', + password: 'password', + database: '_test', + ssl: { + ca: '', + key: '', + cert: '', + }, + }, + mysql2: { + host: 'localhost', + port: '3306', + user: 'root', + password: 'password', + database: '_test', + ssl: { + ca: '', + key: '', + cert: '', + }, + }, + vitess: { + host: 'localhost', + port: '15306', + user: 'root', + password: 'password', + database: '_test', + ssl: { + ca: '', + key: '', + cert: '', + }, + }, + tidb: { + host: 'localhost', + port: '4000', + user: 'root', + password: '', + database: '_test', + ssl: { + ca: '', + key: '', + cert: '', + }, + }, + yugabyte: { + host: 'localhost', + port: '5432', + user: 'postgres', + password: '', + database: '_test', + ssl: { + ca: '', + key: '', + cert: '', + }, + }, + citusdb: { + host: 'localhost', + port: '5432', + user: 'postgres', + password: '', + database: '_test', + ssl: { + ca: '', + key: '', + cert: '', + }, + }, + cockroachdb: { + host: 'localhost', + port: '5432', + user: 'postgres', + password: '', + database: '_test', + ssl: { + ca: '', + key: '', + cert: '', + }, + }, + greenplum: { + host: 'localhost', + port: '5432', + user: 'postgres', + password: '', + database: '_test', + ssl: { + ca: '', + key: '', + cert: '', + }, + }, + mssql: { + host: 'localhost', + port: 1433, + user: 'sa', + password: 'Password123.', + database: '_test', + ssl: { + ca: '', + key: '', + cert: '', + }, + }, + oracledb: { + host: 'localhost', + port: '1521', + user: 'system', + password: 'Oracle18', + database: '_test', + ssl: { + ca: '', + key: '', + cert: '', + }, + }, + sqlite3: { + client: 'sqlite3', + database: homeDir, + connection: { + filename: homeDir, + }, + useNullAsDefault: true, + }, +} + +export const getDefaultConnectionConfig = (client: ClientType): { client: ClientType; connection: any } => { + return { + client, + connection: sampleConnectionData[client], + } +} diff --git a/packages/nc-gui-v2/pages/projects/create-external.vue b/packages/nc-gui-v2/pages/projects/create-external.vue index cc22923d5d..53e7209d32 100644 --- a/packages/nc-gui-v2/pages/projects/create-external.vue +++ b/packages/nc-gui-v2/pages/projects/create-external.vue @@ -1,48 +1,26 @@ @@ -167,9 +179,10 @@ const createProject = async () => { - + { {{ $t("general.create") }} + + + + {{ $t("activity.testDbConn") }} +