Skip to content

Commit ceccfbf

Browse files
author
Guillaume Chau
committed
feat(ui): recent projects in top bar dropdown
1 parent d5a2407 commit ceccfbf

File tree

5 files changed

+37
-0
lines changed

5 files changed

+37
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,11 @@ async function open (id, context) {
383383
// Load plugins
384384
plugins.list(project.path, context)
385385

386+
// Date
387+
context.db.get('projects').find({ id }).assign({
388+
openDate: Date.now()
389+
}).write()
390+
386391
// Save for next time
387392
context.db.set('config.lastOpenProject', id).write()
388393

packages/@vue/cli-ui/apollo-server/schema/project.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type Project {
3333
plugins: [Plugin]
3434
tasks: [Task]
3535
homepage: String
36+
openDate: JSON
3637
}
3738
3839
enum ProjectType {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
"top-bar": {
164164
"no-favorites": "No favorite projects",
165165
"favorite-projects": "Favorite projects",
166+
"recent-projects": "Recent projects",
166167
"homepage": "Home page"
167168
},
168169
"view-badge": {

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
icon-right="arrow_drop_down"
88
button-class="flat round"
99
>
10+
<!-- Current project options -->
11+
1012
<template v-if="projectCurrent">
1113
<VueSwitch
1214
:value="projectCurrent.favorite"
@@ -34,6 +36,8 @@
3436

3537
<div class="dropdown-separator"/>
3638

39+
<!-- Favorites -->
40+
3741
<div v-if="!favoriteProjects.length" class="vue-ui-empty">{{ $t('org.vue.components.top-bar.no-favorites') }}</div>
3842

3943
<template v-else>
@@ -50,6 +54,24 @@
5054
/>
5155
</template>
5256

57+
<!-- Recents -->
58+
59+
<template v-if="recentProjects.length">
60+
<div class="dropdown-separator"/>
61+
62+
<div class="section-title">
63+
{{ $t('org.vue.components.top-bar.recent-projects') }}
64+
</div>
65+
66+
<VueDropdownButton
67+
v-for="project of recentProjects"
68+
:key="project.id"
69+
:label="project.name"
70+
icon-left="restore"
71+
@click="openProject(project)"
72+
/>
73+
</template>
74+
5375
<div class="dropdown-separator"/>
5476

5577
<VueDropdownButton
@@ -92,6 +114,13 @@ export default {
92114
return this.projects.filter(
93115
p => p.favorite && (!this.projectCurrent || this.projectCurrent.id !== p.id)
94116
)
117+
},
118+
119+
recentProjects () {
120+
if (!this.projects) return []
121+
return this.projects.filter(
122+
p => !p.favorite && (!this.projectCurrent || this.projectCurrent.id !== p.id)
123+
).sort((a, b) => b.openDate - a.openDate).slice(0, 3)
95124
}
96125
},
97126

packages/@vue/cli-ui/src/graphql/projectFragment.gql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ fragment project on Project {
55
path
66
favorite
77
homepage
8+
openDate
89
}

0 commit comments

Comments
 (0)