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
Jérome Perrin
gitlab-ce
Commits
ab96ca2b
Commit
ab96ca2b
authored
May 13, 2016
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dropdown implementation
parent
79620c50
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
97 additions
and
76 deletions
+97
-76
CHANGELOG
CHANGELOG
+1
-2
app/assets/javascripts/api.js.coffee
app/assets/javascripts/api.js.coffee
+17
-17
app/assets/javascripts/blob/blob_gitignore_selector.js.coffee
...assets/javascripts/blob/blob_gitignore_selector.js.coffee
+23
-28
app/assets/javascripts/blob/edit_blob.js.coffee
app/assets/javascripts/blob/edit_blob.js.coffee
+1
-1
app/assets/javascripts/gl_dropdown.js.coffee
app/assets/javascripts/gl_dropdown.js.coffee
+29
-16
app/assets/javascripts/lib/type_utility.js.coffee
app/assets/javascripts/lib/type_utility.js.coffee
+9
-0
app/helpers/blob_helper.rb
app/helpers/blob_helper.rb
+5
-5
app/models/repository.rb
app/models/repository.rb
+5
-1
app/views/projects/blob/_editor.html.haml
app/views/projects/blob/_editor.html.haml
+1
-1
lib/api/gitignores.rb
lib/api/gitignores.rb
+5
-5
spec/javascripts/project_title_spec.js.coffee
spec/javascripts/project_title_spec.js.coffee
+1
-0
No files found.
CHANGELOG
View file @
ab96ca2b
...
...
@@ -66,13 +66,12 @@ v 8.8.0 (unreleased)
- All Grape API helpers are now instrumented
- Improve Issue formatting for the Slack Service (Jeroen van Baarsen)
- Fixed advice on invalid permissions on upload path !2948 (Ludovic Perrine)
- When creating a .gitignore file a dropdown with templates will be provided
v 8.7.6
- Fix links on wiki pages for relative url setups. !4131 (Artem Sidorenko)
- Fix import from GitLab.com to a private instance failure. !4181
- Fix external imports not finding the import data. !4106
- Fix import from gitlab.com to a private instance failure
- When creating a .gitignore file a dropdown with templates will be provided
v 8.7.5
- Fix relative links in wiki pages. !4050
...
...
app/assets/javascripts/api.js.coffee
View file @
ab96ca2b
@
Api
=
groups
_p
ath
:
"/api/:version/groups.json"
group
_p
ath
:
"/api/:version/groups/:id.json"
namespaces
_p
ath
:
"/api/:version/namespaces.json"
group
_projects_p
ath
:
"/api/:version/groups/:id/projects.json"
projects
_p
ath
:
"/api/:version/projects.json"
labels
_p
ath
:
"/api/:version/projects/:id/labels"
license
_p
ath
:
"/api/:version/licenses/:key"
gitignore
text_p
ath
:
"/api/:version/gitignores/:key"
groups
P
ath
:
"/api/:version/groups.json"
group
P
ath
:
"/api/:version/groups/:id.json"
namespaces
P
ath
:
"/api/:version/namespaces.json"
group
ProjectsP
ath
:
"/api/:version/groups/:id/projects.json"
projects
P
ath
:
"/api/:version/projects.json"
labels
P
ath
:
"/api/:version/projects/:id/labels"
license
P
ath
:
"/api/:version/licenses/:key"
gitignore
P
ath
:
"/api/:version/gitignores/:key"
group
:
(
group_id
,
callback
)
->
url
=
Api
.
buildUrl
(
Api
.
group
_p
ath
)
url
=
Api
.
buildUrl
(
Api
.
group
P
ath
)
url
=
url
.
replace
(
':id'
,
group_id
)
$
.
ajax
(
...
...
@@ -23,7 +23,7 @@
# Return groups list. Filtered by query
# Only active groups retrieved
groups
:
(
query
,
skip_ldap
,
callback
)
->
url
=
Api
.
buildUrl
(
Api
.
groups
_p
ath
)
url
=
Api
.
buildUrl
(
Api
.
groups
P
ath
)
$
.
ajax
(
url
:
url
...
...
@@ -37,7 +37,7 @@
# Return namespaces list. Filtered by query
namespaces
:
(
query
,
callback
)
->
url
=
Api
.
buildUrl
(
Api
.
namespaces
_p
ath
)
url
=
Api
.
buildUrl
(
Api
.
namespaces
P
ath
)
$
.
ajax
(
url
:
url
...
...
@@ -51,7 +51,7 @@
# Return projects list. Filtered by query
projects
:
(
query
,
order
,
callback
)
->
url
=
Api
.
buildUrl
(
Api
.
projects
_p
ath
)
url
=
Api
.
buildUrl
(
Api
.
projects
P
ath
)
$
.
ajax
(
url
:
url
...
...
@@ -65,7 +65,7 @@
callback
(
projects
)
newLabel
:
(
project_id
,
data
,
callback
)
->
url
=
Api
.
buildUrl
(
Api
.
labels
_p
ath
)
url
=
Api
.
buildUrl
(
Api
.
labels
P
ath
)
url
=
url
.
replace
(
':id'
,
project_id
)
data
.
private_token
=
gon
.
api_token
...
...
@@ -81,7 +81,7 @@
# Return group projects list. Filtered by query
groupProjects
:
(
group_id
,
query
,
callback
)
->
url
=
Api
.
buildUrl
(
Api
.
group
_projects_p
ath
)
url
=
Api
.
buildUrl
(
Api
.
group
ProjectsP
ath
)
url
=
url
.
replace
(
':id'
,
group_id
)
$
.
ajax
(
...
...
@@ -96,7 +96,7 @@
# Return text for a specific license
licenseText
:
(
key
,
data
,
callback
)
->
url
=
Api
.
buildUrl
(
Api
.
license
_p
ath
).
replace
(
':key'
,
key
)
url
=
Api
.
buildUrl
(
Api
.
license
P
ath
).
replace
(
':key'
,
key
)
$
.
ajax
(
url
:
url
...
...
@@ -104,8 +104,8 @@
).
done
(
license
)
->
callback
(
license
)
git
I
gnoreText
:
(
key
,
callback
)
->
url
=
Api
.
buildUrl
(
Api
.
gitignore
text_p
ath
).
replace
(
':key'
,
key
)
git
i
gnoreText
:
(
key
,
callback
)
->
url
=
Api
.
buildUrl
(
Api
.
gitignore
P
ath
).
replace
(
':key'
,
key
)
$
.
get
url
,
(
gitignore
)
->
callback
(
gitignore
)
...
...
app/assets/javascripts/blob/blob_gitignore_selector.js.coffee
View file @
ab96ca2b
class
@
BlobGit
I
gnoreSelector
class
@
BlobGit
i
gnoreSelector
constructor
:
(
opts
)
->
{
@
dropdown
@
editor
@
wrapper
=
@
dropdown
.
parents
(
'.gitignore-selector'
)
@
fileN
ameInput
=
$
(
'#file_name'
)
@
$wrapper
=
@
dropdown
.
closest
(
'.gitignore-selector'
)
@
$filen
ameInput
=
$
(
'#file_name'
)
@
data
=
@
dropdown
.
data
(
'filenames'
)
}
=
opts
...
...
@@ -13,51 +13,46 @@ class @BlobGitIgnoreSelector
filterable
:
true
,
selectable
:
true
,
search
:
fields
:
[
'text'
]
clicked
:
@
onClick
.
bind
(
@
)
fields
:
[
'name'
]
clicked
:
@
onClick
text
:
(
gitignore
)
->
gitignore
.
name
)
@
toggleGit
I
gnoreSelector
()
@
toggleGit
i
gnoreSelector
()
@
bindEvents
()
bindEvents
:
->
@
fileN
ameInput
@
$filen
ameInput
.
on
'keyup blur'
,
(
e
)
=>
@
toggleGit
I
gnoreSelector
()
@
toggleGit
i
gnoreSelector
()
toggleGit
I
gnoreSelector
:
->
filename
=
@
fileN
ameInput
.
val
()
or
$
(
'.editor-file-name'
).
text
().
trim
()
@
wrapper
.
toggleClass
'hidden'
,
filename
isnt
'.gitignore'
toggleGit
i
gnoreSelector
:
->
filename
=
@
$filen
ameInput
.
val
()
or
$
(
'.editor-file-name'
).
text
().
trim
()
@
$
wrapper
.
toggleClass
'hidden'
,
filename
isnt
'.gitignore'
onClick
:
(
item
,
el
,
e
)
-
>
onClick
:
(
item
,
el
,
e
)
=
>
e
.
preventDefault
()
@
requestIgnoreFile
(
item
.
text
)
@
requestIgnoreFile
(
item
.
name
)
requestIgnoreFile
:
(
name
)
->
Api
.
git
I
gnoreText
name
,
@
requestIgnoreFileSuccess
.
bind
(
@
)
Api
.
git
i
gnoreText
name
,
@
requestIgnoreFileSuccess
.
bind
(
@
)
requestIgnoreFileSuccess
:
(
gitignore
)
->
@
editor
.
setValue
(
gitignore
.
content
,
-
1
)
# Move cursor position to end of file
row
=
@
editor
.
session
.
getLength
()
-
1
column
=
@
editor
.
session
.
getLine
(
row
).
length
@
editor
.
gotoLine
(
row
+
1
,
column
)
@
editor
.
setValue
(
gitignore
.
content
,
1
)
@
editor
.
focus
()
class
@
BlobGit
I
gnoreSelectors
class
@
BlobGit
i
gnoreSelectors
constructor
:
(
opts
)
->
_this
=
@
{
@
dropdowns
=
$
(
'.js-gitignore-selector'
)
@
$
dropdowns
=
$
(
'.js-gitignore-selector'
)
@
editor
}
=
opts
@
dropdowns
.
each
-
>
$dropdown
=
$
(
@
)
@
$dropdowns
.
each
(
i
,
dropdown
)
=
>
$dropdown
=
$
(
dropdown
)
new
BlobGit
I
gnoreSelector
(
new
BlobGit
i
gnoreSelector
(
dropdown
:
$dropdown
,
editor
:
_this
.
editor
editor
:
@
editor
)
app/assets/javascripts/blob/edit_blob.js.coffee
View file @
ab96ca2b
...
...
@@ -13,7 +13,7 @@ class @EditBlob
@
initModePanesAndLinks
()
new
BlobLicenseSelector
(
@
editor
)
new
BlobGit
I
gnoreSelectors
(
editor
:
@
editor
)
new
BlobGit
i
gnoreSelectors
(
editor
:
@
editor
)
initModePanesAndLinks
:
->
@
$editModePanes
=
$
(
".js-edit-mode-pane"
)
...
...
app/assets/javascripts/gl_dropdown.js.coffee
View file @
ab96ca2b
...
...
@@ -60,23 +60,36 @@ class GitLabDropdownFilter
results
=
data
if
search_text
isnt
''
# handle groups
# When data is an array of objects therefore [object Array] e.g.
# [
# { prop: 'foo' },
# { prop: 'baz' }
# ]
if
_
.
isArray
(
data
)
results
=
fuzzaldrinPlus
.
filter
(
data
,
search_text
,
key
:
@
options
.
keys
)
else
if
_
.
isObject
(
data
)
results
=
{}
for
key
,
group
of
data
tmp
=
fuzzaldrinPlus
.
filter
(
group
,
search_text
,
key
:
@
options
.
keys
)
if
tmp
.
length
results
[
key
]
=
[]
tmp
.
map
(
item
)
->
results
[
key
].
push
item
else
# If data is grouped therefore an [object Object]. e.g.
# {
# groupName1: [
# { prop: 'foo' },
# { prop: 'baz' }
# ],
# groupName2: [
# { prop: 'abc' },
# { prop: 'def' }
# ]
# }
if
gl
.
utils
.
isObject
data
results
=
{}
for
key
,
group
of
data
tmp
=
fuzzaldrinPlus
.
filter
(
group
,
search_text
,
key
:
@
options
.
keys
)
if
tmp
.
length
results
[
key
]
=
tmp
.
map
(
item
)
->
item
@
options
.
callback
results
else
...
...
@@ -250,7 +263,7 @@ class GitLabDropdown
html
=
[
@
noResults
()]
else
# Handle array groups
if
String
(
data
)
is
"[object Object]"
if
gl
.
utils
.
isObject
data
html
=
[]
for
name
,
groupData
of
data
# Add header for each group
...
...
@@ -269,7 +282,7 @@ class GitLabDropdown
@
appendMenu
(
full_html
)
renderData
:
(
data
,
group
=
false
)
->
$
.
map
data
,
(
obj
,
index
)
=>
data
.
map
(
obj
,
index
)
=>
return
@
renderItem
(
obj
,
group
,
index
)
shouldPropagate
:
(
e
)
=>
...
...
@@ -416,7 +429,7 @@ class GitLabDropdown
selectedIndex
=
el
.
data
(
'index'
)
selectedObject
=
@
renderedData
[
groupName
][
selectedIndex
]
else
selectedIndex
=
el
.
parent
(
).
index
()
selectedIndex
=
el
.
closest
(
'li'
).
index
()
selectedObject
=
@
renderedData
[
selectedIndex
]
value
=
if
@
options
.
id
then
@
options
.
id
(
selectedObject
,
el
)
else
selectedObject
.
id
...
...
app/assets/javascripts/lib/type_utility.js.coffee
0 → 100644
View file @
ab96ca2b
((
w
)
->
w
.
gl
?=
{}
w
.
gl
.
utils
?=
{}
w
.
gl
.
utils
.
isObject
=
(
obj
)
->
obj
?
and
(
obj
.
constructor
is
Object
)
)
window
app/helpers/blob_helper.rb
View file @
ab96ca2b
...
...
@@ -185,13 +185,13 @@ module BlobHelper
}
end
def
gitignore
s_for_select
return
@gitignore
s_for_select
if
defined?
(
@gitignores_for_select
)
def
gitignore
_names
return
@gitignore
_names
if
defined?
(
@gitignore_names
)
@gitignore
s_for_select
=
{
Global
:
Gitlab
::
Gitignore
.
global
.
map
{
|
v
|
{
text:
v
.
name
}
},
@gitignore
_names
=
{
Global
:
Gitlab
::
Gitignore
.
global
.
map
{
|
gitignore
|
{
name:
gitignore
.
name
}
},
# Note that the key here doesn't cover it really
Languages
:
Gitlab
::
Gitignore
.
languages_frameworks
.
map
{
|
v
|
{
text:
v
.
name
}
}
Languages
:
Gitlab
::
Gitignore
.
languages_frameworks
.
map
{
|
gitignore
|
{
name:
gitignore
.
name
}
}
}
end
end
app/models/repository.rb
View file @
ab96ca2b
...
...
@@ -245,7 +245,7 @@ class Repository
def
cache_keys
%i(size branch_names tag_names commit_count
readme version contribution_guide changelog
license_blob license_key)
license_blob license_key
gitignore
)
end
def
build_cache
...
...
@@ -256,6 +256,10 @@ class Repository
end
end
def
expire_gitignore
cache
.
expire
(
:gitignore
)
end
def
expire_tags_cache
cache
.
expire
(
:tag_names
)
@tags
=
nil
...
...
app/views/projects/blob/_editor.html.haml
View file @
ab96ca2b
...
...
@@ -17,7 +17,7 @@
=
select_tag
:license_type
,
grouped_options_for_select
(
licenses_for_select
,
@project
.
repository
.
license_key
),
include_blank:
true
,
class:
'select2 license-select'
,
data:
{
placeholder:
'Choose a license template'
,
project:
@project
.
name
,
fullname:
@project
.
namespace
.
human_name
}
.gitignore-selector.hidden
=
dropdown_tag
(
"Choose a .gitignore template"
,
options:
{
toggle_class:
'js-gitignore-selector'
,
title:
"Choose a template"
,
filter:
true
,
placeholder:
"Filter"
,
data:
{
filenames:
gitignore
s_for_select
}
}
)
=
dropdown_tag
(
"Choose a .gitignore template"
,
options:
{
toggle_class:
'js-gitignore-selector'
,
title:
"Choose a template"
,
filter:
true
,
placeholder:
"Filter"
,
data:
{
filenames:
gitignore
_names
}
}
)
.encoding-selector
=
select_tag
:encoding
,
options_for_select
([
"base64"
,
"text"
],
"text"
),
class:
'select2'
...
...
lib/api/gitignores.rb
View file @
ab96ca2b
...
...
@@ -12,15 +12,15 @@ module API
# Get the text for a specific gitignore
#
# Parameters:
#
key (required) - The key
of a license
#
name (required) - The name
of a license
#
# Example Request:
# GET /gitignores/
e
lixir
# GET /gitignores/
E
lixir
#
get
'gitignores/:
key
'
do
required_attributes!
[
:
key
]
get
'gitignores/:
name
'
do
required_attributes!
[
:
name
]
gitignore
=
Gitlab
::
Gitignore
.
find
(
params
[
:
key
])
gitignore
=
Gitlab
::
Gitignore
.
find
(
params
[
:
name
])
not_found!
(
'.gitignore'
)
unless
gitignore
present
gitignore
,
with:
Entities
::
Gitignore
...
...
spec/javascripts/project_title_spec.js.coffee
View file @
ab96ca2b
#= require bootstrap
#= require select2
#= require lib/type_utility
#= require gl_dropdown
#= require api
#= require project_select
...
...
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