2021-01-05 07:10:36 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module JiraConnectHelper
|
2021-01-25 13:09:03 -05:00
|
|
|
def jira_connect_app_data(subscriptions)
|
|
|
|
skip_groups = subscriptions.map(&:namespace_id)
|
|
|
|
|
2021-01-18 10:10:42 -05:00
|
|
|
{
|
2021-01-25 13:09:03 -05:00
|
|
|
groups_path: api_v4_groups_path(params: { min_access_level: Gitlab::Access::MAINTAINER, skip_groups: skip_groups }),
|
2021-04-14 11:09:04 -04:00
|
|
|
subscriptions: subscriptions.map { |s| serialize_subscription(s) }.to_json,
|
2021-01-28 16:09:04 -05:00
|
|
|
subscriptions_path: jira_connect_subscriptions_path,
|
2021-12-02 04:10:59 -05:00
|
|
|
users_path: current_user ? nil : jira_connect_users_path, # users_path is used to determine if user is signed in
|
|
|
|
gitlab_user_path: current_user ? user_path(current_user) : nil
|
2021-01-18 10:10:42 -05:00
|
|
|
}
|
|
|
|
end
|
2021-04-14 11:09:04 -04:00
|
|
|
|
|
|
|
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-01-05 07:10:36 -05:00
|
|
|
end
|