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

🔨More refactor into Geo Clone UI code

parent babcc5d5
//= require vue //= require vue
/* global modal */ /* global modal Vue */
(() => { (() => {
Vue.component('geo-clone-dialog', { Vue.component('geo-clone-dialog', {
name: 'geo-clone-dialog', name: 'geo-clone-dialog',
...@@ -28,11 +28,11 @@ ...@@ -28,11 +28,11 @@
<h3>{{title}}</h3> <h3>{{title}}</h3>
</div> </div>
<div class="modal-body"> <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> <slot name="clipboard-1"></slot>
<pre class="dark" id="geo-info-1">git clone {{cloneUrlSecondary}}</pre> <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> <slot name="clipboard-2"></slot>
<pre class="dark" id="geo-info-2">git remote set-url --push origin {{cloneUrlPrimary | emptyRepo}}</pre> <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> <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 ...@@ -40,7 +40,7 @@ module ButtonHelper
placement: placement, placement: placement,
container: 'body', container: 'body',
title: "Set a password on your account<br>to pull or push via #{protocol}", 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 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 ...@@ -265,13 +265,6 @@ module ProjectsHelper
"#{number_to_human_size(size_in_bytes, delimiter: ',', precision: 2)}#{limit_text}" "#{number_to_human_size(size_in_bytes, delimiter: ',', precision: 2)}#{limit_text}"
end 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) def default_url_to_repo(project = @project)
case default_clone_protocol case default_clone_protocol
when 'krb5' 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 ...@@ -16,7 +16,6 @@ class Project < ActiveRecord::Base
include ProjectFeaturesCompatibility include ProjectFeaturesCompatibility
include SelectForProjectAuthorization include SelectForProjectAuthorization
prepend EE::GeoAwareAvatar prepend EE::GeoAwareAvatar
include EE::Project
extend Gitlab::ConfigHelper extend Gitlab::ConfigHelper
......
--- ---
title: 'Geo: improve project view UI to guide users how to clone/push from Geo secondary title: 'Geo: Improve project view UI to teach users how to clone from a secondary Geo node and push to a primary.'
node'
merge_request: 789 merge_request: 789
author: Gabriel Mazetto 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