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
7d17f9dc
Commit
7d17f9dc
authored
Oct 26, 2018
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-10-26
parents
edd6fc97
91765b80
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
157 additions
and
14 deletions
+157
-14
app/assets/javascripts/vue_shared/directives/tooltip.js
app/assets/javascripts/vue_shared/directives/tooltip.js
+8
-0
changelogs/unreleased/27231-add-license-data-to-projects-endpoint.yml
...nreleased/27231-add-license-data-to-projects-endpoint.yml
+5
-0
doc/api/projects.md
doc/api/projects.md
+49
-0
lib/api/entities.rb
lib/api/entities.rb
+20
-3
lib/api/projects.rb
lib/api/projects.rb
+7
-2
spec/javascripts/vue_shared/directives/tooltip_spec.js
spec/javascripts/vue_shared/directives/tooltip_spec.js
+30
-9
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+38
-0
No files found.
app/assets/javascripts/vue_shared/directives/tooltip.js
View file @
7d17f9dc
...
...
@@ -9,6 +9,14 @@ export default {
componentUpdated
(
el
)
{
$
(
el
).
tooltip
(
'
_fixTitle
'
);
// update visible tooltips
const
tooltipInstance
=
$
(
el
).
data
(
'
bs.tooltip
'
);
const
tip
=
tooltipInstance
.
getTipElement
();
tooltipInstance
.
setElementContent
(
$
(
tip
.
querySelectorAll
(
'
.tooltip-inner
'
)),
tooltipInstance
.
getTitle
(),
);
},
unbind
(
el
)
{
...
...
changelogs/unreleased/27231-add-license-data-to-projects-endpoint.yml
0 → 100644
View file @
7d17f9dc
---
title
:
Add license data to projects endpoint
merge_request
:
21606
author
:
J.D. Bean (@jdbean)
type
:
added
doc/api/projects.md
View file @
7d17f9dc
...
...
@@ -453,6 +453,7 @@ GET /projects/:id
| --------- | ---- | -------- | ----------- |
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the project
](
README.md#namespaced-path-encoding
)
|
|
`statistics`
| boolean | no | Include project statistics |
|
`license`
| boolean | no | Include project license data |
|
`with_custom_attributes`
| boolean | no | Include
[
custom attributes
](
custom_attributes.md
)
in response (admins only) |
```
json
...
...
@@ -510,6 +511,14 @@ GET /projects/:id
},
"archived"
:
false
,
"avatar_url"
:
"http://example.com/uploads/project/avatar/3/uploads/avatar.png"
,
"license_url"
:
"http://example.com/diaspora/diaspora-client/blob/master/LICENSE"
,
"license"
:
{
"key"
:
"lgpl-3.0"
,
"name"
:
"GNU Lesser General Public License v3.0"
,
"nickname"
:
"GNU LGPLv3"
,
"html_url"
:
"http://choosealicense.com/licenses/lgpl-3.0/"
,
"source_url"
:
"http://www.gnu.org/licenses/lgpl-3.0.txt"
},
"shared_runners_enabled"
:
true
,
"forks_count"
:
0
,
"star_count"
:
0
,
...
...
@@ -576,6 +585,14 @@ If the project is a fork, and you provide a valid token to authenticate, the
"http_url_to_repo"
:
"https://gitlab.com/gitlab-org/gitlab-ce.git"
,
"web_url"
:
"https://gitlab.com/gitlab-org/gitlab-ce"
,
"avatar_url"
:
"https://assets.gitlab-static.net/uploads/-/system/project/avatar/13083/logo-extra-whitespace.png"
,
"license_url"
:
"https://gitlab.com/gitlab-org/gitlab-ce/blob/master/LICENSE"
,
"license"
:
{
"key"
:
"mit"
,
"name"
:
"MIT License"
,
"nickname"
:
null
,
"html_url"
:
"http://choosealicense.com/licenses/mit/"
,
"source_url"
:
"https://opensource.org/licenses/MIT"
,
},
"star_count"
:
3812
,
"forks_count"
:
3561
,
"last_activity_at"
:
"2018-01-02T11:40:26.570Z"
,
...
...
@@ -938,6 +955,14 @@ Example response:
"import_status"
:
"none"
,
"archived"
:
true
,
"avatar_url"
:
"http://example.com/uploads/project/avatar/3/uploads/avatar.png"
,
"license_url"
:
"http://example.com/diaspora/diaspora-client/blob/master/LICENSE"
,
"license"
:
{
"key"
:
"lgpl-3.0"
,
"name"
:
"GNU Lesser General Public License v3.0"
,
"nickname"
:
"GNU LGPLv3"
,
"html_url"
:
"http://choosealicense.com/licenses/lgpl-3.0/"
,
"source_url"
:
"http://www.gnu.org/licenses/lgpl-3.0.txt"
},
"shared_runners_enabled"
:
true
,
"forks_count"
:
0
,
"star_count"
:
1
,
...
...
@@ -1016,6 +1041,14 @@ Example response:
"import_status"
:
"none"
,
"archived"
:
true
,
"avatar_url"
:
"http://example.com/uploads/project/avatar/3/uploads/avatar.png"
,
"license_url"
:
"http://example.com/diaspora/diaspora-client/blob/master/LICENSE"
,
"license"
:
{
"key"
:
"lgpl-3.0"
,
"name"
:
"GNU Lesser General Public License v3.0"
,
"nickname"
:
"GNU LGPLv3"
,
"html_url"
:
"http://choosealicense.com/licenses/lgpl-3.0/"
,
"source_url"
:
"http://www.gnu.org/licenses/lgpl-3.0.txt"
},
"shared_runners_enabled"
:
true
,
"forks_count"
:
0
,
"star_count"
:
0
,
...
...
@@ -1134,6 +1167,14 @@ Example response:
},
"archived"
:
true
,
"avatar_url"
:
"http://example.com/uploads/project/avatar/3/uploads/avatar.png"
,
"license_url"
:
"http://example.com/diaspora/diaspora-client/blob/master/LICENSE"
,
"license"
:
{
"key"
:
"lgpl-3.0"
,
"name"
:
"GNU Lesser General Public License v3.0"
,
"nickname"
:
"GNU LGPLv3"
,
"html_url"
:
"http://choosealicense.com/licenses/lgpl-3.0/"
,
"source_url"
:
"http://www.gnu.org/licenses/lgpl-3.0.txt"
},
"shared_runners_enabled"
:
true
,
"forks_count"
:
0
,
"star_count"
:
0
,
...
...
@@ -1230,6 +1271,14 @@ Example response:
},
"archived"
:
false
,
"avatar_url"
:
"http://example.com/uploads/project/avatar/3/uploads/avatar.png"
,
"license_url"
:
"http://example.com/diaspora/diaspora-client/blob/master/LICENSE"
,
"license"
:
{
"key"
:
"lgpl-3.0"
,
"name"
:
"GNU Lesser General Public License v3.0"
,
"nickname"
:
"GNU LGPLv3"
,
"html_url"
:
"http://choosealicense.com/licenses/lgpl-3.0/"
,
"source_url"
:
"http://www.gnu.org/licenses/lgpl-3.0.txt"
},
"shared_runners_enabled"
:
true
,
"forks_count"
:
0
,
"star_count"
:
0
,
...
...
lib/api/entities.rb
View file @
7d17f9dc
...
...
@@ -160,13 +160,27 @@ module API
# (fixed in https://github.com/rails/rails/pull/25976).
project
.
tags
.
map
(
&
:name
).
sort
end
expose
:ssh_url_to_repo
,
:http_url_to_repo
,
:web_url
,
:readme_url
expose
:license_url
,
if: :license
do
|
project
|
license
=
project
.
repository
.
license_blob
if
license
Gitlab
::
Routing
.
url_helpers
.
project_blob_url
(
project
,
File
.
join
(
project
.
default_branch
,
license
.
path
))
end
end
expose
:license
,
with:
'API::Entities::LicenseBasic'
,
if: :license
do
|
project
|
project
.
repository
.
license
end
expose
:avatar_url
do
|
project
,
options
|
project
.
avatar_url
(
only_path:
false
)
end
expose
:star_count
,
:forks_count
expose
:last_activity_at
expose
:namespace
,
using:
'API::Entities::NamespaceBasic'
expose
:custom_attributes
,
using:
'API::Entities::CustomAttribute'
,
if: :with_custom_attributes
...
...
@@ -1236,11 +1250,14 @@ module API
expose
:deployable
,
using:
Entities
::
Job
end
class
License
<
Grape
::
Entity
class
License
Basic
<
Grape
::
Entity
expose
:key
,
:name
,
:nickname
expose
:popular?
,
as: :popular
expose
:url
,
as: :html_url
expose
(
:source_url
)
{
|
license
|
license
.
meta
[
'source'
]
}
end
class
License
<
LicenseBasic
expose
:popular?
,
as: :popular
expose
(
:description
)
{
|
license
|
license
.
meta
[
'description'
]
}
expose
(
:conditions
)
{
|
license
|
license
.
meta
[
'conditions'
]
}
expose
(
:permissions
)
{
|
license
|
license
.
meta
[
'permissions'
]
}
...
...
lib/api/projects.rb
View file @
7d17f9dc
...
...
@@ -116,7 +116,8 @@ module API
options
=
options
.
reverse_merge
(
with:
current_user
?
Entities
::
ProjectWithAccess
:
Entities
::
BasicProjectDetails
,
statistics:
params
[
:statistics
],
current_user:
current_user
current_user:
current_user
,
license:
false
)
options
[
:with
]
=
Entities
::
BasicProjectDetails
if
params
[
:simple
]
...
...
@@ -232,13 +233,17 @@ module API
params
do
use
:statistics_params
use
:with_custom_attributes
optional
:license
,
type:
Boolean
,
default:
false
,
desc:
'Include project license data'
end
get
":id"
do
options
=
{
with:
current_user
?
Entities
::
ProjectWithAccess
:
Entities
::
BasicProjectDetails
,
current_user:
current_user
,
user_can_admin_project:
can?
(
current_user
,
:admin_project
,
user_project
),
statistics:
params
[
:statistics
]
statistics:
params
[
:statistics
],
license:
params
[
:license
]
}
project
,
options
=
with_custom_attributes
(
user_project
,
options
)
...
...
spec/javascripts/vue_shared/directives/tooltip_spec.js
View file @
7d17f9dc
...
...
@@ -13,24 +13,45 @@ describe('Tooltip directive', () => {
describe
(
'
with a single tooltip
'
,
()
=>
{
beforeEach
(()
=>
{
const
SomeComponent
=
Vue
.
extend
({
setFixtures
(
'
<div id="dummy-element"></div>
'
);
vm
=
new
Vue
({
el
:
'
#dummy-element
'
,
directives
:
{
tooltip
,
},
template
:
`
<div
v-tooltip
title="foo">
</div>
`
,
data
()
{
return
{
tooltip
:
'
some text
'
,
};
},
template
:
'
<div v-tooltip :title="tooltip"></div>
'
,
});
vm
=
new
SomeComponent
().
$mount
();
});
it
(
'
should have tooltip plugin applied
'
,
()
=>
{
expect
(
$
(
vm
.
$el
).
data
(
'
bs.tooltip
'
)).
toBeDefined
();
});
it
(
'
displays the title as tooltip
'
,
()
=>
{
$
(
vm
.
$el
).
tooltip
(
'
show
'
);
const
tooltipElement
=
document
.
querySelector
(
'
.tooltip-inner
'
);
expect
(
tooltipElement
.
innerText
).
toContain
(
'
some text
'
);
});
it
(
'
updates a visible tooltip
'
,
done
=>
{
$
(
vm
.
$el
).
tooltip
(
'
show
'
);
const
tooltipElement
=
document
.
querySelector
(
'
.tooltip-inner
'
);
vm
.
tooltip
=
'
other text
'
;
Vue
.
nextTick
()
.
then
(()
=>
{
expect
(
tooltipElement
).
toContainText
(
'
other text
'
);
done
();
})
.
catch
(
done
.
fail
);
});
});
describe
(
'
with multiple tooltips
'
,
()
=>
{
...
...
spec/requests/api/projects_spec.rb
View file @
7d17f9dc
...
...
@@ -200,6 +200,24 @@ describe API::Projects do
expect
(
json_response
.
first
).
to
include
'statistics'
end
it
"does not include license by default"
do
get
api
(
'/projects'
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
).
not_to
include
(
'license'
,
'license_url'
)
end
it
"does not include license if requested"
do
get
api
(
'/projects'
,
user
),
license:
true
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
first
).
not_to
include
(
'license'
,
'license_url'
)
end
context
'when external issue tracker is enabled'
do
let!
(
:jira_service
)
{
create
(
:jira_service
,
project:
project
)
}
...
...
@@ -1044,6 +1062,26 @@ describe API::Projects do
})
end
it
"does not include license fields by default"
do
get
api
(
"/projects/
#{
project
.
id
}
"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
).
not_to
include
(
'license'
,
'license_url'
)
end
it
'includes license fields when requested'
do
get
api
(
"/projects/
#{
project
.
id
}
"
,
user
),
license:
true
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
[
'license'
]).
to
eq
({
'key'
=>
project
.
repository
.
license
.
key
,
'name'
=>
project
.
repository
.
license
.
name
,
'nickname'
=>
project
.
repository
.
license
.
nickname
,
'html_url'
=>
project
.
repository
.
license
.
url
,
'source_url'
=>
project
.
repository
.
license
.
meta
[
'source'
]
})
end
it
"does not include statistics by default"
do
get
api
(
"/projects/
#{
project
.
id
}
"
,
user
)
...
...
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