2018-09-14 01:42:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-20 10:12:48 -04:00
|
|
|
class IdeController < ApplicationController
|
2018-08-31 06:19:55 -04:00
|
|
|
layout 'fullscreen'
|
2018-03-20 10:12:48 -04:00
|
|
|
|
2020-03-12 17:09:45 -04:00
|
|
|
include ClientsidePreviewCSP
|
2020-02-22 19:09:14 -05:00
|
|
|
include StaticObjectExternalStorageCSP
|
2021-03-05 10:09:12 -05:00
|
|
|
include Gitlab::Utils::StrongMemoize
|
2020-02-22 19:09:14 -05:00
|
|
|
|
2021-07-01 17:08:38 -04:00
|
|
|
before_action :authorize_read_project!
|
|
|
|
|
2020-05-25 11:07:58 -04:00
|
|
|
before_action do
|
|
|
|
push_frontend_feature_flag(:build_service_proxy)
|
2020-07-10 08:09:15 -04:00
|
|
|
push_frontend_feature_flag(:schema_linting)
|
2022-05-06 11:09:03 -04:00
|
|
|
push_frontend_feature_flag(:reject_unsigned_commits_by_gitlab)
|
2022-08-19 20:12:08 -04:00
|
|
|
push_frontend_feature_flag(:vscode_web_ide, current_user)
|
2021-03-05 10:09:12 -05:00
|
|
|
define_index_vars
|
2020-05-25 11:07:58 -04:00
|
|
|
end
|
|
|
|
|
2020-10-05 08:08:47 -04:00
|
|
|
feature_category :web_ide
|
|
|
|
|
2022-03-22 14:08:29 -04:00
|
|
|
urgency :low
|
|
|
|
|
2018-03-20 10:12:48 -04:00
|
|
|
def index
|
2019-07-19 07:11:27 -04:00
|
|
|
Gitlab::UsageDataCounters::WebIdeCounter.increment_views_count
|
2022-06-07 05:09:00 -04:00
|
|
|
|
|
|
|
if project && Feature.enabled?(:route_hll_to_snowplow_phase2, project&.namespace)
|
|
|
|
Gitlab::Tracking.event(self.class.to_s, 'web_ide_views',
|
|
|
|
namespace: project&.namespace, user: current_user)
|
|
|
|
end
|
2018-03-20 10:12:48 -04:00
|
|
|
end
|
2021-03-05 10:09:12 -05:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2021-07-01 17:08:38 -04:00
|
|
|
def authorize_read_project!
|
|
|
|
render_404 unless can?(current_user, :read_project, project)
|
|
|
|
end
|
|
|
|
|
2021-03-05 10:09:12 -05:00
|
|
|
def define_index_vars
|
|
|
|
return unless project
|
|
|
|
|
|
|
|
@branch = params[:branch]
|
|
|
|
@path = params[:path]
|
|
|
|
@merge_request = params[:merge_request_id]
|
2021-03-22 20:09:09 -04:00
|
|
|
@fork_info = fork_info(project, @branch)
|
|
|
|
end
|
|
|
|
|
|
|
|
def fork_info(project, branch)
|
|
|
|
return if can?(current_user, :push_code, project)
|
|
|
|
|
|
|
|
existing_fork = current_user.fork_of(project)
|
2021-03-05 10:09:12 -05:00
|
|
|
|
2021-03-22 20:09:09 -04:00
|
|
|
if existing_fork
|
|
|
|
path = helpers.ide_edit_path(existing_fork, branch, '')
|
|
|
|
{ ide_path: path }
|
|
|
|
elsif can?(current_user, :fork_project, project)
|
|
|
|
path = helpers.ide_fork_and_edit_path(project, branch, '', with_notice: false)
|
|
|
|
{ fork_path: path }
|
2021-03-05 10:09:12 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def project
|
|
|
|
strong_memoize(:project) do
|
|
|
|
next unless params[:project_id].present?
|
|
|
|
|
|
|
|
Project.find_by_full_path(params[:project_id])
|
|
|
|
end
|
|
|
|
end
|
2018-03-20 10:12:48 -04:00
|
|
|
end
|