Commit cb83bdef authored by Shinya Maeda's avatar Shinya Maeda

Merge branch 'ali/improve-deployment-approval-error-messages' into 'master'

Improve and internationalize Deployment Approval error messages

See merge request gitlab-org/gitlab!82454
parents 3ca75a1f 3dbac553
...@@ -38,15 +38,15 @@ module Deployments ...@@ -38,15 +38,15 @@ module Deployments
end end
def validate(deployment, status) def validate(deployment, status)
return 'Unrecognized status' unless Deployments::Approval.statuses.include?(status) return _('Unrecognized approval status.') unless Deployments::Approval.statuses.include?(status)
return 'This environment is not protected' unless deployment.environment.protected? return _('This environment is not protected.') unless deployment.environment.protected?
return 'You do not have permission to approve or reject this deployment' unless current_user&.can?(:update_deployment, deployment) return _("You don't have permission to review this deployment. Contact the project or group owner for help.") unless current_user&.can?(:update_deployment, deployment)
return 'This deployment job is not waiting for approvals' unless deployment.blocked? return _('This deployment is not waiting for approvals.') unless deployment.blocked?
'The same user can not approve' if deployment.user == current_user && status == 'approved' _('You cannot approve your own deployment.') if deployment.user == current_user && status == 'approved'
end end
end end
end end
...@@ -284,7 +284,7 @@ RSpec.describe API::Deployments do ...@@ -284,7 +284,7 @@ RSpec.describe API::Deployments do
end end
context 'and user is not authorized to update deployment' do context 'and user is not authorized to update deployment' do
include_examples 'not created', response_status: :bad_request, message: 'You do not have permission to approve or reject this deployment' include_examples 'not created', response_status: :bad_request, message: "You don't have permission to review this deployment. Contact the project or group owner for help."
end end
context 'with an invalid status' do context 'with an invalid status' do
......
...@@ -157,13 +157,13 @@ RSpec.describe Deployments::ApprovalService do ...@@ -157,13 +157,13 @@ RSpec.describe Deployments::ApprovalService do
context 'when status is not recognized' do context 'when status is not recognized' do
let(:status) { 'foo' } let(:status) { 'foo' }
include_examples 'error', message: 'Unrecognized status' include_examples 'error', message: 'Unrecognized approval status.'
end end
context 'when environment is not protected' do context 'when environment is not protected' do
let(:deployment) { create(:deployment, project: project, deployable: build) } let(:deployment) { create(:deployment, project: project, deployable: build) }
include_examples 'error', message: 'This environment is not protected' include_examples 'error', message: 'This environment is not protected.'
end end
context 'when Protected Environments feature is not available' do context 'when Protected Environments feature is not available' do
...@@ -171,7 +171,7 @@ RSpec.describe Deployments::ApprovalService do ...@@ -171,7 +171,7 @@ RSpec.describe Deployments::ApprovalService do
stub_licensed_features(protected_environments: false) stub_licensed_features(protected_environments: false)
end end
include_examples 'error', message: 'This environment is not protected' include_examples 'error', message: 'This environment is not protected.'
end end
context 'when the user does not have permission to update deployment' do context 'when the user does not have permission to update deployment' do
...@@ -179,19 +179,19 @@ RSpec.describe Deployments::ApprovalService do ...@@ -179,19 +179,19 @@ RSpec.describe Deployments::ApprovalService do
project.add_developer(user) project.add_developer(user)
end end
include_examples 'error', message: 'You do not have permission to approve or reject this deployment' include_examples 'error', message: "You don't have permission to review this deployment. Contact the project or group owner for help."
end end
context 'when user is nil' do context 'when user is nil' do
let(:user) { nil } let(:user) { nil }
include_examples 'error', message: 'You do not have permission to approve or reject this deployment' include_examples 'error', message: "You don't have permission to review this deployment. Contact the project or group owner for help."
end end
context 'when deployment is not blocked' do context 'when deployment is not blocked' do
let(:deployment) { create(:deployment, project: project, environment: environment, deployable: build) } let(:deployment) { create(:deployment, project: project, environment: environment, deployable: build) }
include_examples 'error', message: 'This deployment job is not waiting for approvals' include_examples 'error', message: 'This deployment is not waiting for approvals.'
end end
context 'when the creator of the deployment is approving' do context 'when the creator of the deployment is approving' do
...@@ -199,7 +199,7 @@ RSpec.describe Deployments::ApprovalService do ...@@ -199,7 +199,7 @@ RSpec.describe Deployments::ApprovalService do
deployment.user = user deployment.user = user
end end
include_examples 'error', message: 'The same user can not approve' include_examples 'error', message: 'You cannot approve your own deployment.'
end end
context 'when the creator of the deployment is rejecting' do context 'when the creator of the deployment is rejecting' do
......
...@@ -37582,6 +37582,9 @@ msgstr "" ...@@ -37582,6 +37582,9 @@ msgstr ""
msgid "This credential has expired" msgid "This credential has expired"
msgstr "" msgstr ""
msgid "This deployment is not waiting for approvals."
msgstr ""
msgid "This device has already been registered with us." msgid "This device has already been registered with us."
msgstr "" msgstr ""
...@@ -37609,6 +37612,9 @@ msgstr "" ...@@ -37609,6 +37612,9 @@ msgstr ""
msgid "This environment is being re-deployed" msgid "This environment is being re-deployed"
msgstr "" msgstr ""
msgid "This environment is not protected."
msgstr ""
msgid "This environment's canary ingress has been updated recently. Please retry later." msgid "This environment's canary ingress has been updated recently. Please retry later."
msgstr "" msgstr ""
...@@ -39392,6 +39398,9 @@ msgstr "" ...@@ -39392,6 +39398,9 @@ msgstr ""
msgid "Unreachable" msgid "Unreachable"
msgstr "" msgstr ""
msgid "Unrecognized approval status."
msgstr ""
msgid "Unrecognized cluster type" msgid "Unrecognized cluster type"
msgstr "" msgstr ""
...@@ -42220,6 +42229,9 @@ msgstr "" ...@@ -42220,6 +42229,9 @@ msgstr ""
msgid "You cannot access the raw file. Please wait a minute." msgid "You cannot access the raw file. Please wait a minute."
msgstr "" msgstr ""
msgid "You cannot approve your own deployment."
msgstr ""
msgid "You cannot combine replace_ids with add_ids or remove_ids" msgid "You cannot combine replace_ids with add_ids or remove_ids"
msgstr "" msgstr ""
...@@ -42304,6 +42316,9 @@ msgstr "" ...@@ -42304,6 +42316,9 @@ msgstr ""
msgid "You don't have any recent searches" msgid "You don't have any recent searches"
msgstr "" msgstr ""
msgid "You don't have permission to review this deployment. Contact the project or group owner for help."
msgstr ""
msgid "You don't have sufficient permission to perform this action." msgid "You don't have sufficient permission to perform this action."
msgstr "" msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment