debian-mirror-gitlab/app/helpers/jira_connect_helper.rb

30 lines
912 B
Ruby
Raw Normal View History

2021-03-08 18:12:59 +05:30
# frozen_string_literal: true
module JiraConnectHelper
2021-03-11 19:13:27 +05:30
def jira_connect_app_data(subscriptions)
skip_groups = subscriptions.map(&:namespace_id)
2021-03-08 18:12:59 +05:30
{
2021-03-11 19:13:27 +05:30
groups_path: api_v4_groups_path(params: { min_access_level: Gitlab::Access::MAINTAINER, skip_groups: skip_groups }),
2021-04-29 21:17:54 +05:30
subscriptions: subscriptions.map { |s| serialize_subscription(s) }.to_json,
2021-03-11 19:13:27 +05:30
subscriptions_path: jira_connect_subscriptions_path,
users_path: current_user ? nil : jira_connect_users_path
2021-03-08 18:12:59 +05:30
}
end
2021-04-29 21:17:54 +05:30
private
def serialize_subscription(subscription)
{
group: {
name: subscription.namespace.name,
avatar_url: subscription.namespace.avatar_url,
full_name: subscription.namespace.full_name,
description: subscription.namespace.description
},
created_at: subscription.created_at,
unlink_path: jira_connect_subscription_path(subscription)
}
end
2021-03-08 18:12:59 +05:30
end