summaryrefslogtreecommitdiff
path: root/lib/api/entities.rb
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-09-03 09:35:21 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-09-03 09:35:21 +0200
commit2436631dea9264045d8694705a95d90c30b4057d (patch)
tree53c55f8c7ec7d4695d863585fe4dc8aba4527c84 /lib/api/entities.rb
parentb3cd41b4014fa96780218f0f086de239731ec91a (diff)
parent2aaab34b67eb2a6593780eda33d501a715ef0c5f (diff)
downloadgitlab-ce-refactor/ci-config-add-logical-validation.tar.gz
Merge branch 'master' into refactor/ci-config-add-logical-validationrefactor/ci-config-add-logical-validation
* master: (414 commits) Remove suggested colors hover underline Fix markdown anchor icon interaction Fix expiration date picker after update Refactored code to rely less on IDs that could change Move CHANGELOG entry for !5858 from 8.11 to 8.12 Hides merge request section in edit project when disabled Fix a typo Change minimum Unicorns required to two Update memory requirements Added `.term-bold` declaration. Change the inline code to codeblocks for the new features doc guideline Fix GitLab import button Rename behaviour to behavior in bug issue template for consistency Convert datetime coffeescript spec to ES6 Align add button on repository view Update CHANGELOG with 8.11.4 entries. removed null return - renamed 'placeTop' to 'placeProfileAvatarsToTop' Refactor Ci::Build#raw_trace Move CHANGELOG entry to a proper version Change widths of content in MR pipeline tab ... Conflicts: lib/gitlab/ci/config/node/jobs.rb
Diffstat (limited to 'lib/api/entities.rb')
-rw-r--r--lib/api/entities.rb35
1 files changed, 32 insertions, 3 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index aaeb3d4800b..3faba79415b 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -76,15 +76,23 @@ module API
expose :owner, using: Entities::UserBasic, unless: ->(project, options) { project.group }
expose :name, :name_with_namespace
expose :path, :path_with_namespace
- expose :issues_enabled, :merge_requests_enabled, :wiki_enabled, :builds_enabled, :snippets_enabled, :container_registry_enabled
+ expose :container_registry_enabled
+
+ # Expose old field names with the new permissions methods to keep API compatible
+ expose(:issues_enabled) { |project, options| project.feature_available?(:issues, options[:user]) }
+ expose(:merge_requests_enabled) { |project, options| project.feature_available?(:merge_requests, options[:user]) }
+ expose(:wiki_enabled) { |project, options| project.feature_available?(:wiki, options[:user]) }
+ expose(:builds_enabled) { |project, options| project.feature_available?(:builds, options[:user]) }
+ expose(:snippets_enabled) { |project, options| project.feature_available?(:snippets, options[:user]) }
+
expose :created_at, :last_activity_at
- expose :shared_runners_enabled
+ expose :shared_runners_enabled, :lfs_enabled
expose :creator_id
expose :namespace
expose :forked_from_project, using: Entities::BasicProjectDetails, if: lambda{ |project, options| project.forked? }
expose :avatar_url
expose :star_count, :forks_count
- expose :open_issues_count, if: lambda { |project, options| project.issues_enabled? && project.default_issues_tracker? }
+ expose :open_issues_count, if: lambda { |project, options| project.feature_available?(:issues, options[:user]) && project.default_issues_tracker? }
expose :runners_token, if: lambda { |_project, options| options[:user_can_admin_project] }
expose :public_builds
expose :shared_with_groups do |project, options|
@@ -211,6 +219,7 @@ module API
expose :user_notes_count
expose :upvotes, :downvotes
expose :due_date
+ expose :confidential
expose :web_url do |issue, options|
Gitlab::UrlBuilder.build(issue)
@@ -232,6 +241,8 @@ module API
expose :milestone, using: Entities::Milestone
expose :merge_when_build_succeeds
expose :merge_status
+ expose :diff_head_sha, as: :sha
+ expose :merge_commit_sha
expose :subscribed do |merge_request, options|
merge_request.subscribed?(options[:current_user])
end
@@ -250,6 +261,19 @@ module API
end
end
+ class MergeRequestDiff < Grape::Entity
+ expose :id, :head_commit_sha, :base_commit_sha, :start_commit_sha,
+ :created_at, :merge_request_id, :state, :real_size
+ end
+
+ class MergeRequestDiffFull < MergeRequestDiff
+ expose :commits, using: Entities::RepoCommit
+
+ expose :diffs, using: Entities::RepoDiff do |compare, _|
+ compare.raw_diffs(all_diffs: true).to_a
+ end
+ end
+
class SSHKey < Grape::Entity
expose :id, :title, :key, :created_at
end
@@ -561,5 +585,10 @@ module API
class Template < Grape::Entity
expose :name, :content
end
+
+ class BroadcastMessage < Grape::Entity
+ expose :id, :message, :starts_at, :ends_at, :color, :font
+ expose :active?, as: :active
+ end
end
end