Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
65a883a0
Commit
65a883a0
authored
Sep 04, 2017
by
kushalpandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Projects Dropdown Root App Component
parent
d90f3fe6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
157 additions
and
0 deletions
+157
-0
app/assets/javascripts/projects_dropdown/components/app.vue
app/assets/javascripts/projects_dropdown/components/app.vue
+157
-0
No files found.
app/assets/javascripts/projects_dropdown/components/app.vue
0 → 100644
View file @
65a883a0
<
script
>
import
bs
from
'
../../breakpoints
'
;
import
eventHub
from
'
../event_hub
'
;
import
loadingIcon
from
'
../../vue_shared/components/loading_icon.vue
'
;
import
projectsListFrequent
from
'
./projects_list_frequent.vue
'
;
import
projectsListSearch
from
'
./projects_list_search.vue
'
;
import
search
from
'
./search.vue
'
;
export
default
{
components
:
{
search
,
loadingIcon
,
projectsListFrequent
,
projectsListSearch
,
},
props
:
{
currentProject
:
{
type
:
Object
,
required
:
true
,
},
store
:
{
type
:
Object
,
required
:
true
,
},
service
:
{
type
:
Object
,
required
:
true
,
},
},
data
()
{
return
{
isLoadingProjects
:
false
,
isFrequentsListVisible
:
false
,
isSearchListVisible
:
false
,
isLocalStorageFailed
:
false
,
isSearchFailed
:
false
,
searchQuery
:
''
,
};
},
computed
:
{
frequentProjects
()
{
return
this
.
store
.
getFrequentProjects
();
},
searchProjects
()
{
return
this
.
store
.
getSearchedProjects
();
},
},
methods
:
{
toggleFrequentProjectsList
(
state
)
{
this
.
isLoadingProjects
=
!
state
;
this
.
isSearchListVisible
=
!
state
;
this
.
isFrequentsListVisible
=
state
;
},
toggleSearchProjectsList
(
state
)
{
this
.
isLoadingProjects
=
!
state
;
this
.
isFrequentsListVisible
=
!
state
;
this
.
isSearchListVisible
=
state
;
},
toggleLoader
(
state
)
{
this
.
isFrequentsListVisible
=
!
state
;
this
.
isSearchListVisible
=
!
state
;
this
.
isLoadingProjects
=
state
;
},
fetchFrequentProjects
()
{
const
screenSize
=
bs
.
getBreakpointSize
();
if
(
this
.
searchQuery
&&
(
screenSize
!==
'
sm
'
&&
screenSize
!==
'
xs
'
))
{
this
.
toggleSearchProjectsList
(
true
);
}
else
{
this
.
toggleLoader
(
true
);
this
.
isLocalStorageFailed
=
false
;
const
projects
=
this
.
service
.
getFrequentProjects
();
if
(
projects
)
{
this
.
toggleFrequentProjectsList
(
true
);
this
.
store
.
setFrequentProjects
(
projects
);
}
else
{
this
.
isLocalStorageFailed
=
true
;
this
.
toggleFrequentProjectsList
(
true
);
this
.
store
.
setFrequentProjects
([]);
}
}
},
fetchSearchedProjects
(
searchQuery
)
{
this
.
searchQuery
=
searchQuery
;
this
.
toggleLoader
(
true
);
this
.
service
.
getSearchedProjects
(
this
.
searchQuery
)
.
then
(
res
=>
res
.
json
())
.
then
((
results
)
=>
{
this
.
toggleSearchProjectsList
(
true
);
this
.
store
.
setSearchedProjects
(
results
);
})
.
catch
(()
=>
{
this
.
isSearchFailed
=
true
;
this
.
toggleSearchProjectsList
(
true
);
});
},
logCurrentProjectAccess
()
{
this
.
service
.
logProjectAccess
(
this
.
currentProject
);
},
handleSearchClear
()
{
this
.
searchQuery
=
''
;
this
.
toggleFrequentProjectsList
(
true
);
this
.
store
.
clearSearchedProjects
();
},
handleSearchFailure
()
{
this
.
isSearchFailed
=
true
;
this
.
toggleSearchProjectsList
(
true
);
},
},
created
()
{
if
(
this
.
currentProject
.
id
)
{
this
.
logCurrentProjectAccess
();
}
eventHub
.
$on
(
'
dropdownOpen
'
,
this
.
fetchFrequentProjects
);
eventHub
.
$on
(
'
searchProjects
'
,
this
.
fetchSearchedProjects
);
eventHub
.
$on
(
'
searchCleared
'
,
this
.
handleSearchClear
);
eventHub
.
$on
(
'
searchFailed
'
,
this
.
handleSearchFailure
);
},
beforeDestroy
()
{
eventHub
.
$off
(
'
dropdownOpen
'
,
this
.
fetchFrequentProjects
);
eventHub
.
$off
(
'
searchProjects
'
,
this
.
fetchSearchedProjects
);
eventHub
.
$off
(
'
searchCleared
'
,
this
.
handleSearchClear
);
eventHub
.
$off
(
'
searchFailed
'
,
this
.
handleSearchFailure
);
},
};
</
script
>
<
template
>
<div>
<search/>
<loading-icon
class=
"loading-animation prepend-top-20"
size=
"2"
v-if=
"isLoadingProjects"
:label=
"s__('ProjectsDropdown|Loading projects')"
/>
<div
class=
"section-header"
v-if=
"isFrequentsListVisible"
>
{{
s__
(
'
ProjectsDropdown|Frequently visited
'
)
}}
</div>
<projects-list-frequent
v-if=
"isFrequentsListVisible"
:local-storage-failed=
"isLocalStorageFailed"
:projects=
"frequentProjects"
/>
<projects-list-search
v-if=
"isSearchListVisible"
:search-failed=
"isSearchFailed"
:matcher=
"searchQuery"
:projects=
"searchProjects"
/>
</div>
</
template
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment