Commit e2688fee authored by Stan Hu's avatar Stan Hu

Address initial review comments

parent 478730be
...@@ -17,11 +17,10 @@ class Import::BitbucketController < Import::BaseController ...@@ -17,11 +17,10 @@ class Import::BitbucketController < Import::BaseController
end end
def status def status
client = Bitbucket::Client.new(credentials) bitbucket_client = Bitbucket::Client.new(credentials)
repos = client.repos repos = bitbucket_client.repos
@repos = repos.select(&:valid?) @repos, @incompatible_repos = repos.partition { |repo| repo.valid? }
@incompatible_repos = repos.reject(&:valid?)
@already_added_projects = current_user.created_projects.where(import_type: 'bitbucket') @already_added_projects = current_user.created_projects.where(import_type: 'bitbucket')
already_added_projects_names = @already_added_projects.pluck(:import_source) already_added_projects_names = @already_added_projects.pluck(:import_source)
...@@ -36,15 +35,15 @@ class Import::BitbucketController < Import::BaseController ...@@ -36,15 +35,15 @@ class Import::BitbucketController < Import::BaseController
end end
def create def create
client = Bitbucket::Client.new(credentials) bitbucket_client = Bitbucket::Client.new(credentials)
@repo_id = params[:repo_id].to_s @repo_id = params[:repo_id].to_s
name = @repo_id.gsub('___', '/') name = @repo_id.gsub('___', '/')
repo = client.repo(name) repo = bitbucket_client.repo(name)
@project_name = params[:new_name].presence || repo.name @project_name = params[:new_name].presence || repo.name
repo_owner = repo.owner repo_owner = repo.owner
repo_owner = current_user.username if repo_owner == client.user.username repo_owner = current_user.username if repo_owner == bitbucket_client.user.username
@target_namespace = params[:new_namespace].presence || repo_owner @target_namespace = params[:new_namespace].presence || repo_owner
namespace = find_or_create_namespace(@target_namespace, repo_owner) namespace = find_or_create_namespace(@target_namespace, repo_owner)
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
- @already_added_projects.each do |project| - @already_added_projects.each do |project|
%tr{id: "project_#{project.id}", class: "#{project_status_css_class(project.import_status)}"} %tr{id: "project_#{project.id}", class: "#{project_status_css_class(project.import_status)}"}
%td %td
= link_to project.import_source, 'https://bitbucket.org/#{project.import_source}', target: '_blank' = link_to project.import_source, "https://bitbucket.org/#{project.import_source}", target: '_blank'
%td %td
= link_to project.path_with_namespace, [project.namespace.becomes(Namespace), project] = link_to project.path_with_namespace, [project.namespace.becomes(Namespace), project]
%td.job-status %td.job-status
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
- @repos.each do |repo| - @repos.each do |repo|
%tr{id: "repo_#{repo.owner}___#{repo.slug}"} %tr{id: "repo_#{repo.owner}___#{repo.slug}"}
%td %td
= link_to "#{repo.full_name}", "https://bitbucket.org/#{repo.full_name}", target: "_blank" = link_to repo.full_name, "https://bitbucket.org/#{repo.full_name}", target: "_blank"
%td.import-target %td.import-target
%fieldset.row %fieldset.row
.input-group .input-group
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
- @incompatible_repos.each do |repo| - @incompatible_repos.each do |repo|
%tr{id: "repo_#{repo.owner}___#{repo.slug}"} %tr{id: "repo_#{repo.owner}___#{repo.slug}"}
%td %td
= link_to "#{repo.full_name}", "https://bitbucket.org/#{repo.full_name}", target: '_blank' = link_to repo.full_name, "https://bitbucket.org/#{repo.full_name}", target: '_blank'
%td.import-target %td.import-target
%td.import-actions-job-status %td.import-actions-job-status
= label_tag 'Incompatible Project', nil, class: 'label label-danger' = label_tag 'Incompatible Project', nil, class: 'label label-danger'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment