Commit 937b8d03 authored by Gabriel Mazetto's avatar Gabriel Mazetto

🔨More refactor into Geo Clone UI code

parent babcc5d5
//= require vue
/* global modal */
/* global modal Vue */
(() => {
Vue.component('geo-clone-dialog', {
name: 'geo-clone-dialog',
......@@ -28,11 +28,11 @@
<h3>{{title}}</h3>
</div>
<div class="modal-body">
<p><strong>Step1.</strong> Clone the repository from your secondary node:</p>
<p><strong>Step 1.</strong> Clone the repository from your secondary node:</p>
<slot name="clipboard-1"></slot>
<pre class="dark" id="geo-info-1">git clone {{cloneUrlSecondary}}</pre>
<p><strong>Step2.</strong> Go to the new directory and define <strong>primary's node</strong> repository URL as the <strong>push</strong> remote:</p>
<p><strong>Step 2.</strong> Go to the new directory and define <strong>primary node's</strong> repository URL as the <strong>push</strong> remote:</p>
<slot name="clipboard-2"></slot>
<pre class="dark" id="geo-info-2">git remote set-url --push origin {{cloneUrlPrimary | emptyRepo}}</pre>
<p><strong>Done.</strong> You can now commit and push code as you normally do, but with increased speed.</p>
......
......@@ -40,7 +40,7 @@ module ButtonHelper
placement: placement,
container: 'body',
title: "Set a password on your account<br>to pull or push via #{protocol}",
primary_url: (project.geo_primary_http_url_to_repo if Gitlab::Geo.secondary?)
primary_url: (geo_primary_http_url_to_repo(project) if Gitlab::Geo.secondary?)
}
end
......
module EeGitlabRoutingHelper
def geo_primary_web_url(project)
File.join(::Gitlab::Geo.primary_node.url, ::Gitlab::Routing.url_helpers.namespace_project_path(project.namespace, project))
end
def geo_primary_http_url_to_repo(project)
"#{geo_primary_web_url(project)}.git"
end
def geo_primary_default_url_to_repo(project)
case default_clone_protocol
when 'http'
geo_primary_http_url_to_repo(project)
end
end
end
......@@ -265,13 +265,6 @@ module ProjectsHelper
"#{number_to_human_size(size_in_bytes, delimiter: ',', precision: 2)}#{limit_text}"
end
def geo_primary_default_url_to_repo(project = @project)
case default_clone_protocol
when 'http'
project.geo_primary_http_url_to_repo
end
end
def default_url_to_repo(project = @project)
case default_clone_protocol
when 'krb5'
......
module EE
# Project EE mixin
#
# This module is intended to encapsulate EE-specific model logic
# and be included in the `Project` model
module Project
extend ActiveSupport::Concern
included do
def geo_primary_web_url
File.join(::Gitlab::Geo.primary_node.url, ::Gitlab::Routing.url_helpers.namespace_project_path(self.namespace, self))
end
def geo_primary_http_url_to_repo
"#{geo_primary_web_url}.git"
end
end
end
end
......@@ -16,7 +16,6 @@ class Project < ActiveRecord::Base
include ProjectFeaturesCompatibility
include SelectForProjectAuthorization
prepend EE::GeoAwareAvatar
include EE::Project
extend Gitlab::ConfigHelper
......
---
title: 'Geo: improve project view UI to guide users how to clone/push from Geo secondary
node'
title: 'Geo: Improve project view UI to teach users how to clone from a secondary Geo node and push to a primary.'
merge_request: 789
author: Gabriel Mazetto
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