summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/status/build/manual.rb
blob: 0074f3675e003f7fdb4c086b06cd2cdbe57b804d (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
# frozen_string_literal: true

module Gitlab
  module Ci
    module Status
      module Build
        class Manual < Status::Extended
          def self.matches?(build, user)
            build.playable?
          end

          def illustration
            {
              image: 'illustrations/manual_action.svg',
              size: 'svg-394',
              title: _('This job requires a manual action'),
              content: illustration_content
            }
          end

          private

          def illustration_content
            if can?(user, :update_build, subject)
              _('This job requires manual intervention to start. Before starting this job, you can add variables below for last-minute configuration changes.')
            else
              generic_permission_failure_message
            end
          end

          def generic_permission_failure_message
            _("This job does not run automatically and must be started manually, but you do not have access to it.")
          end
        end
      end
    end
  end
end

Gitlab::Ci::Status::Build::Manual.prepend_mod_with('Gitlab::Ci::Status::Build::Manual')