2020 <a-select
2121 class =" project-select"
2222 defaultValue =" Default View"
23- :value =" selectedProject "
23+ :value =" $store.getters.project.displaytext || $store.getters.project.name || 'Default View' "
2424 :disabled =" isDisabled()"
2525 :filterOption =" filterProject"
2626 @change =" changeProject"
27+ @focus =" fetchData"
2728 showSearch >
28- <a-icon slot =" suffixIcon" style =" font-size :14px " type =" project" />
29+
30+ <a-tooltip placement =" bottom" slot =" suffixIcon" >
31+ <template slot="title">
32+ <span >{{ $t('projects') }}</span >
33+ </template >
34+ <a-icon style =" font-size : 20px ; color : #999 ; margin-top : -5px " type =" project" />
35+ </a-tooltip >
36+
2937 <a-select-option v-for =" (project, index) in projects" :key =" index" >
3038 {{ project.displaytext || project.name }}
3139 </a-select-option >
3442</template >
3543
3644<script >
37- import Vue from ' vue'
3845import store from ' @/store'
3946import { api } from ' @/api'
40- import { CURRENT_PROJECT } from ' @/store/mutation-types'
4147
4248export default {
4349 name: ' ProjectMenu' ,
4450 data () {
4551 return {
46- visible: false ,
47- projects: [],
48- selectedProject: ' Default View'
52+ projects: []
4953 }
5054 },
5155 mounted () {
@@ -56,24 +60,15 @@ export default {
5660 if (this .isDisabled ()) {
5761 return
5862 }
59- // TODO: refactor fetching project list for project selector
60- this .projects = []
6163 var page = 1
6264 const getNextPage = () => {
6365 api (' listProjects' , { listAll: true , details: ' min' , page: page, pageSize: 500 }).then (json => {
64- if (this . projects . length === 0 ) {
65- this .projects . push ( { name: ' Default View' })
66+ if (page === 1 ) {
67+ this .projects = [ { name: ' Default View' }]
6668 }
6769 if (json && json .listprojectsresponse && json .listprojectsresponse .project ) {
6870 this .projects .push (... json .listprojectsresponse .project )
6971 }
70- const currentProject = Vue .ls .get (CURRENT_PROJECT ) || {}
71- for (var project of this .projects ) {
72- if (project && currentProject && project .id === currentProject .id ) {
73- this .setSelectedProject (project)
74- break
75- }
76- }
7772 if (this .projects .length - 1 < json .listprojectsresponse .count ) {
7873 page++
7974 getNextPage ()
@@ -85,12 +80,8 @@ export default {
8580 isDisabled () {
8681 return ! Object .prototype .hasOwnProperty .call (store .getters .apis , ' listProjects' )
8782 },
88- setSelectedProject (project ) {
89- this .selectedProject = project .displaytext || project .name
90- },
9183 changeProject (index ) {
9284 const project = this .projects [index]
93- this .setSelectedProject (project)
9485 this .$store .dispatch (' SetProject' , project)
9586 this .$store .dispatch (' ToggleTheme' , project .id === undefined ? ' light' : ' dark' )
9687 this .$message .success (` Switched to "${ project .name } "` )
0 commit comments