Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 12:08:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 12:08:42 +0300
commitb76ae638462ab0f673e5915986070518dd3f9ad3 (patch)
treebdab0533383b52873be0ec0eb4d3c66598ff8b91 /app/serializers/jira_connect
parent434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff)
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'app/serializers/jira_connect')
-rw-r--r--app/serializers/jira_connect/app_data_serializer.rb28
-rw-r--r--app/serializers/jira_connect/group_entity.rb8
-rw-r--r--app/serializers/jira_connect/subscription_entity.rb11
3 files changed, 47 insertions, 0 deletions
diff --git a/app/serializers/jira_connect/app_data_serializer.rb b/app/serializers/jira_connect/app_data_serializer.rb
new file mode 100644
index 00000000000..994ff19f96e
--- /dev/null
+++ b/app/serializers/jira_connect/app_data_serializer.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+class JiraConnect::AppDataSerializer
+ include Gitlab::Routing
+ include ::API::Helpers::RelatedResourcesHelpers
+
+ def initialize(subscriptions, signed_in)
+ @subscriptions = subscriptions
+ @signed_in = signed_in
+ end
+
+ def as_json
+ skip_groups = @subscriptions.map(&:namespace_id)
+
+ {
+ groups_path: api_v4_groups_path(params: { min_access_level: Gitlab::Access::MAINTAINER, skip_groups: skip_groups }),
+ subscriptions: JiraConnect::SubscriptionEntity.represent(@subscriptions).as_json,
+ subscriptions_path: jira_connect_subscriptions_path,
+ login_path: signed_in? ? nil : jira_connect_users_path
+ }
+ end
+
+ private
+
+ def signed_in?
+ !!@signed_in
+ end
+end
diff --git a/app/serializers/jira_connect/group_entity.rb b/app/serializers/jira_connect/group_entity.rb
new file mode 100644
index 00000000000..e5a552cb9d8
--- /dev/null
+++ b/app/serializers/jira_connect/group_entity.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+class JiraConnect::GroupEntity < Grape::Entity
+ expose :name
+ expose :avatar_url
+ expose :full_name
+ expose :description
+end
diff --git a/app/serializers/jira_connect/subscription_entity.rb b/app/serializers/jira_connect/subscription_entity.rb
new file mode 100644
index 00000000000..259cd5b122f
--- /dev/null
+++ b/app/serializers/jira_connect/subscription_entity.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class JiraConnect::SubscriptionEntity < Grape::Entity
+ include Gitlab::Routing
+
+ expose :created_at
+ expose :unlink_path do |subscription|
+ jira_connect_subscription_path(subscription)
+ end
+ expose :namespace, with: JiraConnect::GroupEntity, as: :group
+end