diff --git a/packages/nc-gui-v2/package-lock.json b/packages/nc-gui-v2/package-lock.json index 84aba4bc92..76026dda1a 100644 --- a/packages/nc-gui-v2/package-lock.json +++ b/packages/nc-gui-v2/package-lock.json @@ -12,6 +12,7 @@ "jwt-decode": "^3.1.2", "nocodb-sdk": "file:../nocodb-sdk", "socket.io-client": "^4.5.1", + "unique-names-generator": "^4.7.1", "vue-i18n": "^9.1.10", "vue-toastification": "^2.0.0-rc.5", "vuetify": "^3.0.0-alpha.13" @@ -12986,6 +12987,14 @@ "unplugin": "^0.6.3" } }, + "node_modules/unique-names-generator": { + "version": "4.7.1", + "resolved": "https://registry.npmjs.org/unique-names-generator/-/unique-names-generator-4.7.1.tgz", + "integrity": "sha512-lMx9dX+KRmG8sq6gulYYpKWZc9RlGsgBR6aoO8Qsm3qvkSJ+3rAymr+TnV8EDMrIrwuFJ4kruzMWM/OpYzPoow==", + "engines": { + "node": ">=8" + } + }, "node_modules/unist-util-stringify-position": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-2.0.3.tgz", @@ -23859,6 +23868,11 @@ "unplugin": "^0.6.3" } }, + "unique-names-generator": { + "version": "4.7.1", + "resolved": "https://registry.npmjs.org/unique-names-generator/-/unique-names-generator-4.7.1.tgz", + "integrity": "sha512-lMx9dX+KRmG8sq6gulYYpKWZc9RlGsgBR6aoO8Qsm3qvkSJ+3rAymr+TnV8EDMrIrwuFJ4kruzMWM/OpYzPoow==" + }, "unist-util-stringify-position": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-2.0.3.tgz", diff --git a/packages/nc-gui-v2/package.json b/packages/nc-gui-v2/package.json index b1569bf160..c234caa6bf 100644 --- a/packages/nc-gui-v2/package.json +++ b/packages/nc-gui-v2/package.json @@ -18,6 +18,7 @@ "jwt-decode": "^3.1.2", "nocodb-sdk": "file:../nocodb-sdk", "socket.io-client": "^4.5.1", + "unique-names-generator": "^4.7.1", "vue-i18n": "^9.1.10", "vue-toastification": "^2.0.0-rc.5", "vuetify": "^3.0.0-alpha.13" 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 bc7cdd0e49..50b3e02e3c 100644 --- a/packages/nc-gui-v2/pages/projects/index/create-external.vue +++ b/packages/nc-gui-v2/pages/projects/index/create-external.vue @@ -9,6 +9,7 @@ import { extractSdkResponseErrorMsg } from '~/utils/errorUtils' import { clientTypes, fieldRequiredValidator, + generateUniqueName, getDefaultConnectionConfig, getTestDatabaseName, projectTitleValidator, @@ -77,6 +78,9 @@ watch( (v) => (formState.dataSource.connection.database = `${v}_noco`), ) +// generate a random project title +formState.title = generateUniqueName() + const caFileInput = ref() const keyFileInput = ref() const certFileInput = ref() diff --git a/packages/nc-gui-v2/utils/projectCreateUtils.ts b/packages/nc-gui-v2/utils/projectCreateUtils.ts index a9a5817197..a7ec2eb682 100644 --- a/packages/nc-gui-v2/utils/projectCreateUtils.ts +++ b/packages/nc-gui-v2/utils/projectCreateUtils.ts @@ -1,3 +1,4 @@ +import { adjectives, animals, starWars, uniqueNamesGenerator } from 'unique-names-generator' import type { ClientType, ProjectCreateForm } from '~/lib/types' const testDataBaseNames = { @@ -188,3 +189,11 @@ export const fieldRequiredValidator = { } export const sslUsage = ['No', 'Preferred', 'Required', 'Required-CA', 'Required-IDENTITY'] + +export const generateUniqueName = () => { + return uniqueNamesGenerator({ + dictionaries: [[starWars], [adjectives, animals]][Math.floor(Math.random() * 2)], + }) + .toLowerCase() + .replace(/[ -]/g, '_') +}