Skip to content

Commit 5a80c24

Browse files
author
Guillaume Chau
committed
feat(ui): tasks list
1 parent 120c13d commit 5a80c24

25 files changed

+403
-26
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default {
2020
props: {
2121
title: {
2222
type: String,
23-
default: false
23+
default: null
2424
}
2525
}
2626
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export default {
115115
editingPath: false,
116116
editedPath: '',
117117
folderCurrent: {},
118-
foldersFavorite: [],
118+
foldersFavorite: []
119119
}
120120
},
121121

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default {
3535
3636
computed: {
3737
query: {
38-
get() {
38+
get () {
3939
return this.searchStore.query
4040
},
4141
set (value) {

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,14 @@ export default {
9191
await this.$apollo.mutate({
9292
mutation: CONSOLE_LOGS_CLEAR,
9393
update: store => {
94-
store.writeQuery({ query: CONSOLE_LOGS, data: { consoleLogs: [] }})
95-
store.writeQuery({ query: CONSOLE_LOG_LAST, data: { consoleLogLast: null }})
94+
store.writeQuery({
95+
query: CONSOLE_LOGS,
96+
data: { consoleLogs: [] }
97+
})
98+
store.writeQuery({
99+
query: CONSOLE_LOG_LAST,
100+
data: { consoleLogLast: null }
101+
})
96102
}
97103
})
98104
this.close()
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<template>
2+
<div class="nav-content">
3+
<NavList
4+
:items="items"
5+
>
6+
<template slot-scope="props">
7+
<slot v-bind="props"/>
8+
</template>
9+
</NavList>
10+
11+
<div class="content vue-ui-disable-scroll">
12+
<router-view/>
13+
</div>
14+
</div>
15+
</template>
16+
17+
<script>
18+
export default {
19+
props: {
20+
items: {
21+
type: Array,
22+
required: true
23+
}
24+
}
25+
}
26+
</script>
27+
28+
<style lang="stylus" scoped>
29+
@import "~@/style/imports"
30+
31+
.nav-content
32+
width 100%
33+
height 100%
34+
display grid
35+
grid-template-columns 300px 1fr
36+
grid-template-rows 1fr
37+
grid-template-areas "nav content"
38+
> .nav-list
39+
grid-area nav
40+
> .content
41+
grid-area content
42+
overflow-x hidden
43+
overflow-y auto
44+
</style>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<template>
2+
<div class="nav-list vue-ui-disable-scroll">
3+
<div class="content">
4+
<div
5+
v-for="item of items"
6+
:key="item.id"
7+
@click="currentRoute = item.route"
8+
>
9+
<slot
10+
:item="item"
11+
:selected="item.route === currentRoute"
12+
/>
13+
</div>
14+
</div>
15+
</div>
16+
</template>
17+
18+
<script>
19+
import { isSameRoute, isIncludedRoute } from '../util/route'
20+
21+
export default {
22+
props: {
23+
items: {
24+
type: Array,
25+
required: true
26+
}
27+
},
28+
29+
computed: {
30+
currentRoute: {
31+
get () {
32+
const currentRoute = this.$route
33+
const item = this.items.find(
34+
item => isIncludedRoute(currentRoute, this.$router.resolve(item.route).route)
35+
)
36+
return item && item.route
37+
},
38+
set (route) {
39+
if (!isSameRoute(this.$route, route)) {
40+
this.$router.push(route)
41+
}
42+
}
43+
}
44+
}
45+
}
46+
</script>
47+
48+
<style lang="stylus" scoped>
49+
@import "~@/style/imports"
50+
51+
.nav-list
52+
overflow-x none
53+
overflow-y auto
54+
background darken($color-light-background, 2%)
55+
</style>

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ export default {
105105
max-width 400px
106106
margin-top 24px
107107
108-
109108
&:not(.loading)
110109
.vue-ui-loading-indicator
111110
>>> .animation

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export default {
7676
data () {
7777
return {
7878
pluginDetails: null,
79-
pluginLogo:! null,
79+
pluginLogo: null,
8080
updating: false
8181
}
8282
},

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ export default {
126126
}
127127
</script>
128128

129-
130129
<style lang="stylus" scoped>
131130
@import "~@/style/imports"
132131
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<template>
2+
<div
3+
class="task-item list-item"
4+
:class="{
5+
selected
6+
}"
7+
>
8+
<div class="content">
9+
<ItemLogo
10+
icon="assignment"
11+
v-tooltip="status"
12+
/>
13+
14+
<ListItemInfo
15+
:name="task.name"
16+
:description="task.description || status"
17+
:selected="selected"
18+
/>
19+
</div>
20+
</div>
21+
</template>
22+
23+
<script>
24+
export default {
25+
props: {
26+
task: {
27+
type: Object,
28+
required: true
29+
},
30+
31+
selected: {
32+
type: Boolean,
33+
default: false
34+
}
35+
},
36+
37+
computed: {
38+
status () {
39+
return this.$t(`types.task.status.${this.task.status}`)
40+
}
41+
}
42+
}
43+
</script>
44+
45+
<style lang="stylus" scoped>
46+
@import "~@/style/imports"
47+
48+
.task-item
49+
padding $padding-item
50+
51+
.content
52+
h-box()
53+
box-center()
54+
55+
.list-item-info
56+
flex 100% 1 1
57+
width 0
58+
</style>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const cwd = require('./cwd')
2+
const folders = require('./folders')
3+
4+
let tasks = []
5+
6+
function list (context) {
7+
const file = cwd.get()
8+
const pkg = folders.readPackage(file, context)
9+
tasks = []
10+
if (pkg.scripts) {
11+
tasks = Object.keys(pkg.scripts).map(
12+
name => ({
13+
id: `${file}${name}`,
14+
name,
15+
command: pkg.scripts[name],
16+
status: 'idle'
17+
})
18+
)
19+
}
20+
return tasks
21+
}
22+
23+
function findOne (id, context) {
24+
return tasks.find(
25+
t => t.id === id
26+
)
27+
}
28+
29+
module.exports = {
30+
list,
31+
findOne
32+
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const projects = require('./connectors/projects')
1010
const progress = require('./connectors/progress')
1111
const logs = require('./connectors/logs')
1212
const plugins = require('./connectors/plugins')
13+
const tasks = require('./connectors/tasks')
1314

1415
// Prevent code from exiting server process
1516
exit.exitProcess = false
@@ -44,7 +45,9 @@ module.exports = {
4445
projectCurrent: (root, args, context) => projects.getCurrent(context),
4546
projectCreation: (root, args, context) => projects.getCreation(context),
4647
pluginInstallation: (root, args, context) => plugins.getInstallation(context),
47-
plugin: (root, { id }, context) => plugins.findOne(id, context)
48+
plugin: (root, { id }, context) => plugins.findOne(id, context),
49+
tasks: (root, args, context) => tasks.list(context),
50+
task: (root, { id }, context) => tasks.findOne(id, context)
4851
},
4952

5053
Mutation: {

packages/@vue/cli-ui/src/graphql-api/type-defs.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,21 @@ type Progress {
154154
args: [String]
155155
}
156156
157+
type Task {
158+
id: ID!
159+
status: TaskStatus!
160+
name: String!
161+
command: String!
162+
description: String
163+
}
164+
165+
enum TaskStatus {
166+
idle
167+
running
168+
done
169+
error
170+
}
171+
157172
type Query {
158173
progress (id: ID!): Progress
159174
cwd: String!
@@ -166,6 +181,8 @@ type Query {
166181
projectCreation: ProjectCreation
167182
pluginInstallation: PluginInstallation
168183
plugin (id: ID!): Plugin
184+
tasks: [Task]
185+
task (id: ID!): Task
169186
}
170187
171188
type Mutation {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#import "./taskFragment.gql"
2+
3+
query task ($id: ID!) {
4+
task (id: $id) {
5+
...task
6+
}
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fragment task on Task {
2+
id
3+
status
4+
name
5+
command
6+
description
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#import "./taskFragment.gql"
2+
3+
query tasks {
4+
tasks {
5+
...task
6+
}
7+
}

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@
9090
"plugin-update": "Updating {arg0}..."
9191
}
9292
},
93+
"types": {
94+
"task": {
95+
"status": {
96+
"idle": "Idle",
97+
"running": "Running",
98+
"done": "Done",
99+
"error": "Error"
100+
}
101+
}
102+
},
93103
"views": {
94104
"project-select": {
95105
"title": "Vue Project Manager",
@@ -223,7 +233,8 @@
223233
"title": "Project configuration"
224234
},
225235
"project-tasks": {
226-
"title": "Project tasks"
236+
"title": "Project tasks",
237+
"heading": "Scripts"
227238
}
228239
}
229240
}

packages/@vue/cli-ui/src/router.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import ProjectPlugins from './views/ProjectPlugins.vue'
77
import ProjectPluginsAdd from './views/ProjectPluginsAdd.vue'
88
import ProjectConfiguration from './views/ProjectConfiguration.vue'
99
import ProjectTasks from './views/ProjectTasks.vue'
10+
import ProjectTaskDetails from './views/ProjectTaskDetails.vue'
1011
import ProjectSelect from './views/ProjectSelect.vue'
1112
import ProjectCreate from './views/ProjectCreate.vue'
1213
import About from './views/About.vue'
@@ -48,7 +49,15 @@ const router = new Router({
4849
{
4950
path: 'tasks',
5051
name: 'project-tasks',
51-
component: ProjectTasks
52+
component: ProjectTasks,
53+
children: [
54+
{
55+
path: ':id',
56+
name: 'project-task-details',
57+
component: ProjectTaskDetails,
58+
props: true
59+
}
60+
]
5261
}
5362
]
5463
},

packages/@vue/cli-ui/src/style/main.styl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,6 @@ ansi-colors('white', $vue-ui-color-light)
9898
.no-margin-y
9999
margin-top 0
100100
margin-bottom 0
101+
102+
.fill-height
103+
height 100%

0 commit comments

Comments
 (0)