Skip to content

Commit

Permalink
feat(ui): validate new project folder name
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed Jun 16, 2018
1 parent 3a88152 commit 8957c3a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/@vue/cli-ui/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@
"placeholder": "my-app",
"tooltip": "Change base folder",
"action": "Select this folder",
"folder-exists": "This folder already exists"
"folder-exists": "This folder already exists",
"folder-name-invalid": "Folder name invalid"
},
"manager": {
"label": "Package manager",
Expand Down
15 changes: 14 additions & 1 deletion packages/@vue/cli-ui/src/views/ProjectCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@
/>
</div>

<div
v-if="formData.folder && !folderNameValid"
class="vue-ui-text danger banner"
>
<VueIcon icon="error" class="big"/>
<span>{{ $t('views.project-create.tabs.details.form.folder.folder-name-invalid') }}</span>
</div>

<ApolloQuery
v-if="formData.folder"
:query="require('../graphql/folderExists.gql')"
Expand Down Expand Up @@ -477,8 +485,13 @@ export default {
},
computed: {
folderNameValid () {
const name = this.formData.folder
return !name.match(/[/@\s+%:]/) && encodeURIComponent(name) === name
},
detailsValid () {
return !!this.formData.folder
return !!this.formData.folder && this.folderNameValid
},
presetValid () {
Expand Down

0 comments on commit 8957c3a

Please sign in to comment.