summaryrefslogtreecommitdiff
path: root/app/controllers/ide_controller.rb
blob: ea67c76a8bc46255b0d7c84a311fad40d621ce71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# frozen_string_literal: true

class IdeController < ApplicationController
  layout 'fullscreen'

  include ClientsidePreviewCSP
  include StaticObjectExternalStorageCSP
  include Gitlab::Utils::StrongMemoize

  before_action do
    push_frontend_feature_flag(:build_service_proxy)
    push_frontend_feature_flag(:schema_linting)
    define_index_vars
  end

  feature_category :web_ide

  def index
    Gitlab::UsageDataCounters::WebIdeCounter.increment_views_count
  end

  private

  def define_index_vars
    return unless project

    @branch = params[:branch]
    @path = params[:path]
    @merge_request = params[:merge_request_id]

    unless can?(current_user, :push_code, project)
      @forked_project = ForkProjectsFinder.new(project, current_user: current_user).execute.first
    end
  end

  def project
    strong_memoize(:project) do
      next unless params[:project_id].present?

      Project.find_by_full_path(params[:project_id])
    end
  end
end