Skip to content

Commit

Permalink
fix(ui): project creation not reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed Jun 16, 2018
1 parent 8957c3a commit 9efdfaf
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 8 deletions.
5 changes: 4 additions & 1 deletion packages/@vue/cli-ui/src/graphql-api/connectors/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ function removeCreator (context) {
installProgress.removeListener('log', onInstallLog)
creator = null
}
return true
}

async function getCreation (context) {
Expand Down Expand Up @@ -426,5 +427,7 @@ module.exports = {
open,
remove,
resetCwd,
setFavorite
setFavorite,
initCreator,
removeCreator
}
4 changes: 4 additions & 0 deletions packages/@vue/cli-ui/src/graphql-api/schema/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ extend type Query {
}
extend type Mutation {
projectInitCreation: ProjectCreation
projectCancelCreation: Boolean
projectCreate (input: ProjectCreateInput!): Project!
projectImport (input: ProjectImportInput!): Project!
projectOpen (id: ID!): Project!
Expand Down Expand Up @@ -80,6 +82,8 @@ exports.resolvers = {
},

Mutation: {
projectInitCreation: (root, args, context) => projects.initCreator(context),
projectCancelCreation: (root, args, context) => projects.removeCreator(context),
projectCreate: (root, { input }, context) => projects.create(input, context),
projectImport: (root, { input }, context) => projects.import(input, context),
projectOpen: (root, { id }, context) => projects.open(id, context),
Expand Down
3 changes: 3 additions & 0 deletions packages/@vue/cli-ui/src/graphql/projectCancelCreation.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mutation projectCancelCreation {
projectCancelCreation
}
7 changes: 7 additions & 0 deletions packages/@vue/cli-ui/src/graphql/projectInitCreation.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#import "./projectCreationFragment.gql"

mutation projectInitCreation {
projectInitCreation {
...projectCreation
}
}
18 changes: 12 additions & 6 deletions packages/@vue/cli-ui/src/views/ProjectCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@
:label="$t('views.project-create.tabs.details.modal.buttons.clear')"
icon-left="delete_forever"
class="danger"
@click="reset()"
/>
</div>
</VueModal>
Expand Down Expand Up @@ -425,6 +424,7 @@ import PROJECT_CREATION from '../graphql/projectCreation.gql'
import FEATURE_SET_ENABLED from '../graphql/featureSetEnabled.gql'
import PRESET_APPLY from '../graphql/presetApply.gql'
import PROJECT_CREATE from '../graphql/projectCreate.gql'
import PROJECT_CANCEL_CREATION from '../graphql/projectCancelCreation.gql'
function formDataFactory () {
return {
Expand Down Expand Up @@ -510,11 +510,11 @@ export default {
}
},
methods: {
reset () {
formData = formDataFactory()
},
beforeDestroy () {
this.cancel()
},
methods: {
async selectPreset (id) {
if (id === 'remote') {
this.showRemotePreset = true
Expand Down Expand Up @@ -571,14 +571,20 @@ export default {
}
}
})
this.reset()
this.$router.push({ name: 'project-home' })
await this.$nextTick()
} catch (e) {
// eslint-disable-next-line no-console
console.error(e)
this.debug = `ERROR: ${e}`
}
},
async cancel () {
formData = formDataFactory()
await this.$apollo.mutate({
mutation: PROJECT_CANCEL_CREATION
})
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion packages/@vue/cli-ui/src/views/ProjectSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
icon-left="add"
:label="$route.query.hideTabs ? $t('views.project-create.tabs.details.form.folder.action') : $t('views.project-select.buttons.create')"
class="big primary create-project"
:to="{ name: 'project-create' }"
@click="createProject()"
/>
</div>
</VueTab>
Expand Down Expand Up @@ -70,6 +70,7 @@

<script>
import FOLDER_CURRENT from '../graphql/folderCurrent.gql'
import PROJECT_INIT_CREATION from '../graphql/projectInitCreation.gql'
import PROJECT_IMPORT from '../graphql/projectImport.gql'
export default {
Expand Down Expand Up @@ -101,6 +102,14 @@ export default {
},
methods: {
async createProject () {
await this.$apollo.mutate({
mutation: PROJECT_INIT_CREATION
})
this.$router.push({ name: 'project-create' })
},
async importProject () {
await this.$apollo.mutate({
mutation: PROJECT_IMPORT,
Expand Down

0 comments on commit 9efdfaf

Please sign in to comment.