projectmenu: Use project displaytext and use name as fallback

This uses project displaytext instead of name when available.
Fixes #38

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2019-09-19 10:30:51 +05:30
parent 0b4b9b6c62
commit 004080540b

View File

@ -10,7 +10,7 @@
@change="changeProject" @change="changeProject"
showSearch> showSearch>
<a-select-option v-for="(project, index) in projects" :key="index"> <a-select-option v-for="(project, index) in projects" :key="index">
{{ project.name }} {{ project.displaytext || project.name }}
</a-select-option> </a-select-option>
</a-select> </a-select>
</span> </span>
@ -54,7 +54,7 @@ export default {
const currentProject = Vue.ls.get(CURRENT_PROJECT) const currentProject = Vue.ls.get(CURRENT_PROJECT)
for (var project of this.projects) { for (var project of this.projects) {
if (project.id === currentProject.id) { if (project.id === currentProject.id) {
this.selectedProject = project.name this.setSelectedProject(project)
break break
} }
} }
@ -69,9 +69,12 @@ export default {
isDisabled () { isDisabled () {
return !store.getters.apis.hasOwnProperty('listProjects') return !store.getters.apis.hasOwnProperty('listProjects')
}, },
setSelectedProject (project) {
this.selectedProject = project.displaytext || project.name
},
changeProject (index) { changeProject (index) {
const project = this.projects[index] const project = this.projects[index]
this.selectedProject = project.name this.setSelectedProject(project)
this.$store.dispatch('SetProject', project) this.$store.dispatch('SetProject', project)
this.$store.dispatch('ToggleTheme', project.id === undefined ? 'light' : 'dark') this.$store.dispatch('ToggleTheme', project.id === undefined ? 'light' : 'dark')
this.$message.success(`Switched to "${project.name}"`) this.$message.success(`Switched to "${project.name}"`)