-
Notifications
You must be signed in to change notification settings - Fork 25
/
App.vue
260 lines (252 loc) Β· 8.05 KB
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<template>
<div id="app">
<v-app :dark="darkMode">
<v-navigation-drawer
:mini-variant="miniDrawer"
v-model="drawer"
fixed
clipped
hide-overlay
app
>
<v-list-tile v-if="miniDrawer" @click.stop="miniDrawer = !miniDrawer">
<v-list-tile-action>
<v-icon>chevron_right</v-icon>
</v-list-tile-action>
</v-list-tile>
<v-list dense class="pa-1" v-if="connectedUser">
<v-list-tile avatar>
<v-list-tile-avatar>
<v-avatar size="44px">
<img v-if="connectedUser" :src="connectedUser.avatar_url">
<v-icon v-else>account_circle</v-icon>
</v-avatar>
</v-list-tile-avatar>
<v-list-tile-content>
<v-list-tile-title>{{ connectedUser.name }}</v-list-tile-title>
</v-list-tile-content>
<v-list-tile-action>
<v-btn icon @click.stop="miniDrawer = !miniDrawer">
<v-icon>chevron_left</v-icon>
</v-btn>
</v-list-tile-action>
</v-list-tile>
</v-list>
<v-list dense>
<v-list-tile v-if="isConfigured" @click="$router.push({ name: 'home' })">
<v-list-tile-action>
<v-icon>dashboard</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>
Home
</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
<v-list-tile v-if="isConfigured" @click="$router.push({ name: 'mrs' })">
<v-list-tile-action>
<v-icon>merge_type</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title class="with-badge">
Merge Requests
</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
<v-list-tile v-if="isConfigured" @click="$router.push({ name: 'issues' })">
<v-list-tile-action>
<v-icon>bug_report</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title class="with-badge">
Issues
</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
<v-list-tile v-if="isConfigured" @click="$router.push({ name: 'todo' })">
<v-list-tile-action>
<v-badge v-if="miniDrawer" right overlap>
<span slot="badge">{{todosSize}}</span>
<v-icon>list</v-icon>
</v-badge>
<v-icon v-else>list</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title class="with-badge">
<span>Todo</span>
<v-spacer/>
<v-chip v-if="todosSize" color="orange" small text-color="white">{{todosSize}}</v-chip>
</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
<v-list-tile v-if="isConfigured" @click="$router.push({ name: 'projects' })">
<v-list-tile-action>
<v-icon>lightbulb</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title class="with-badge">Projects</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
<v-list-tile v-if="isAdmin" @click="$router.push({ name: 'runners' })">
<v-list-tile-action>
<v-icon>directions_run</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title class="with-badge">
Runners
</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
<v-list>
<v-list-tile v-if="isConfigured" class="mt-3">
<v-list-tile-action>
<v-btn icon ripple @click="dialog = true">
<v-icon color="grey darken-1">add_circle_outline</v-icon>
</v-btn>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>
<span class="grey--text text--darken-1">TEAMS</span>
</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
<v-list-tile :to="`/team/${team.name}`" :active-class="(darkMode) ? `grey darken-2` : `grey lighten-4`" v-for="team in teams" :key="team.name" avatar>
<v-list-tile-avatar>
<avatar :name="team.name" :size="32"/>
</v-list-tile-avatar>
<v-list-tile-content>
<v-list-tile-title v-text="team.name"></v-list-tile-title>
</v-list-tile-content>
<v-list-tile-action>
<v-menu offset-y min-width="150">
<v-btn icon ripple slot="activator" @click.native.prevent>
<v-icon color="grey darken-1">more_vert</v-icon>
</v-btn>
<v-list>
<v-list-tile @click.prevent="deleteTeam(team)">
<v-list-tile-title>Delete</v-list-tile-title>
</v-list-tile>
</v-list>
</v-menu>
</v-list-tile-action>
</v-list-tile>
</v-list>
<v-list-tile href="https://github.com/chamerling/gitlab-teams/" target="_blank">
<v-list-tile-action>
<v-icon color="grey darken-1">info</v-icon>
</v-list-tile-action>
<v-list-tile-title class="grey--text text--darken-1">About</v-list-tile-title>
</v-list-tile>
</v-list>
</v-navigation-drawer>
<v-toolbar dark flat fixed app clipped-left dense color="orange darken-4">
<v-toolbar-side-icon @click.stop="drawer = !drawer"></v-toolbar-side-icon>
<v-toolbar-title>GitLab Teams</v-toolbar-title>
<v-spacer></v-spacer>
<user-menu v-if="connectedUser"/>
</v-toolbar>
<v-content>
<v-container class="pa-0">
<transition name="fade" mode="out-in">
<router-view/>
</transition>
</v-container>
</v-content>
<snackbar/>
<create-team-dialog :show="dialog" @close="changeDialog"></create-team-dialog>
</v-app>
</div>
</template>
<script>
import _ from "lodash";
import { mapGetters } from "vuex";
import Snackbar from "@/components/ui/Snackbar.vue";
import UserMenu from "@/components/ui/UserMenu.vue";
import Avatar from "@/components/Avatar.vue";
import CreateTeamDialog from "@/components/CreateTeamDialog.vue";
export default {
data: () => ({
drawer: null,
dialog: false
}),
methods: {
openSettings() {
this.$router.push({ name: "settings" });
},
deleteTeam(team) {
this.$store.dispatch("deleteTeam", team);
this.$router.push({ name: "home" });
},
changeDialog(dialog) {
this.dialog = dialog;
}
},
computed: {
darkMode() {
return this.$store.state.settings.darkMode;
},
isConfigured() {
return this.$store.getters.isConfigured;
},
isAdmin() {
return (
this.$store.getters.getConnectedUser &&
this.$store.getters.getConnectedUser.is_admin
);
},
teams() {
return _.orderBy(
this.$store.getters.getTeams,
[team => team.name.toLowerCase()],
"asc"
);
},
miniDrawer: {
set(mini) {
this.$store.dispatch("setMiniDrawer", mini);
},
get() {
return this.$store.state.ui.miniDrawer;
}
},
...mapGetters({
todosSize: "getTodosSize",
connectedUser: "getConnectedUser"
})
},
mounted() {
// TODO: Needs to be moved as nav guard
if (!this.isConfigured) {
this.openSettings();
} else {
// FIXME: Also need to dispatch loadCurrentUser to watchMergeRequests
this.$store.dispatch("launchUserWatchers");
}
},
components: {
Snackbar,
UserMenu,
Avatar,
CreateTeamDialog
}
};
</script>
<style scoped>
.fade-enter-active,
.fade-leave-active {
transition-duration: 0.2s;
transition-property: opacity;
transition-timing-function: ease;
}
.fade-enter,
.fade-leave-active {
opacity: 0;
}
.with-badge {
display: flex;
}
.v-chip {
margin-top: 0;
margin-bottom: 0;
}
</style>