Skip to content

Commit 99dc316

Browse files
author
Guillaume Chau
committed
feat(ui): import project: missing modules modal
1 parent ccde77c commit 99dc316

File tree

3 files changed

+48
-9
lines changed

3 files changed

+48
-9
lines changed

packages/@vue/cli-ui/locales/en.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,13 @@
191191
"buttons": {
192192
"create": "Create a new project here",
193193
"import": "Import this folder"
194+
},
195+
"import": {
196+
"no-modules": {
197+
"title": "Missing modules",
198+
"message": "It seems the project is missing the 'node_modules' folder. Please check you installed the dependencies before importing.",
199+
"close": "Got it"
200+
}
194201
}
195202
},
196203
"project-create": {

packages/@vue/cli-ui/src/graphql-api/connectors/projects.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,10 @@ async function create (input, context) {
332332
}
333333

334334
async function importProject (input, context) {
335+
if (!fs.existsSync(path.join(input.path, 'node_modules'))) {
336+
throw new Error('NO_MODULES')
337+
}
338+
335339
const project = {
336340
id: shortId.generate(),
337341
path: input.path,

packages/@vue/cli-ui/src/views/ProjectSelect.vue

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,27 @@
6565
v-tooltip="$t('views.about.title')"
6666
/>
6767
</div>
68+
69+
<VueModal
70+
v-if="showNoModulesModal"
71+
:title="$t('views.project-select.import.no-modules.title')"
72+
class="small no-modules-modal"
73+
@close="showNoModulesModal = false"
74+
>
75+
<div class="default-body">
76+
<div class="message">
77+
{{ $t('views.project-select.import.no-modules.message') }}
78+
</div>
79+
</div>
80+
81+
<div slot="footer" class="actions">
82+
<VueButton
83+
class="primary big"
84+
:label="$t('views.project-select.import.no-modules.close')"
85+
@click="showNoModulesModal = false"
86+
/>
87+
</div>
88+
</VueModal>
6889
</div>
6990
</template>
7091

@@ -86,7 +107,8 @@ export default {
86107
return {
87108
folderCurrent: {},
88109
tab: undefined,
89-
hideTabs: !!this.$route.query.hideTabs
110+
hideTabs: !!this.$route.query.hideTabs,
111+
showNoModulesModal: false
90112
}
91113
},
92114
@@ -111,16 +133,22 @@ export default {
111133
},
112134
113135
async importProject () {
114-
await this.$apollo.mutate({
115-
mutation: PROJECT_IMPORT,
116-
variables: {
117-
input: {
118-
path: this.folderCurrent.path
136+
try {
137+
await this.$apollo.mutate({
138+
mutation: PROJECT_IMPORT,
139+
variables: {
140+
input: {
141+
path: this.folderCurrent.path
142+
}
119143
}
120-
}
121-
})
144+
})
122145
123-
this.$router.push({ name: 'project-home' })
146+
this.$router.push({ name: 'project-home' })
147+
} catch (e) {
148+
if (e.graphQLErrors && e.graphQLErrors.some(e => e.message === 'NO_MODULES')) {
149+
this.showNoModulesModal = true
150+
}
151+
}
124152
}
125153
}
126154
}

0 commit comments

Comments
 (0)