From fc92738a0245f1be88250448bebd9c20e9849444 Mon Sep 17 00:00:00 2001
From: GitLab Bot
Date: Wed, 3 Jun 2020 21:08:23 +0000
Subject: Add latest changes from gitlab-org/gitlab@master
---
.../javascripts/authentication/u2f/authenticate.js | 10 ++--
app/assets/javascripts/authentication/u2f/index.js | 4 +-
.../javascripts/authentication/u2f/register.js | 2 +-
.../clusters/components/applications.vue | 23 ++++----
app/assets/javascripts/lib/utils/text_utility.js | 2 +-
.../labels/components/promote_label_modal.vue | 4 +-
.../project_selector/project_selector.vue | 15 ++----
app/assets/stylesheets/pages/pipelines.scss | 3 +-
.../container_expiration_policies/update.rb | 62 ++++++++++++++++++++++
.../types/container_expiration_policy_type.rb | 2 +-
app/graphql/types/mutation_type.rb | 1 +
.../update_service.rb | 38 +++++++++++++
app/views/admin/sessions/_two_factor_u2f.html.haml | 17 ------
app/views/admin/sessions/two_factor.html.haml | 2 +-
app/views/devise/sessions/two_factor.html.haml | 2 +-
app/views/u2f/_authenticate.html.haml | 19 +++----
app/views/u2f/_register.html.haml | 2 +-
17 files changed, 142 insertions(+), 66 deletions(-)
create mode 100644 app/graphql/mutations/container_expiration_policies/update.rb
create mode 100644 app/services/container_expiration_policies/update_service.rb
delete mode 100644 app/views/admin/sessions/_two_factor_u2f.html.haml
(limited to 'app')
diff --git a/app/assets/javascripts/authentication/u2f/authenticate.js b/app/assets/javascripts/authentication/u2f/authenticate.js
index 6244df1180e..201cd5c2e61 100644
--- a/app/assets/javascripts/authentication/u2f/authenticate.js
+++ b/app/assets/javascripts/authentication/u2f/authenticate.js
@@ -40,10 +40,10 @@ export default class U2FAuthenticate {
this.signRequests = u2fParams.sign_requests.map(request => omit(request, 'challenge'));
this.templates = {
- setup: '#js-authenticate-u2f-setup',
- inProgress: '#js-authenticate-u2f-in-progress',
- error: '#js-authenticate-u2f-error',
- authenticated: '#js-authenticate-u2f-authenticated',
+ setup: '#js-authenticate-token-2fa-setup',
+ inProgress: '#js-authenticate-token-2fa-in-progress',
+ error: '#js-authenticate-token-2fa-error',
+ authenticated: '#js-authenticate-token-2fa-authenticated',
};
}
@@ -88,7 +88,7 @@ export default class U2FAuthenticate {
error_message: error.message(),
error_code: error.errorCode,
});
- return this.container.find('#js-u2f-try-again').on('click', this.renderInProgress);
+ return this.container.find('#js-token-2fa-try-again').on('click', this.renderInProgress);
}
renderAuthenticated(deviceResponse) {
diff --git a/app/assets/javascripts/authentication/u2f/index.js b/app/assets/javascripts/authentication/u2f/index.js
index 6e0d1c308f6..f129acca1c3 100644
--- a/app/assets/javascripts/authentication/u2f/index.js
+++ b/app/assets/javascripts/authentication/u2f/index.js
@@ -5,8 +5,8 @@ export default () => {
if (!gon.u2f) return;
const u2fAuthenticate = new U2FAuthenticate(
- $('#js-authenticate-u2f'),
- '#js-login-u2f-form',
+ $('#js-authenticate-token-2fa'),
+ '#js-login-token-2fa-form',
gon.u2f,
document.querySelector('#js-login-2fa-device'),
document.querySelector('.js-2fa-form'),
diff --git a/app/assets/javascripts/authentication/u2f/register.js b/app/assets/javascripts/authentication/u2f/register.js
index f5a422727ad..52c0ce1fc04 100644
--- a/app/assets/javascripts/authentication/u2f/register.js
+++ b/app/assets/javascripts/authentication/u2f/register.js
@@ -78,7 +78,7 @@ export default class U2FRegister {
error_message: error.message(),
error_code: error.errorCode,
});
- return this.container.find('#js-u2f-try-again').on('click', this.renderSetup);
+ return this.container.find('#js-token-2fa-try-again').on('click', this.renderSetup);
}
renderRegistered(deviceResponse) {
diff --git a/app/assets/javascripts/clusters/components/applications.vue b/app/assets/javascripts/clusters/components/applications.vue
index a71244fdc13..334d6df088c 100644
--- a/app/assets/javascripts/clusters/components/applications.vue
+++ b/app/assets/javascripts/clusters/components/applications.vue
@@ -196,7 +196,7 @@ export default {
s__(`ClusterIntegration|Choose which applications to install on your Kubernetes cluster.
Helm Tiller is required to install any of the following applications.`)
}}
- {{ __('More information') }}
+ {{ __('More information') }}
@@ -306,9 +306,9 @@ export default {
generated endpoint in order to access
your application after it has been deployed.`)
}}
-
+
{{ __('More information') }}
-
+
@@ -318,9 +318,9 @@ export default {
the process of being assigned. Please check your Kubernetes
cluster or Quotas on Google Kubernetes Engine if it takes a long time.`)
}}
-
+
{{ __('More information') }}
-
+
@@ -397,11 +397,10 @@ export default {
s__(`ClusterIntegration|Issuers represent a certificate authority.
You must provide an email address for your Issuer. `)
}}
- {{ __('More information') }}{{ __('More information') }}
@@ -578,9 +577,9 @@ export default {
s__(`ClusterIntegration|Replace this with your own hostname if you want.
If you do so, point hostname to Ingress IP Address from above.`)
}}
-
+
{{ __('More information') }}
-
+
@@ -617,9 +616,7 @@ export default {
s__(`ClusterIntegration|You must have an RBAC-enabled cluster
to install Knative.`)
}}
-
- {{ __('More information') }}
-
+ {{ __('More information') }}
{{
diff --git a/app/assets/javascripts/lib/utils/text_utility.js b/app/assets/javascripts/lib/utils/text_utility.js
index 86714471823..aac58f285f0 100644
--- a/app/assets/javascripts/lib/utils/text_utility.js
+++ b/app/assets/javascripts/lib/utils/text_utility.js
@@ -168,7 +168,7 @@ export const convertToCamelCase = string =>
* @param {*} string
*/
export const convertToSnakeCase = string =>
- slugifyWithUnderscore(string.match(/([a-zA-Z][^A-Z]*)/g).join(' '));
+ slugifyWithUnderscore((string.match(/([a-zA-Z][^A-Z]*)/g) || [string]).join(' '));
/**
* Converts a sentence to lower case from the second word onwards
diff --git a/app/assets/javascripts/pages/projects/labels/components/promote_label_modal.vue b/app/assets/javascripts/pages/projects/labels/components/promote_label_modal.vue
index 2e3ed15e50f..08078fa6b62 100644
--- a/app/assets/javascripts/pages/projects/labels/components/promote_label_modal.vue
+++ b/app/assets/javascripts/pages/projects/labels/components/promote_label_modal.vue
@@ -90,9 +90,7 @@ export default {
footer-primary-button-variant="warning"
@submit="onSubmit"
>
-
- {{ title }}
-
+
{{ text }}
diff --git a/app/assets/javascripts/vue_shared/components/project_selector/project_selector.vue b/app/assets/javascripts/vue_shared/components/project_selector/project_selector.vue
index fd45ac52647..6f3f2aa0e8e 100644
--- a/app/assets/javascripts/vue_shared/components/project_selector/project_selector.vue
+++ b/app/assets/javascripts/vue_shared/components/project_selector/project_selector.vue
@@ -24,28 +24,23 @@ export default {
},
showNoResultsMessage: {
type: Boolean,
- required: false,
- default: false,
+ required: true,
},
showMinimumSearchQueryMessage: {
type: Boolean,
- required: false,
- default: false,
+ required: true,
},
showLoadingIndicator: {
type: Boolean,
- required: false,
- default: false,
+ required: true,
},
showSearchErrorMessage: {
type: Boolean,
- required: false,
- default: false,
+ required: true,
},
totalResults: {
type: Number,
- required: false,
- default: 0,
+ required: true,
},
},
data() {
diff --git a/app/assets/stylesheets/pages/pipelines.scss b/app/assets/stylesheets/pages/pipelines.scss
index 47c6a9a44ca..43d766db9e0 100644
--- a/app/assets/stylesheets/pages/pipelines.scss
+++ b/app/assets/stylesheets/pages/pipelines.scss
@@ -669,7 +669,8 @@
.ci-action-icon-container {
position: absolute;
right: 5px;
- top: 5px;
+ top: 50%;
+ transform: translateY(-50%);
// Action Icons in big pipeline-graph nodes
&.ci-action-icon-wrapper {
diff --git a/app/graphql/mutations/container_expiration_policies/update.rb b/app/graphql/mutations/container_expiration_policies/update.rb
new file mode 100644
index 00000000000..ee28f3dc81e
--- /dev/null
+++ b/app/graphql/mutations/container_expiration_policies/update.rb
@@ -0,0 +1,62 @@
+# frozen_string_literal: true
+
+module Mutations
+ module ContainerExpirationPolicies
+ class Update < Mutations::BaseMutation
+ include ResolvesProject
+
+ graphql_name 'UpdateContainerExpirationPolicy'
+
+ authorize :destroy_container_image
+
+ argument :project_path,
+ GraphQL::ID_TYPE,
+ required: true,
+ description: 'The project path where the container expiration policy is located'
+
+ argument :enabled,
+ GraphQL::BOOLEAN_TYPE,
+ required: false,
+ description: copy_field_description(Types::ContainerExpirationPolicyType, :enabled)
+
+ argument :cadence,
+ Types::ContainerExpirationPolicyCadenceEnum,
+ required: false,
+ description: copy_field_description(Types::ContainerExpirationPolicyType, :cadence)
+
+ argument :older_than,
+ Types::ContainerExpirationPolicyOlderThanEnum,
+ required: false,
+ description: copy_field_description(Types::ContainerExpirationPolicyType, :older_than)
+
+ argument :keep_n,
+ Types::ContainerExpirationPolicyKeepEnum,
+ required: false,
+ description: copy_field_description(Types::ContainerExpirationPolicyType, :keep_n)
+
+ field :container_expiration_policy,
+ Types::ContainerExpirationPolicyType,
+ null: true,
+ description: 'The container expiration policy after mutation'
+
+ def resolve(project_path:, **args)
+ project = authorized_find!(full_path: project_path)
+
+ result = ::ContainerExpirationPolicies::UpdateService
+ .new(container: project, current_user: current_user, params: args)
+ .execute
+
+ {
+ container_expiration_policy: result.payload[:container_expiration_policy],
+ errors: result.error? ? [result.message] : []
+ }
+ end
+
+ private
+
+ def find_object(full_path:)
+ resolve_project(full_path: full_path)
+ end
+ end
+ end
+end
diff --git a/app/graphql/types/container_expiration_policy_type.rb b/app/graphql/types/container_expiration_policy_type.rb
index 4b380767fbd..da53dbcbd39 100644
--- a/app/graphql/types/container_expiration_policy_type.rb
+++ b/app/graphql/types/container_expiration_policy_type.rb
@@ -10,7 +10,7 @@ module Types
field :created_at, Types::TimeType, null: false, description: 'Timestamp of when the container expiration policy was created'
field :updated_at, Types::TimeType, null: false, description: 'Timestamp of when the container expiration policy was updated'
- field :enabled, GraphQL::BOOLEAN_TYPE, null: false, description: 'Indicates if this container expiration policy is enabled'
+ field :enabled, GraphQL::BOOLEAN_TYPE, null: false, description: 'Indicates whether this container expiration policy is enabled'
field :older_than, Types::ContainerExpirationPolicyOlderThanEnum, null: true, description: 'Tags older that this will expire'
field :cadence, Types::ContainerExpirationPolicyCadenceEnum, null: false, description: 'This container expiration policy schedule'
field :keep_n, Types::ContainerExpirationPolicyKeepEnum, null: true, description: 'Number of tags to retain'
diff --git a/app/graphql/types/mutation_type.rb b/app/graphql/types/mutation_type.rb
index 590ed7e960a..a983231c78a 100644
--- a/app/graphql/types/mutation_type.rb
+++ b/app/graphql/types/mutation_type.rb
@@ -49,6 +49,7 @@ module Types
mount_mutation Mutations::JiraImport::Start
mount_mutation Mutations::DesignManagement::Upload, calls_gitaly: true
mount_mutation Mutations::DesignManagement::Delete, calls_gitaly: true
+ mount_mutation Mutations::ContainerExpirationPolicies::Update
end
end
diff --git a/app/services/container_expiration_policies/update_service.rb b/app/services/container_expiration_policies/update_service.rb
new file mode 100644
index 00000000000..2f34941d692
--- /dev/null
+++ b/app/services/container_expiration_policies/update_service.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+module ContainerExpirationPolicies
+ class UpdateService < BaseContainerService
+ include Gitlab::Utils::StrongMemoize
+
+ ALLOWED_ATTRIBUTES = %i[enabled cadence older_than keep_n name_regex name_regex_keep].freeze
+
+ def execute
+ return ServiceResponse.error(message: 'Access Denied', http_status: 403) unless allowed?
+
+ if container_expiration_policy.update(container_expiration_policy_params)
+ ServiceResponse.success(payload: { container_expiration_policy: container_expiration_policy })
+ else
+ ServiceResponse.error(
+ message: container_expiration_policy.errors.full_messages.to_sentence || 'Bad request',
+ http_status: 400
+ )
+ end
+ end
+
+ private
+
+ def container_expiration_policy
+ strong_memoize(:container_expiration_policy) do
+ @container.container_expiration_policy || @container.build_container_expiration_policy
+ end
+ end
+
+ def allowed?
+ Ability.allowed?(current_user, :destroy_container_image, @container)
+ end
+
+ def container_expiration_policy_params
+ @params.slice(*ALLOWED_ATTRIBUTES)
+ end
+ end
+end
diff --git a/app/views/admin/sessions/_two_factor_u2f.html.haml b/app/views/admin/sessions/_two_factor_u2f.html.haml
deleted file mode 100644
index 09b91d76295..00000000000
--- a/app/views/admin/sessions/_two_factor_u2f.html.haml
+++ /dev/null
@@ -1,17 +0,0 @@
-#js-authenticate-u2f
-%a.btn.btn-block.btn-info#js-login-2fa-device{ href: '#' }= _("Sign in via 2FA code")
-
-%script#js-authenticate-u2f-in-progress{ type: "text/template" }
- %p= _("Trying to communicate with your device. Plug it in (if you haven't already) and press the button on the device now.")
-
--# haml-lint:disable NoPlainNodes
-%script#js-authenticate-u2f-error{ type: "text/template" }
- %div
- %p <%= error_message %> (#{_("error code:")} <%= error_code %>)
- %a.btn.btn-block.btn-warning#js-u2f-try-again= _("Try again?")
-
-%script#js-authenticate-u2f-authenticated{ type: "text/template" }
- %div
- %p= _("We heard back from your U2F device. You have been authenticated.")
- = form_tag(admin_session_path, method: :post, id: 'js-login-u2f-form') do |f|
- = hidden_field_tag 'user[device_response]', nil, class: 'form-control', required: true, id: "js-device-response"
diff --git a/app/views/admin/sessions/two_factor.html.haml b/app/views/admin/sessions/two_factor.html.haml
index 57a3452cf35..746d57dbad1 100644
--- a/app/views/admin/sessions/two_factor.html.haml
+++ b/app/views/admin/sessions/two_factor.html.haml
@@ -12,4 +12,4 @@
- if current_user.two_factor_otp_enabled?
= render 'admin/sessions/two_factor_otp'
- if current_user.two_factor_u2f_enabled?
- = render 'admin/sessions/two_factor_u2f'
+ = render 'u2f/authenticate', render_remember_me: false, target_path: admin_session_path
diff --git a/app/views/devise/sessions/two_factor.html.haml b/app/views/devise/sessions/two_factor.html.haml
index f49cdfbf8da..126d8450568 100644
--- a/app/views/devise/sessions/two_factor.html.haml
+++ b/app/views/devise/sessions/two_factor.html.haml
@@ -14,4 +14,4 @@
= f.submit "Verify code", class: "btn btn-success"
- if @user.two_factor_u2f_enabled?
- = render "u2f/authenticate", locals: { params: params, resource: resource, resource_name: resource_name }
+ = render "u2f/authenticate", params: params, resource: resource, resource_name: resource_name, render_remember_me: true, target_path: new_user_session_path
diff --git a/app/views/u2f/_authenticate.html.haml b/app/views/u2f/_authenticate.html.haml
index 51018428b1b..6658d70df8d 100644
--- a/app/views/u2f/_authenticate.html.haml
+++ b/app/views/u2f/_authenticate.html.haml
@@ -1,18 +1,19 @@
-#js-authenticate-u2f
+#js-authenticate-token-2fa
%a.btn.btn-block.btn-info#js-login-2fa-device{ href: '#' }= _("Sign in via 2FA code")
-%script#js-authenticate-u2f-in-progress{ type: "text/template" }
+%script#js-authenticate-token-2fa-in-progress{ type: "text/template" }
%p= _("Trying to communicate with your device. Plug it in (if you haven't already) and press the button on the device now.")
-%script#js-authenticate-u2f-error{ type: "text/template" }
+%script#js-authenticate-token-2fa-error{ type: "text/template" }
%div
%p <%= error_message %> (#{_("error code:")} <%= error_code %>)
- %a.btn.btn-block.btn-warning#js-u2f-try-again= _("Try again?")
+ %a.btn.btn-block.btn-warning#js-token-2fa-try-again= _("Try again?")
-%script#js-authenticate-u2f-authenticated{ type: "text/template" }
+%script#js-authenticate-token-2fa-authenticated{ type: "text/template" }
%div
- %p= _("We heard back from your U2F device. You have been authenticated.")
- = form_tag(new_user_session_path, method: :post, id: 'js-login-u2f-form') do |f|
- - resource_params = params[resource_name].presence || params
- = hidden_field_tag 'user[remember_me]', resource_params.fetch(:remember_me, 0)
+ %p= _("We heard back from your device. You have been authenticated.")
+ = form_tag(target_path, method: :post, id: 'js-login-token-2fa-form') do |f|
+ - if render_remember_me
+ - resource_params = params[resource_name].presence || params
+ = hidden_field_tag 'user[remember_me]', resource_params.fetch(:remember_me, 0)
= hidden_field_tag 'user[device_response]', nil, class: 'form-control', required: true, id: "js-device-response"
diff --git a/app/views/u2f/_register.html.haml b/app/views/u2f/_register.html.haml
index ef3835332a7..6f3f4c4981c 100644
--- a/app/views/u2f/_register.html.haml
+++ b/app/views/u2f/_register.html.haml
@@ -25,7 +25,7 @@
%div
%p
%span <%= error_message %> (#{_("error code:")} <%= error_code %>)
- %a.btn.btn-warning#js-u2f-try-again= _("Try again?")
+ %a.btn.btn-warning#js-token-2fa-try-again= _("Try again?")
%script#js-register-u2f-registered{ type: "text/template" }
.row.append-bottom-10
--
cgit v1.2.1