Commit 15191864 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'feature/geo-ui-improvements' into 'master'

Geo: Improve UI for users in a Geo node

This implements visual hints to help user diagnose Geo (#76) installations, and help guide users that are in a secondary node to understand that they are in a read-only instance.

Fixes gitlab-org/gitlab-ee#640

# First login flash message
![first-login_notice](/uploads/51507c12eb8f4ec29a9e58dbc4c1b716/first-login_notice.png)

# Admin screen - Dashboard information
![admin-screen](/uploads/ee1b3b50a013cd5195c7e2047497d387/admin-screen.png)

# Link to primary node 
![link_to_primary_node](/uploads/6061d64690cda83f49145f9643d0e0bd/link_to_primary_node.png)

See merge request !451
parents 48c866c5 3edac18c
......@@ -3,9 +3,17 @@
# Automatically sets the layout and ensures an administrator is logged in
class Admin::ApplicationController < ApplicationController
before_action :authenticate_admin!
before_action :display_geo_information
layout 'admin'
def authenticate_admin!
render_404 unless current_user.is_admin?
end
def display_geo_information
return unless Gitlab::Geo.secondary?
primary_node = view_context.link_to('primary node', Gitlab::Geo.primary_node.url)
flash.now[:notice] = "You are on a secondary (read-only) Geo node. If you want to make any changes, you must visit the #{primary_node}.".html_safe
end
end
......@@ -25,9 +25,7 @@ class Oauth::GeoAuthController < ActionController::Base
user = User.find_by(id: remote_user['id'])
if user && sign_in(user, bypass: true)
session[:access_token] = token
return_to = oauth.get_oauth_state_return_to
redirect_to(return_to || root_path)
after_sign_in_with_gitlab(token, oauth.get_oauth_state_return_to)
else
invalid_credentials
end
......@@ -46,6 +44,16 @@ class Oauth::GeoAuthController < ActionController::Base
private
def after_sign_in_with_gitlab(token, return_to)
if Gitlab::Geo.primary_node
primary_node = view_context.link_to('primary node', Gitlab::Geo.primary_node.url)
flash[:notice] = "You are on a secondary (read-only) Geo node. If you want to make any changes, you must visit the #{primary_node}.".html_safe
end
session[:access_token] = token
redirect_to(return_to || root_path)
end
def invalid_credentials
@error = 'Cannot find user to login. Your account may have been deleted.'
render :error, layout: 'errors'
......
......@@ -63,6 +63,10 @@
Elasticsearch
%span.light.pull-right
= boolean_to_icon Gitlab.config.elasticsearch.enabled
%p
Geo
%span.light.pull-right
= boolean_to_icon Gitlab::Geo.enabled?
.col-md-4
%h4
Components
......@@ -83,6 +87,12 @@
GitLab API
%span.pull-right
= API::API::version
- if Gitlab::Geo.enabled?
%p
Geo
%span.pull-right
= Gitlab::Geo.current_node.primary ? 'Primary node' : 'Secondary node'
%p
Git
%span.pull-right
......@@ -101,6 +111,7 @@
= Gitlab::Database.adapter_name
%span.pull-right
= Gitlab::Database.version
%hr
.row
.col-sm-4
......
......@@ -30,6 +30,10 @@
- unless todos_pending_count == 0
%span.badge.todos-pending-count
= todos_pending_count
- if Gitlab::Geo.secondary?
%li
= link_to Gitlab::Geo.primary_node.url, title: 'Go to primary node', data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
= icon('globe fw')
- if current_user.can_create_project?
%li
= link_to new_project_path, title: 'New project', data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
......
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