- page_title _("Google Code import")
- header_title _("Projects"), root_path
%h3.page-title.gl-display-flex
  .gl-display-flex.gl-align-items-center.gl-justify-content-center
    = sprite_icon('google', css_class: 'gl-mr-2')
  = _('Import projects from Google Code')

- if @repos.any?
  %p.light
    = _('Select projects you want to import.')
  %p.light
    - link_to_customize = link_to(_("customize"), new_user_map_import_google_code_path)
    = _("Optionally, you can %{link_to_customize} how Google Code email addresses and usernames are imported into GitLab.").html_safe % { link_to_customize: link_to_customize }
  %hr
  %p
  - if @incompatible_repos.any?
    = button_tag class: "btn btn-import btn-success js-import-all" do
      = _("Import all compatible projects")
      = loading_icon(css_class: 'loading-icon')
  - else
    = button_tag class: "btn btn-import btn-success js-import-all" do
      = _("Import all projects")
      = loading_icon(css_class: 'loading-icon')

.table-responsive
  %table.table.import-jobs
    %colgroup.import-jobs-from-col
    %colgroup.import-jobs-to-col
    %colgroup.import-jobs-status-col
    %thead
      %tr
        %th= _("From Google Code")
        %th= _("To GitLab")
        %th= _("Status")
    %tbody
      - @already_added_projects.each do |project|
        %tr{ id: "project_#{project.id}", class: "#{project_status_css_class(project.import_status)}" }
          %td
            = link_to project.import_source, "https://code.google.com/p/#{project.import_source}", target: "_blank", rel: 'noopener noreferrer'
          %td
            = link_to project.full_path, project
          %td.job-status
            - case project.import_status
            - when 'finished'
              %span
                = sprite_icon('check')
                = _("done")
            - when 'started'
              = loading_icon
              = _("started")
            - else
              = project.human_import_status_name

      - @repos.each do |repo|
        %tr{ id: "repo_#{repo.id}" }
          %td
            = link_to repo.name, "https://code.google.com/p/#{repo.name}", target: "_blank", rel: 'noopener noreferrer'
          %td.import-target
            #{current_user.username}/#{repo.name}
          %td.import-actions.job-status
            = button_tag class: "btn btn-import js-add-to-import" do
              = _("Import")
              = loading_icon(css_class: 'loading-icon')
      - @incompatible_repos.each do |repo|
        %tr{ id: "repo_#{repo.id}" }
          %td
            = link_to repo.name, "https://code.google.com/p/#{repo.name}", target: "_blank", rel: 'noopener noreferrer'
          %td.import-target
          %td.import-actions-job-status
            = label_tag _("Incompatible Project"), nil, class: "label badge-danger"

- if @incompatible_repos.any?
  %p
    = _("One or more of your Google Code projects cannot be imported into GitLab directly because they use Subversion or Mercurial for version control, rather than Git.")
    - link_to_import_flow = link_to(_("import flow"), new_import_google_code_path)
    = _("Please convert them to Git on Google Code, and go through the %{link_to_import_flow} again.").html_safe % { link_to_import_flow: link_to_import_flow }

.js-importer-status{ data: { jobs_import_path: "#{jobs_import_google_code_path}", import_path: "#{import_google_code_path}" } }