2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
2018-05-09 12:01:36 +05:30
module Gitlab
module Ci
module Status
module Build
class Manual < Status :: Extended
2022-06-21 17:19:12 +05:30
def self . matches? ( build , user )
build . playable?
end
2018-05-09 12:01:36 +05:30
def illustration
{
image : 'illustrations/manual_action.svg' ,
size : 'svg-394' ,
title : _ ( 'This job requires a manual action' ) ,
2022-06-21 17:19:12 +05:30
content : illustration_content
2018-05-09 12:01:36 +05:30
}
end
2022-06-21 17:19:12 +05:30
private
def illustration_content
if can? ( user , :update_build , subject )
2023-03-17 16:20:25 +05:30
manual_job_action_message
2022-06-21 17:19:12 +05:30
else
generic_permission_failure_message
end
end
2023-03-17 16:20:25 +05:30
def manual_job_action_message
if subject . retryable?
_ ( " You can modify this job's CI/CD variables before running it again. " )
else
_ ( 'This job does not start automatically and must be started manually. You can add CI/CD variables below for last-minute configuration changes before starting the job.' )
end
end
2022-06-21 17:19:12 +05:30
def generic_permission_failure_message
2023-03-17 16:20:25 +05:30
if subject . outdated_deployment?
_ ( " This deployment job does not run automatically and must be started manually, but it's older than the latest deployment, and therefore can't run. " )
else
_ ( " This job does not run automatically and must be started manually, but you do not have access to it. " )
end
2018-05-09 12:01:36 +05:30
end
end
end
end
end
end
2022-06-21 17:19:12 +05:30
Gitlab :: Ci :: Status :: Build :: Manual . prepend_mod_with ( 'Gitlab::Ci::Status::Build::Manual' )