summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-12-10 14:52:44 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-12-10 14:52:44 +0000
commit86a8eee1b8bd43a1fe962905eb97a1f478cc050b (patch)
tree439816bbaf4a0caf16d579223eb9465e0b0daebc /app
parent1b517a5a19c4aafc6fa6d738b0ee7c1e4a2cce36 (diff)
downloadgitlab-ce-86a8eee1b8bd43a1fe962905eb97a1f478cc050b.tar.gz
Add latest changes from gitlab-org/gitlab@13-6-stable-ee
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/registry/explorer/utils.js11
-rw-r--r--app/assets/javascripts/vue_merge_request_widget/mr_widget_options.vue5
-rw-r--r--app/helpers/members_helper.rb6
-rw-r--r--app/services/members/invite_service.rb16
-rw-r--r--app/services/projects/create_service.rb7
5 files changed, 34 insertions, 11 deletions
diff --git a/app/assets/javascripts/registry/explorer/utils.js b/app/assets/javascripts/registry/explorer/utils.js
index 2c89d508c31..a48da51caae 100644
--- a/app/assets/javascripts/registry/explorer/utils.js
+++ b/app/assets/javascripts/registry/explorer/utils.js
@@ -1,3 +1,5 @@
+import { joinPaths } from '~/lib/utils/url_utility';
+
export const pathGenerator = (imageDetails, ending = '?format=json') => {
// this method is a temporary workaround, to be removed with graphql implementation
// https://gitlab.com/gitlab-org/gitlab/-/issues/276432
@@ -12,5 +14,12 @@ export const pathGenerator = (imageDetails, ending = '?format=json') => {
return acc;
}, [])
.join('/');
- return `/${basePath}/registry/repository/${imageDetails.id}/tags${ending}`;
+
+ return joinPaths(
+ window.gon.relative_url_root,
+ `/${basePath}`,
+ '/registry/repository/',
+ `${imageDetails.id}`,
+ `tags${ending}`,
+ );
};
diff --git a/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.vue b/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.vue
index 190d790f584..e7f0977778e 100644
--- a/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.vue
+++ b/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.vue
@@ -202,6 +202,9 @@ export default {
shouldShowAccessibilityReport() {
return this.mr.accessibilityReportPath;
},
+ formattedHumanAccess() {
+ return (this.mr.humanAccess || '').toLowerCase();
+ },
},
watch: {
state(newVal, oldVal) {
@@ -439,7 +442,7 @@ export default {
class="mr-widget-workflow"
:pipeline-path="mr.mergeRequestAddCiConfigPath"
:pipeline-svg-path="mr.pipelinesEmptySvgPath"
- :human-access="mr.humanAccess.toLowerCase()"
+ :human-access="formattedHumanAccess"
:user-callouts-path="mr.userCalloutsPath"
:user-callout-feature-id="mr.suggestPipelineFeatureId"
@dismiss="dismissSuggestPipelines"
diff --git a/app/helpers/members_helper.rb b/app/helpers/members_helper.rb
index d66f67fbb60..5dc636ad996 100644
--- a/app/helpers/members_helper.rb
+++ b/app/helpers/members_helper.rb
@@ -6,14 +6,14 @@ module MembersHelper
text = 'Are you sure you want to'
action =
- if member.request?
+ if member.invite?
+ "revoke the invitation for #{member.invite_email} to join"
+ elsif member.request?
if member.user == user
'withdraw your access request for'
else
"deny #{member.user.name}'s request to join"
end
- elsif member.invite?
- "revoke the invitation for #{member.invite_email} to join"
else
if member.user
"remove #{member.user.name} from"
diff --git a/app/services/members/invite_service.rb b/app/services/members/invite_service.rb
index cfab5c3ef9d..60ebbaface2 100644
--- a/app/services/members/invite_service.rb
+++ b/app/services/members/invite_service.rb
@@ -20,8 +20,8 @@ module Members
emails.each do |email|
next if existing_member?(source, email)
-
next if existing_invite?(source, email)
+ next if existing_request?(source, email)
if existing_user?(email)
add_existing_user_as_member(current_user, source, params, email)
@@ -44,8 +44,7 @@ module Members
access_level: params[:access_level],
invite_email: email,
created_by_id: current_user.id,
- expires_at: params[:expires_at],
- requested_at: Time.current.utc)
+ expires_at: params[:expires_at])
unless new_member.valid? && new_member.persisted?
errors[params[:email]] = new_member.errors.full_messages.to_sentence
@@ -92,6 +91,17 @@ module Members
false
end
+ def existing_request?(source, email)
+ existing_request = source.requesters.with_user_by_email(email).exists?
+
+ if existing_request
+ errors[email] = "Member cannot be invited because they already requested to join #{source.name}"
+ return true
+ end
+
+ false
+ end
+
def existing_user(email)
User.find_by_email(email)
end
diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb
index 8f18a23aa0f..a01db4b498c 100644
--- a/app/services/projects/create_service.rb
+++ b/app/services/projects/create_service.rb
@@ -67,7 +67,7 @@ module Projects
@project
rescue ActiveRecord::RecordInvalid => e
- message = "Unable to save #{e.record.type}: #{e.record.errors.full_messages.join(", ")} "
+ message = "Unable to save #{e.inspect}: #{e.record.errors.full_messages.join(", ")}"
fail(error: message)
rescue => e
@project.errors.add(:base, e.message) if @project
@@ -122,8 +122,9 @@ module Projects
only_concrete_membership: true)
if group_access_level > GroupMember::NO_ACCESS
- current_user.project_authorizations.create!(project: @project,
- access_level: group_access_level)
+ current_user.project_authorizations.safe_find_or_create_by!(
+ project: @project,
+ access_level: group_access_level)
end
if Feature.enabled?(:specialized_project_authorization_workers)