diff --git a/app/controllers/ide_controller.rb b/app/controllers/ide_controller.rb index 1ff25a453981b35a16c7cdee92f7f29e3ed56fda..a9056b234c4ed2dc583067cb4bd8b88e4bf3b86f 100644 --- a/app/controllers/ide_controller.rb +++ b/app/controllers/ide_controller.rb @@ -1,6 +1,14 @@ class IdeController < ApplicationController layout 'nav_only' + before_action :check_ide_available! + def index end + + private + + def check_ide_available! + render_404 unless License.feature_available?(:ide) + end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f78880312bce578baea1339a9fe881814aa873f7..8de3882d06913171cf48ee6b68f3c3aecbedd69c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -310,8 +310,8 @@ def collapsed_sidebar? cookies["sidebar_collapsed"] == "true" end - def show_new_ide? - cookies["new_repo"] == "true" && body_data_page != 'projects:show' + def show_new_ide?(project) + cookies["new_repo"] == "true" && body_data_page != 'projects:show' && project.feature_available?(:ide) end def locale_path diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index a6e1de6ffdc97bfce543b9af51fa4a2344482f29..da3b4941fc64a6269e6d601d202c4408a09d7a3d 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -52,7 +52,7 @@ def ide_edit_text end def ide_blob_link(project = @project, ref = @ref, path = @path, options = {}) - return unless show_new_ide? + return unless show_new_ide?(project) blob = options.delete(:blob) blob ||= project.repository.blob_at(ref, path) rescue nil diff --git a/app/views/profiles/preferences/show.html.haml b/app/views/profiles/preferences/show.html.haml index 66d1d1e8d44e19bed09de26ac0f2851c143bed05..e2a112700e8ef64254ffc9bd2eacda4d764e09e2 100644 --- a/app/views/profiles/preferences/show.html.haml +++ b/app/views/profiles/preferences/show.html.haml @@ -3,6 +3,8 @@ = render 'profiles/head' = form_for @user, url: profile_preferences_path, remote: true, method: :put, html: { class: 'row prepend-top-default js-preferences-form' } do |f| + = render "profiles/preferences/ide", f: f + .col-lg-4.application-theme %h4.prepend-top-0 GitLab navigation theme diff --git a/app/views/projects/tree/_tree_header.html.haml b/app/views/projects/tree/_tree_header.html.haml index 2f829b60eb502249636328600e3d3e22538615c0..f6446305c1d6e874bfe3ba1c0782ea72e8daf0e4 100644 --- a/app/views/projects/tree/_tree_header.html.haml +++ b/app/views/projects/tree/_tree_header.html.haml @@ -68,7 +68,7 @@ #{ _('New tag') } .tree-controls - - if show_new_ide? + - if show_new_ide?(@project) = succeed " " do = link_to ide_edit_path(@project, @id), class: 'btn btn-default' do = ide_edit_text diff --git a/app/views/shared/_ref_switcher.html.haml b/app/views/shared/_ref_switcher.html.haml index 479bd2cdb38c225c96b6c35457c0866295dfc6cb..6eda2b6c18fdec7a66408cfb6cda1409edc95acb 100644 --- a/app/views/shared/_ref_switcher.html.haml +++ b/app/views/shared/_ref_switcher.html.haml @@ -1,6 +1,6 @@ - show_create = local_assigns.fetch(:show_create, false) -- show_new_branch_form = show_new_ide? && show_create && can?(current_user, :push_code, @project) +- show_new_branch_form = show_new_ide?(@project) && show_create && can?(current_user, :push_code, @project) - dropdown_toggle_text = @ref || @project.default_branch = form_tag switch_project_refs_path(@project), method: :get, class: "project-refs-form" do = hidden_field_tag :destination, destination diff --git a/ee/app/models/license.rb b/ee/app/models/license.rb index ff0e9357885e2058c8d5ac1372b458e2abb12d3e..60ad3a51fae31fd31e75a1d527f45cb6a3b8e3ee 100644 --- a/ee/app/models/license.rb +++ b/ee/app/models/license.rb @@ -57,6 +57,7 @@ class License < ActiveRecord::Base sast_container dast epics + ide ].freeze # List all features available for early adopters, diff --git a/ee/app/views/profiles/preferences/_ide.html.haml b/ee/app/views/profiles/preferences/_ide.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..3aeb024ab05f331ce41db7c0d44492457729ff3a --- /dev/null +++ b/ee/app/views/profiles/preferences/_ide.html.haml @@ -0,0 +1,20 @@ +- if License.feature_available?(:ide) + .col-lg-4 + %h4.prepend-top-0 + Web IDE (Beta) + %p + Enable the new web IDE on this device to make it possible to open and edit multiple files with a single commit. + - if current_application_settings.should_check_namespace_plan? + Available for public GitLab.com projects or those using Gold. + .col-lg-8.multi-file-editor-options + = label_tag do + .preview.append-bottom-10= image_tag "multi-editor-off.png" + = f.radio_button :multi_file, "off", checked: true + Off + = label_tag do + .preview.append-bottom-10= image_tag "multi-editor-on.png" + = f.radio_button :multi_file, "on", checked: false + On + + .col-sm-12 + %hr diff --git a/spec/features/profiles/user_visits_profile_preferences_page_spec.rb b/spec/features/profiles/user_visits_profile_preferences_page_spec.rb index 90d6841af0ef11886e6b8df689ba2939e38346de..59853706a6d9be15c8d254cdd0cb73e49afedec4 100644 --- a/spec/features/profiles/user_visits_profile_preferences_page_spec.rb +++ b/spec/features/profiles/user_visits_profile_preferences_page_spec.rb @@ -4,6 +4,8 @@ let(:user) { create(:user) } before do + stub_licensed_features(ide: true) + sign_in(user) visit(profile_preferences_path) diff --git a/spec/features/projects/tree/create_directory_spec.rb b/spec/features/projects/tree/create_directory_spec.rb index 0c67196f53eccc645bebda02c47118b9f256c1da..ccb307b196305d2b10b8351cdbe4dc04969d737c 100644 --- a/spec/features/projects/tree/create_directory_spec.rb +++ b/spec/features/projects/tree/create_directory_spec.rb @@ -5,6 +5,8 @@ let(:project) { create(:project, :repository) } before do + stub_licensed_features(ide: true) + project.add_master(user) sign_in(user) diff --git a/spec/features/projects/tree/create_file_spec.rb b/spec/features/projects/tree/create_file_spec.rb index 85f7318c05d0fab68497a9a03691d41f2b992671..5febe3b10d26d92018b70087d3d600bd9f7570eb 100644 --- a/spec/features/projects/tree/create_file_spec.rb +++ b/spec/features/projects/tree/create_file_spec.rb @@ -5,6 +5,8 @@ let(:project) { create(:project, :repository) } before do + stub_licensed_features(ide: true) + project.add_master(user) sign_in(user) diff --git a/spec/features/projects/tree/upload_file_spec.rb b/spec/features/projects/tree/upload_file_spec.rb index f81e8677e92f7a9e9c43c56b01ffb177a189eb3a..06eeecfaed0f7cc48011189d9762c99f9bebe555 100644 --- a/spec/features/projects/tree/upload_file_spec.rb +++ b/spec/features/projects/tree/upload_file_spec.rb @@ -7,6 +7,8 @@ let(:img_file) { File.join(Rails.root, 'spec', 'fixtures', 'dk.png') } before do + stub_licensed_features(ide: true) + project.add_master(user) sign_in(user)