Commit 90b95843 authored by Savas Vedova's avatar Savas Vedova

Merge branch '241735-add-import-options-to-projects-and-groups-dropdown' into 'master'

Add Import options to projects and groups dropdown

See merge request gitlab-org/gitlab!54749
parents 048403df a4b9b8a7
......@@ -2,6 +2,7 @@ import $ from 'jquery';
import BindInOut from '~/behaviors/bind_in_out';
import initFilePickers from '~/file_pickers';
import Group from '~/group';
import LinkedTabs from '~/lib/utils/bootstrap_linked_tabs';
import GroupPathValidator from './group_path_validator';
const parentId = $('#group_parent_id');
......@@ -12,3 +13,16 @@ BindInOut.initAll();
initFilePickers();
new Group(); // eslint-disable-line no-new
const CONTAINER_SELECTOR = '.group-edit-container .nav-tabs';
const DEFAULT_ACTION = '#create-group-pane';
// eslint-disable-next-line no-new
new LinkedTabs({
defaultAction: DEFAULT_ACTION,
parentEl: CONTAINER_SELECTOR,
hashedTabs: true,
});
if (window.location.hash) {
$(CONTAINER_SELECTOR).find(`a[href="${window.location.hash}"]`).tab('show');
}
......@@ -133,7 +133,7 @@ class Import::BulkImportsController < ApplicationController
rescue Gitlab::UrlBlocker::BlockedUrlError => e
clear_session_data
redirect_to new_group_path, alert: _('Specified URL cannot be used: "%{reason}"') % { reason: e.message }
redirect_to new_group_path(anchor: 'import-group-pane'), alert: _('Specified URL cannot be used: "%{reason}"') % { reason: e.message }
end
def allow_local_requests?
......@@ -156,7 +156,7 @@ class Import::BulkImportsController < ApplicationController
}, status: :unprocessable_entity
end
format.html do
redirect_to new_group_path
redirect_to new_group_path(anchor: 'import-group-pane')
end
end
end
......
......@@ -10,7 +10,7 @@ class Import::GitlabGroupsController < ApplicationController
def create
unless file_is_valid?(group_params[:file])
return redirect_back_or_default(options: { alert: s_('GroupImport|Unable to process group import file') })
return redirect_to new_group_path(anchor: 'import-group-pane'), alert: s_('GroupImport|Unable to process group import file')
end
group_data = group_params.except(:file).merge(
......@@ -30,9 +30,8 @@ class Import::GitlabGroupsController < ApplicationController
redirect_to group_path(group), alert: _("Group import could not be scheduled")
end
else
redirect_back_or_default(
options: { alert: s_("GroupImport|Group could not be imported: %{errors}") % { errors: group.errors.full_messages.to_sentence } }
)
redirect_to new_group_path(anchor: 'import-group-pane'),
alert: s_("GroupImport|Group could not be imported: %{errors}") % { errors: group.errors.full_messages.to_sentence }
end
end
......
= form_with url: configure_import_bulk_imports_path, class: 'group-form gl-show-field-errors' do |f|
= form_errors(@group)
.gl-border-l-solid.gl-border-r-solid.gl-border-gray-100.gl-border-1.gl-p-5
%h4.gl-display-flex
= s_('GroupsNew|Import groups from another instance of GitLab')
......
......@@ -3,8 +3,6 @@
- group_path << parent.full_path + '/' if parent
= form_with url: import_gitlab_group_path, class: 'group-form gl-show-field-errors', multipart: true do |f|
= form_errors(@group)
.gl-border-l-solid.gl-border-r-solid.gl-border-gray-100.gl-border-1.gl-p-5
%h4
= _('Import group from file')
......
......@@ -8,5 +8,11 @@
= nav_link(path: 'groups#explore') do
= link_to explore_groups_path, data: { track_label: "groups_dropdown_explore_groups", track_event: "click_link" } do
= _('Explore groups')
= nav_link(path: 'groups/new#create-group-pane', html_options: { class: 'gl-border-0 gl-border-t-1 gl-border-solid gl-border-gray-100' }) do
= link_to new_group_path(anchor: 'create-group-pane'), data: { track_label: "groups_dropdown_create_group", track_event: "click_link" } do
= _('Create group')
= nav_link(path: 'groups/new#import-group-pane') do
= link_to new_group_path(anchor: 'import-group-pane'), data: { track_label: "groups_dropdown_import_group", track_event: "click_link" } do
= _('Import group')
.frequent-items-dropdown-content
#js-groups-dropdown{ data: { user_name: current_user.username, group: group_meta } }
......@@ -11,5 +11,16 @@
= nav_link(path: 'projects#trending') do
= link_to explore_root_path, data: { track_label: "projects_dropdown_explore_projects", track_event: "click_link" } do
= _('Explore projects')
= nav_link(path: 'projects/new#blank_project',
html_options: { class: 'gl-border-0 gl-border-t-1 gl-border-solid gl-border-gray-100' },
data: { track_label: "projects_dropdown_blank_project", track_event: "click_link" }) do
= link_to new_project_path(anchor: 'blank_project') do
= _('Create blank project')
= nav_link(path: 'projects/new#import_project') do
= link_to new_project_path(anchor: 'import_project'), data: { track_label: "projects_dropdown_import_project", track_event: "click_link" } do
= _('Import project')
= nav_link(path: 'projects/new#create_from_template') do
= link_to new_project_path(anchor: 'create_from_template'), data: { track_label: "projects_dropdown_create_from_template", track_event: "click_link" } do
= _('Create from template')
.frequent-items-dropdown-content
#js-projects-dropdown{ data: { user_name: current_user.username, project: project_meta } }
---
title: Add Import options to projects and groups dropdown
merge_request: 54749
author:
type: added
......@@ -8596,6 +8596,9 @@ msgstr ""
msgid "Create and provide your GitHub %{link_start}Personal Access Token%{link_end}. You will need to select the %{code_open}repo%{code_close} scope, so we can display a list of your public and private repositories which are available to import."
msgstr ""
msgid "Create blank project"
msgstr ""
msgid "Create branch"
msgstr ""
......@@ -8623,6 +8626,9 @@ msgstr ""
msgid "Create from"
msgstr ""
msgid "Create from template"
msgstr ""
msgid "Create group"
msgstr ""
......@@ -15349,6 +15355,9 @@ msgstr ""
msgid "Import from Jira"
msgstr ""
msgid "Import group"
msgstr ""
msgid "Import group from file"
msgstr ""
......
......@@ -123,7 +123,7 @@ RSpec.describe Import::BulkImportsController do
it 'denies network request' do
get :status
expect(controller).to redirect_to(new_group_path)
expect(controller).to redirect_to(new_group_path(anchor: 'import-group-pane'))
expect(flash[:alert]).to eq('Specified URL cannot be used: "Only allowed schemes are http, https"')
end
end
......
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