2018-08-18 07:19:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-29 22:11:36 -04:00
|
|
|
module DeployTokensHelper
|
2022-08-26 17:10:03 -04:00
|
|
|
def expand_deploy_tokens_section?(new_deploy_token, created_deploy_token)
|
|
|
|
created_deploy_token ||
|
|
|
|
new_deploy_token.errors.present? ||
|
2018-03-29 22:11:36 -04:00
|
|
|
Rails.env.test?
|
|
|
|
end
|
2018-04-05 23:02:13 -04:00
|
|
|
|
2020-09-08 11:08:41 -04:00
|
|
|
def container_registry_enabled?(group_or_project)
|
2018-04-05 23:02:13 -04:00
|
|
|
Gitlab.config.registry.enabled &&
|
2020-09-08 11:08:41 -04:00
|
|
|
can?(current_user, :read_container_image, group_or_project)
|
|
|
|
end
|
|
|
|
|
|
|
|
def packages_registry_enabled?(group_or_project)
|
|
|
|
Gitlab.config.packages.enabled &&
|
2022-08-19 14:10:17 -04:00
|
|
|
can?(current_user, :read_package, group_or_project&.packages_policy_subject)
|
2018-04-06 10:30:21 -04:00
|
|
|
end
|
2022-03-01 10:22:06 -05:00
|
|
|
|
|
|
|
def deploy_token_revoke_button_data(token:, group_or_project:)
|
|
|
|
{
|
|
|
|
token: token.to_json(only: [:id, :name]),
|
|
|
|
revoke_path: revoke_deploy_token_path(group_or_project, token)
|
|
|
|
}
|
|
|
|
end
|
2018-03-29 22:11:36 -04:00
|
|
|
end
|