Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7fa619ea
Commit
7fa619ea
authored
Oct 05, 2018
by
Gabriel Mazetto
Committed by
Douglas Barbosa Alexandre
Oct 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Geo: Added a button to Admin UI > Geo Nodes to open Geo Projects screen of any secondary node
parent
1ac860fb
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
140 additions
and
47 deletions
+140
-47
ee/app/assets/javascripts/geo_nodes/components/geo_node_actions.vue
...ets/javascripts/geo_nodes/components/geo_node_actions.vue
+67
-39
ee/app/assets/javascripts/geo_nodes/components/node_detail_sections/node_details_section_main.vue
...onents/node_detail_sections/node_details_section_main.vue
+1
-1
ee/app/assets/javascripts/geo_nodes/store/geo_nodes_store.js
ee/app/assets/javascripts/geo_nodes/store/geo_nodes_store.js
+1
-0
ee/app/models/geo_node.rb
ee/app/models/geo_node.rb
+6
-0
ee/changelogs/unreleased/7126-geo-open-projects.yml
ee/changelogs/unreleased/7126-geo-open-projects.yml
+5
-0
ee/lib/ee/api/entities.rb
ee/lib/ee/api/entities.rb
+4
-0
ee/spec/features/geo_node_spec.rb
ee/spec/features/geo_node_spec.rb
+35
-5
ee/spec/fixtures/api/schemas/public_api/v4/geo_node.json
ee/spec/fixtures/api/schemas/public_api/v4/geo_node.json
+2
-1
ee/spec/javascripts/geo_nodes/components/geo_node_actions_spec.js
...javascripts/geo_nodes/components/geo_node_actions_spec.js
+3
-1
ee/spec/javascripts/geo_nodes/mock_data.js
ee/spec/javascripts/geo_nodes/mock_data.js
+1
-0
ee/spec/models/geo_node_spec.rb
ee/spec/models/geo_node_spec.rb
+12
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-0
No files found.
ee/app/assets/javascripts/geo_nodes/components/geo_node_actions.vue
View file @
7fa619ea
...
...
@@ -2,13 +2,21 @@
import
{
__
,
s__
}
from
'
~/locale
'
;
import
eventHub
from
'
../event_hub
'
;
import
{
NODE_ACTIONS
}
from
'
../constants
'
;
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
export
default
{
components
:
{
Icon
,
},
props
:
{
node
:
{
type
:
Object
,
required
:
true
,
},
nodeActionsAllowed
:
{
type
:
Boolean
,
required
:
true
,
},
nodeEditAllowed
:
{
type
:
Boolean
,
required
:
true
,
...
...
@@ -25,6 +33,9 @@
nodeToggleLabel
()
{
return
this
.
node
.
enabled
?
__
(
'
Disable
'
)
:
__
(
'
Enable
'
);
},
isSecondaryNode
()
{
return
!
this
.
node
.
primary
;
},
},
methods
:
{
onToggleNode
()
{
...
...
@@ -54,52 +65,69 @@
<
template
>
<div
class=
"geo-node-actions"
>
<div
v-if=
"nodeMissingOauth"
class=
"node-action-container"
>
<button
type=
"button"
class=
"btn btn-default btn-sm btn-node-action"
@
click=
"onRepairNode"
>
{{
s__
(
'
Repair authentication
'
)
}}
</button>
</div>
<div
v-if=
"isToggleAllowed"
class=
"node-action-container"
>
<button
:class=
"
{
'btn-warning': node.enabled,
'btn-success': !node.enabled
}"
type="button"
class="btn btn-sm btn-node-action"
@click="onToggleNode"
>
{{
nodeToggleLabel
}}
</button>
</div>
<div
v-if=
"nodeEditAllowed"
v-if=
"isSecondaryNode"
class=
"node-action-container"
>
<a
:href=
"node.
editPath
"
:href=
"node.
geoProjectsUrl
"
class=
"btn btn-sm btn-node-action"
target=
"_blank"
>
{{
__
(
'
Edit
'
)
}}
<icon
name=
"external-link"
/>
{{
__
(
'
Open projects
'
)
}}
</a>
</div>
<div
class=
"node-action-container"
>
<button
type=
"button"
class=
"btn btn-sm btn-node-action btn-danger"
@
click=
"onRemoveNode"
<template
v-if=
"nodeActionsAllowed"
>
<div
v-if=
"nodeMissingOauth"
class=
"node-action-container"
>
{{
__
(
'
Remove
'
)
}}
</button>
</div>
<button
type=
"button"
class=
"btn btn-default btn-sm btn-node-action"
@
click=
"onRepairNode"
>
{{
s__
(
'
Repair authentication
'
)
}}
</button>
</div>
<div
v-if=
"isToggleAllowed"
class=
"node-action-container"
>
<button
:class=
"
{
'btn-warning': node.enabled,
'btn-success': !node.enabled
}"
type="button"
class="btn btn-sm btn-node-action"
@click="onToggleNode"
>
{{
nodeToggleLabel
}}
</button>
</div>
<div
v-if=
"nodeEditAllowed"
class=
"node-action-container"
>
<a
:href=
"node.editPath"
class=
"btn btn-sm btn-node-action"
>
{{
__
(
'
Edit
'
)
}}
</a>
</div>
<div
class=
"node-action-container"
>
<button
type=
"button"
class=
"btn btn-sm btn-node-action btn-danger"
@
click=
"onRemoveNode"
>
{{
__
(
'
Remove
'
)
}}
</button>
</div>
</
template
>
</div>
</template>
ee/app/assets/javascripts/geo_nodes/components/node_detail_sections/node_details_section_main.vue
View file @
7fa619ea
...
...
@@ -65,8 +65,8 @@
/>
</div>
<geo-node-actions
v-if=
"nodeActionsAllowed"
:node=
"node"
:node-actions-allowed=
"nodeActionsAllowed"
:node-edit-allowed=
"nodeEditAllowed"
:node-missing-oauth=
"nodeDetails.missingOAuthApplication"
/>
...
...
ee/app/assets/javascripts/geo_nodes/store/geo_nodes_store.js
View file @
7fa619ea
...
...
@@ -54,6 +54,7 @@ export default class GeoNodesStore {
basePath
:
rawNode
.
_links
.
self
,
repairPath
:
rawNode
.
_links
.
repair
,
editPath
:
rawNode
.
web_edit_url
,
geoProjectsUrl
:
rawNode
.
web_geo_projects_url
,
statusPath
:
rawNode
.
_links
.
status
,
};
}
...
...
ee/app/models/geo_node.rb
View file @
7fa619ea
...
...
@@ -153,6 +153,12 @@ class GeoNode < ActiveRecord::Base
Gitlab
::
Routing
.
url_helpers
.
oauth_geo_logout_url
(
url_helper_args
.
merge
(
state:
state
))
end
def
geo_projects_url
return
unless
self
.
secondary?
Gitlab
::
Routing
.
url_helpers
.
admin_geo_projects_url
(
url_helper_args
)
end
def
missing_oauth_application?
self
.
primary?
?
false
:
!
oauth_application
.
present?
end
...
...
ee/changelogs/unreleased/7126-geo-open-projects.yml
0 → 100644
View file @
7fa619ea
---
title
:
'
Geo:
Added
a
button
to
Admin
UI
>
Geo
Nodes
to
open
Geo
Projects
screen
of
any
secondary
node'
merge_request
:
7512
author
:
type
:
added
ee/lib/ee/api/entities.rb
View file @
7fa619ea
...
...
@@ -263,6 +263,10 @@ module EE
::
Gitlab
::
Routing
.
url_helpers
.
edit_admin_geo_node_url
(
geo_node
)
end
expose
:web_geo_projects_url
,
if:
->
(
geo_node
,
_
)
{
geo_node
.
secondary?
}
do
|
geo_node
|
geo_node
.
geo_projects_url
end
expose
:_links
do
expose
:self
do
|
geo_node
|
expose_url
api_v4_geo_nodes_path
(
id:
geo_node
.
id
)
...
...
ee/spec/features/geo_node_spec.rb
View file @
7fa619ea
require
'spec_helper'
describe
'GEO Nodes'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:geo_url
)
{
'http://geo.example.com'
}
include
::
EE
::
GeoHelpers
set
(
:user
)
{
create
(
:user
)
}
set
(
:geo_primary
)
{
create
(
:geo_node
,
:primary
)
}
set
(
:geo_secondary
)
{
create
(
:geo_node
)
}
context
'Geo Secondary Node'
do
let
(
:project
)
{
create
(
:project
)
}
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:secondary?
)
{
true
}
allow
(
Gitlab
::
Geo
).
to
receive_message_chain
(
:primary_node
,
:url
)
{
geo_url
}
stub_current_geo_node
(
geo_secondary
)
project
.
add_maintainer
(
user
)
sign_in
(
user
)
...
...
@@ -26,4 +29,31 @@ describe 'GEO Nodes' do
end
end
end
context
'Primary Geo Node'
do
let
(
:admin_user
)
{
create
(
:user
,
:admin
)
}
before
do
stub_current_geo_node
(
geo_primary
)
stub_licensed_features
(
geo:
true
)
sign_in
(
admin_user
)
end
describe
'Geo Nodes admin screen'
do
it
"has a 'Open projects' button on listed secondary geo nodes pointing to correct URL"
,
:js
do
visit
admin_geo_nodes_path
expect
(
page
).
to
have_content
(
geo_primary
.
url
)
expect
(
page
).
to
have_content
(
geo_secondary
.
url
)
wait_for_requests
geo_node_actions
=
all
(
'div.geo-node-actions'
)
expected_url
=
File
.
join
(
geo_secondary
.
url
,
'/admin/geo/projects'
)
expect
(
geo_node_actions
.
last
).
to
have_link
(
'Open projects'
,
href:
expected_url
)
end
end
end
end
ee/spec/fixtures/api/schemas/public_api/v4/geo_node.json
View file @
7fa619ea
...
...
@@ -21,8 +21,9 @@
"files_max_capacity"
:
{
"type"
:
"integer"
},
"repos_max_capacity"
:
{
"type"
:
"integer"
},
"verification_max_capacity"
:
{
"type"
:
"integer"
},
"clone_protocol"
:
{
"type"
:
[
"string"
]
},
"clone_protocol"
:
{
"type"
:
"string"
},
"web_edit_url"
:
{
"type"
:
"string"
},
"web_geo_projects_url"
:
{
"type"
:
[
"string"
,
"null"
]
},
"_links"
:
{
"type"
:
"object"
,
"required"
:
[
"self"
,
"repair"
],
...
...
ee/spec/javascripts/geo_nodes/components/geo_node_actions_spec.js
View file @
7fa619ea
...
...
@@ -6,12 +6,14 @@ import eventHub from 'ee/geo_nodes/event_hub';
import
{
NODE_ACTIONS
}
from
'
ee/geo_nodes/constants
'
;
import
{
mockNodes
}
from
'
../mock_data
'
;
const
createComponent
=
(
node
=
mockNodes
[
0
],
nodeEditAllowed
=
true
,
nodeMissingOauth
=
false
)
=>
{
const
createComponent
=
(
node
=
mockNodes
[
0
],
nodeEditAllowed
=
true
,
nodeActionsAllowed
=
true
,
nodeMissingOauth
=
false
)
=>
{
const
Component
=
Vue
.
extend
(
geoNodeActionsComponent
);
return
mountComponent
(
Component
,
{
node
,
nodeEditAllowed
,
nodeActionsAllowed
,
nodeMissingOauth
,
});
};
...
...
ee/spec/javascripts/geo_nodes/mock_data.js
View file @
7fa619ea
...
...
@@ -47,6 +47,7 @@ export const mockNode = {
current
:
true
,
enabled
:
true
,
nodeActionActive
:
false
,
nodeActionsAllowed
:
false
,
basePath
:
'
http://127.0.0.1:3001/api/v4/geo_nodes/1
'
,
repairPath
:
'
http://127.0.0.1:3001/api/v4/geo_nodes/1/repair
'
,
statusPath
:
'
http://127.0.0.1:3001/api/v4/geo_nodes/1/status
'
,
...
...
ee/spec/models/geo_node_spec.rb
View file @
7fa619ea
...
...
@@ -328,6 +328,18 @@ describe GeoNode, type: :model do
end
end
describe
'#geo_projects_url'
do
it
'returns the Geo Projects url for the specific node'
do
expected_url
=
'https://localhost:3000/gitlab/admin/geo/projects'
expect
(
new_node
.
geo_projects_url
).
to
eq
(
expected_url
)
end
it
'returns nil when node is a primary one'
do
expect
(
primary_node
.
geo_projects_url
).
to
be_nil
end
end
describe
'#missing_oauth_application?'
do
context
'on a primary node'
do
it
'returns false'
do
...
...
locale/gitlab.pot
View file @
7fa619ea
...
...
@@ -5446,6 +5446,9 @@ msgstr ""
msgid "Open in Xcode"
msgstr ""
msgid "Open projects"
msgstr ""
msgid "Open sidebar"
msgstr ""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment