debian-mirror-gitlab/app/controllers/import/github_groups_controller.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

58 lines
1.1 KiB
Ruby
Raw Normal View History

2022-11-25 23:54:43 +05:30
# frozen_string_literal: true
module Import
class GithubGroupsController < ApplicationController
include Import::GithubOauth
before_action :provider_auth, only: [:status]
feature_category :importers
PAGE_LENGTH = 25
def status
respond_to do |format|
format.json do
render json: { provider_groups: serialized_provider_groups }
end
end
end
private
def serialized_provider_groups
Import::GithubOrgSerializer.new.represent(importable_orgs)
end
def importable_orgs
client_orgs.to_a
end
def client_orgs
@client_orgs ||= client.octokit.organizations(nil, pagination_options)
end
def client
@client ||= Gitlab::GithubImport::Client.new(session[access_token_key])
end
def pagination_options
{
page: [1, params[:page].to_i].max,
per_page: PAGE_LENGTH
}
end
def auth_state_key
:"#{provider_name}_auth_state_key"
end
def access_token_key
:"#{provider_name}_access_token"
end
def provider_name
:github
end
end
end