Skip to content

Commit 7a0cd08

Browse files
author
Guillaume Chau
committed
feat(ui): open project in editor
1 parent be5ec5f commit 7a0cd08

File tree

4 files changed

+46
-2
lines changed

4 files changed

+46
-2
lines changed

packages/@vue/cli-ui/apollo-server/connectors/files.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ async function openInEditor (input, context) {
1010
if (input.gitPath) {
1111
query = await git.resolveFile(input.file, context)
1212
} else {
13-
path.resolve(cwd.get(), input.file)
13+
query = path.resolve(cwd.get(), input.file)
1414
}
1515
if (input.line) {
1616
query += `:${input.line}`

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@
9393
"project-select-list-item": {
9494
"tooltips": {
9595
"favorite": "Toggle favorite",
96-
"delete": "Remove from list"
96+
"delete": "Remove from list",
97+
"open-in-editor": "Open in editor"
9798
}
9899
},
99100
"project-plugin-item": {

packages/@vue/cli-ui/src/components/ProjectSelectListItem.vue

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
@click.stop="$emit('favorite')"
1111
/>
1212
</div>
13+
1314
<div class="info">
1415
<ListItemInfo
1516
:description="project.path"
@@ -24,6 +25,7 @@
2425
</div>
2526
</ListItemInfo>
2627
</div>
28+
2729
<div class="actions">
2830
<VueButton
2931
v-if="project.homepage"
@@ -34,6 +36,14 @@
3436
v-tooltip="project.homepage"
3537
@click.stop
3638
/>
39+
40+
<VueButton
41+
class="icon-button"
42+
icon-left="open_in_browser"
43+
v-tooltip="$t('org.vue.components.project-select-list-item.tooltips.open-in-editor')"
44+
@click.stop="openInEditor()"
45+
/>
46+
3747
<VueButton
3848
class="icon-button"
3949
icon-left="close"
@@ -47,12 +57,27 @@
4757
</template>
4858

4959
<script>
60+
import OPEN_IN_EDITOR from '../graphql/fileOpenInEditor.gql'
61+
5062
export default {
5163
props: {
5264
project: {
5365
type: Object,
5466
required: true
5567
}
68+
},
69+
70+
methods: {
71+
async openInEditor () {
72+
await this.$apollo.mutate({
73+
mutation: OPEN_IN_EDITOR,
74+
variables: {
75+
input: {
76+
file: this.project.path
77+
}
78+
}
79+
})
80+
}
5681
}
5782
}
5883
</script>

packages/@vue/cli-ui/src/components/TopBar.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
{{ $t('org.vue.components.project-select-list-item.tooltips.favorite') }}
1818
</VueSwitch>
1919

20+
<VueDropdownButton
21+
:label="$t('org.vue.components.project-select-list-item.tooltips.open-in-editor')"
22+
icon-left="open_in_browser"
23+
@click="openInEditor(projectCurrent)"
24+
/>
25+
2026
<VueDropdownButton
2127
v-if="projectCurrent.homepage"
2228
:href="projectCurrent.homepage"
@@ -72,6 +78,7 @@ import PROJECT_CURRENT from '../graphql/projectCurrent.gql'
7278
import PROJECTS from '../graphql/projects.gql'
7379
import PROJECT_OPEN from '../graphql/projectOpen.gql'
7480
import PROJECT_SET_FAVORITE from '../graphql/projectSetFavorite.gql'
81+
import OPEN_IN_EDITOR from '../graphql/fileOpenInEditor.gql'
7582
7683
export default {
7784
apollo: {
@@ -112,6 +119,17 @@ export default {
112119
}
113120
})
114121
}
122+
},
123+
124+
async openInEditor (project) {
125+
await this.$apollo.mutate({
126+
mutation: OPEN_IN_EDITOR,
127+
variables: {
128+
input: {
129+
file: project.path
130+
}
131+
}
132+
})
115133
}
116134
}
117135
}

0 commit comments

Comments
 (0)