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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
deca5ef2
Commit
deca5ef2
authored
Jun 07, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refs dropdown is now loaded async
parent
0aab84c7
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
73 additions
and
11 deletions
+73
-11
app/assets/javascripts/gl_dropdown.js.coffee
app/assets/javascripts/gl_dropdown.js.coffee
+7
-5
app/assets/javascripts/project.js.coffee
app/assets/javascripts/project.js.coffee
+35
-0
app/assets/stylesheets/framework/selects.scss
app/assets/stylesheets/framework/selects.scss
+0
-5
app/assets/stylesheets/pages/projects.scss
app/assets/stylesheets/pages/projects.scss
+6
-0
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+16
-0
app/views/shared/_ref_switcher.html.haml
app/views/shared/_ref_switcher.html.haml
+8
-1
config/routes.rb
config/routes.rb
+1
-0
No files found.
app/assets/javascripts/gl_dropdown.js.coffee
View file @
deca5ef2
...
...
@@ -58,7 +58,7 @@ class GitLabDropdownFilter
filter
:
(
search_text
)
->
data
=
@
options
.
data
()
if
data
?
if
data
?
and
not
@
options
.
filterByText
results
=
data
if
search_text
isnt
''
...
...
@@ -102,10 +102,11 @@ class GitLabDropdownFilter
$el
=
$
(
@
)
matches
=
fuzzaldrinPlus
.
match
(
$el
.
text
().
trim
(),
search_text
)
if
matches
.
length
$el
.
show
()
else
$el
.
hide
()
if
$el
.
is
(
':not(.dropdown-header)'
)
if
matches
.
length
$el
.
show
()
else
$el
.
hide
()
else
elements
.
show
()
...
...
@@ -191,6 +192,7 @@ class GitLabDropdown
if
@
options
.
filterable
@
filter
=
new
GitLabDropdownFilter
@
filterInput
,
filterInputBlur
:
@
filterInputBlur
filterByText
:
@
options
.
filterByText
remote
:
@
options
.
filterRemote
query
:
@
options
.
data
keys
:
searchFields
...
...
app/assets/javascripts/project.js.coffee
View file @
deca5ef2
...
...
@@ -19,6 +19,7 @@ class @Project
$
(
'.clone'
).
text
(
url
)
# Ref switcher
@
initRefSwitcher
()
$
(
'.project-refs-select'
).
on
'change'
,
->
$
(
@
).
parents
(
'form'
).
submit
()
...
...
@@ -50,3 +51,37 @@ class @Project
changeProject
:
(
url
)
->
window
.
location
=
url
initRefSwitcher
:
->
$
(
'.js-project-refs-dropdown'
).
each
->
$dropdown
=
$
(
@
)
selected
=
$dropdown
.
data
(
'selected'
)
$dropdown
.
glDropdown
(
data
:
(
term
,
callback
)
->
$
.
ajax
(
url
:
$dropdown
.
data
(
'refs-url'
)
).
done
(
refs
)
->
callback
(
refs
)
selectable
:
true
filterable
:
true
filterByText
:
true
fieldName
:
'ref'
renderRow
:
(
ref
)
->
if
ref
.
header
?
"<li class='dropdown-header'>
#{
ref
.
header
}
</li>"
else
isActiveClass
=
if
ref
is
selected
then
'is-active'
else
''
"<li>
<a href='#' data-ref='
#{
ref
}
' class='
#{
isActiveClass
}
'>
#{
ref
}
</a>
</li>"
id
:
(
obj
,
$el
)
->
$el
.
data
(
'ref'
)
toggleLabel
:
(
obj
,
$el
)
->
$el
.
text
().
trim
()
clicked
:
(
e
)
->
$dropdown
.
closest
(
'form'
).
submit
()
)
app/assets/stylesheets/framework/selects.scss
View file @
deca5ef2
...
...
@@ -165,11 +165,6 @@
background-size
:
16px
16px
!
important
;
}
/** Branch/tag selector **/
.project-refs-form
.select2-container
{
width
:
160px
!
important
;
}
.select2-results
.select2-no-results
,
.select2-results
.select2-searching
,
.select2-results
.select2-ajax-error
,
...
...
app/assets/stylesheets/pages/projects.scss
View file @
deca5ef2
...
...
@@ -616,3 +616,9 @@ pre.light-well {
color
:
$gl-text-green
;
}
}
.project-refs-form
{
.dropdown-menu
{
width
:
300px
;
}
}
app/controllers/projects_controller.rb
View file @
deca5ef2
...
...
@@ -251,6 +251,22 @@ class ProjectsController < Projects::ApplicationController
}
end
def
refs
repository
=
@project
.
repository
options
=
{
'Branches'
=>
repository
.
branch_names
,
'Tags'
=>
VersionSorter
.
rsort
(
repository
.
tag_names
)
}
# If reference is commit id - we should add it to branch/tag selectbox
if
@ref
&&
!
options
.
flatten
.
include?
(
@ref
)
&&
@ref
=~
/\A[0-9a-zA-Z]{6,52}\z/
options
<<
{
'Commits'
=>
@ref
}
end
render
json:
options
.
to_json
end
private
def
determine_layout
...
...
app/views/shared/_ref_switcher.html.haml
View file @
deca5ef2
=
form_tag
switch_namespace_project_refs_path
(
@project
.
namespace
,
@project
),
method: :get
,
class:
"project-refs-form"
do
=
select_tag
"ref"
,
grouped_options_refs
,
class:
"project-refs-select select2 select2-sm"
=
hidden_field_tag
:destination
,
destination
-
if
defined?
(
path
)
=
hidden_field_tag
:path
,
path
-
@options
&&
@options
.
each
do
|
key
,
value
|
=
hidden_field_tag
key
,
value
,
id:
nil
.dropdown
=
dropdown_toggle
@ref
||
@project
.
default_branch
,
{
toggle:
"dropdown"
,
selected:
@ref
||
@project
.
default_branch
,
refs_url:
refs_namespace_project_path
(
@project
.
namespace
,
@project
)
},
{
toggle_class:
"js-project-refs-dropdown"
}
.dropdown-menu.dropdown-menu-selectable
=
dropdown_title
"Switch branch/tag"
=
dropdown_filter
"Search branches and tags"
=
dropdown_content
=
dropdown_loading
-# = select_tag "ref", grouped_options_refs, class: "project-refs-select select2 select2-sm"
config/routes.rb
View file @
deca5ef2
...
...
@@ -479,6 +479,7 @@ Rails.application.routes.draw do
get
:download_export
get
:autocomplete_sources
get
:activity
get
:refs
end
scope
module: :projects
do
...
...
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