Browse Source

feat(gui-v2): generate random project title

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2730/head
Pranav C 2 years ago
parent
commit
e0ce002ff7
  1. 14
      packages/nc-gui-v2/package-lock.json
  2. 1
      packages/nc-gui-v2/package.json
  3. 4
      packages/nc-gui-v2/pages/projects/index/create-external.vue
  4. 9
      packages/nc-gui-v2/utils/projectCreateUtils.ts

14
packages/nc-gui-v2/package-lock.json generated

@ -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",

1
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"

4
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<HTMLInputElement>()
const keyFileInput = ref<HTMLInputElement>()
const certFileInput = ref<HTMLInputElement>()

9
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, '_')
}

Loading…
Cancel
Save