diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-25 15:09:00 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-25 15:09:00 +0300 |
commit | 08d789003aa7d3ac20bd260b171b771aeffef44a (patch) | |
tree | b27cdd7d4402d7f168a804328af087e720a1c267 /app/helpers | |
parent | e2dcb7987a3502b166457b7538c8368df6ff19b0 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/builds_helper.rb | 38 | ||||
-rw-r--r-- | app/helpers/ci/builds_helper.rb | 40 | ||||
-rw-r--r-- | app/helpers/ci/variables_helper.rb | 54 | ||||
-rw-r--r-- | app/helpers/ci_variables_helper.rb | 52 |
4 files changed, 94 insertions, 90 deletions
diff --git a/app/helpers/builds_helper.rb b/app/helpers/builds_helper.rb deleted file mode 100644 index 2def3488184..00000000000 --- a/app/helpers/builds_helper.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true - -module BuildsHelper - def build_summary(build, skip: false) - if build.has_trace? - if skip - link_to _("View job log"), pipeline_job_url(build.pipeline, build) - else - build.trace.html(last_lines: 10).html_safe - end - else - _("No job log") - end - end - - def sidebar_build_class(build, current_build) - build_class = [] - build_class << 'active' if build.id === current_build.id - build_class << 'retried' if build.retried? - build_class.join(' ') - end - - def javascript_build_options - { - page_path: project_job_path(@project, @build), - build_status: @build.status, - build_stage: @build.stage, - log_state: '' - } - end - - def build_failed_issue_options - { - title: _("Job Failed #%{build_id}") % { build_id: @build.id }, - description: project_job_url(@project, @build) - } - end -end diff --git a/app/helpers/ci/builds_helper.rb b/app/helpers/ci/builds_helper.rb new file mode 100644 index 00000000000..bfdb830f2c3 --- /dev/null +++ b/app/helpers/ci/builds_helper.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +module Ci + module BuildsHelper + def build_summary(build, skip: false) + if build.has_trace? + if skip + link_to _('View job log'), pipeline_job_url(build.pipeline, build) + else + build.trace.html(last_lines: 10).html_safe + end + else + _('No job log') + end + end + + def sidebar_build_class(build, current_build) + build_class = [] + build_class << 'active' if build.id === current_build.id + build_class << 'retried' if build.retried? + build_class.join(' ') + end + + def javascript_build_options + { + page_path: project_job_path(@project, @build), + build_status: @build.status, + build_stage: @build.stage, + log_state: '' + } + end + + def build_failed_issue_options + { + title: _("Job Failed #%{build_id}") % { build_id: @build.id }, + description: project_job_url(@project, @build) + } + end + end +end diff --git a/app/helpers/ci/variables_helper.rb b/app/helpers/ci/variables_helper.rb new file mode 100644 index 00000000000..b20390d58e9 --- /dev/null +++ b/app/helpers/ci/variables_helper.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +module Ci + module VariablesHelper + def ci_variable_protected_by_default? + Gitlab::CurrentSettings.current_application_settings.protected_ci_variables + end + + def create_deploy_token_path(entity, opts = {}) + if entity.is_a?(::Group) + create_deploy_token_group_settings_repository_path(entity, opts) + else + # TODO: change this path to 'create_deploy_token_project_settings_ci_cd_path' + # See MR comment for more detail: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/27059#note_311585356 + create_deploy_token_project_settings_repository_path(entity, opts) + end + end + + def revoke_deploy_token_path(entity, token) + if entity.is_a?(::Group) + revoke_group_deploy_token_path(entity, token) + else + revoke_project_deploy_token_path(entity, token) + end + end + + def ci_variable_protected?(variable, only_key_value) + if variable && !only_key_value + variable.protected + else + ci_variable_protected_by_default? + end + end + + def ci_variable_masked?(variable, only_key_value) + if variable && !only_key_value + variable.masked + else + false + end + end + + def ci_variable_type_options + [ + %w(Variable env_var), + %w(File file) + ] + end + + def ci_variable_maskable_regex + Ci::Maskable::REGEX.inspect.sub('\\A', '^').sub('\\z', '$').sub(/^\//, '').sub(/\/[a-z]*$/, '').gsub('\/', '/') + end + end +end diff --git a/app/helpers/ci_variables_helper.rb b/app/helpers/ci_variables_helper.rb deleted file mode 100644 index cd0718c1b82..00000000000 --- a/app/helpers/ci_variables_helper.rb +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -module CiVariablesHelper - def ci_variable_protected_by_default? - Gitlab::CurrentSettings.current_application_settings.protected_ci_variables - end - - def create_deploy_token_path(entity, opts = {}) - if entity.is_a?(Group) - create_deploy_token_group_settings_repository_path(entity, opts) - else - # TODO: change this path to 'create_deploy_token_project_settings_ci_cd_path' - # See MR comment for more detail: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/27059#note_311585356 - create_deploy_token_project_settings_repository_path(entity, opts) - end - end - - def revoke_deploy_token_path(entity, token) - if entity.is_a?(Group) - revoke_group_deploy_token_path(entity, token) - else - revoke_project_deploy_token_path(entity, token) - end - end - - def ci_variable_protected?(variable, only_key_value) - if variable && !only_key_value - variable.protected - else - ci_variable_protected_by_default? - end - end - - def ci_variable_masked?(variable, only_key_value) - if variable && !only_key_value - variable.masked - else - false - end - end - - def ci_variable_type_options - [ - %w(Variable env_var), - %w(File file) - ] - end - - def ci_variable_maskable_regex - Ci::Maskable::REGEX.inspect.sub('\\A', '^').sub('\\z', '$').sub(/^\//, '').sub(/\/[a-z]*$/, '').gsub('\/', '/') - end -end |