15720: Warn about empty ManagementToken or SystemRootToken.
[arvados.git] / apps / workbench / app / views / layouts / body.html.erb
1 <%# Copyright (C) The Arvados Authors. All rights reserved.
2
3 SPDX-License-Identifier: AGPL-3.0 %>
4
5   <div id="wrapper" class="container-fluid">
6     <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
7       <div class="navbar-header">
8         <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
9           <span class="sr-only">Toggle navigation</span>
10           <span class="icon-bar"></span>
11           <span class="icon-bar"></span>
12           <span class="icon-bar"></span>
13         </button>
14         <% site_name = Rails.configuration.Workbench.SiteName.downcase rescue Rails.application.class.parent_name %>
15         <% if current_user %>
16           <a class="navbar-brand" href="/" data-push=true><%= site_name %></a>
17         <% else %>
18           <span class="navbar-brand"><%= site_name %></span>
19         <% end %>
20       </div>
21
22       <div class="collapse navbar-collapse">
23         <ul class="nav navbar-nav navbar-right">
24
25           <li>
26             <a><i class="rotating loading glyphicon glyphicon-refresh"></i></a>
27           </li>
28
29           <% if current_user %>
30             <% if current_user.is_active %>
31               <% if !Rails.configuration.Workbench.MultiSiteSearch.empty? %>
32                 <li>
33                   <form class="navbar-form">
34                     <%=
35                        target = Rails.configuration.Workbench.MultiSiteSearch
36                        if target == "true"
37                          target = {controller: 'search', action: 'index'}
38                        end
39                        link_to("Multi-site search", target, {class: 'btn btn-default'}) %>
40                   </form>
41                 </li>
42               <% end %>
43               <li>
44                 <form class="navbar-form" role="search"
45                            data-search-modal=
46                            "<%= url_for(
47                             action: 'choose',
48                             controller: 'search',
49                             title: 'Search',
50                             action_name: 'Show',
51                             action_href: url_for(controller: :actions, action: :show),
52                             action_method: 'get',
53                             action_data: {selection_param: 'uuid', success: 'redirect-to-created-object'}.to_json)
54                            %>">
55                   <div class="input-group" style="width: 220px">
56                     <input type="text" class="form-control" placeholder="search this site">
57                     <a class="input-group-addon"><span class="glyphicon glyphicon-search"></span></a>
58                   </div>
59                 </form>
60               </li>
61             <% end %>
62
63             <li class="dropdown notification-menu">
64               <a href="#" class="dropdown-toggle" data-toggle="dropdown" id="notifications-menu">
65                 <span class="badge badge-alert notification-count"><%= user_notifications.length if user_notifications.any? %></span>
66                 <span class="fa fa-lg fa-user"></span>
67                 <span class="caret"></span>
68               </a>
69               <ul class="dropdown-menu" role="menu">
70                 <li role="presentation" class="dropdown-header">
71                   <%= current_user.email %>
72                 </li>
73                 <% if current_user.is_active %>
74                 <li role="menuitem"><a href="/projects/<%=current_user.uuid%>" role="menuitem"><i class="fa fa-lg fa-home fa-fw"></i> Home project </a></li>
75                   <% if Rails.configuration.Services.Composer.ExternalURL != URI("") %>
76                     <li role="menuitem">
77                       <form action="<%= Rails.configuration.Services.Composer.ExternalURL.to_s %>" method="GET">
78                         <input type="hidden" name="api_token" value="<%= Thread.current[:arvados_api_token] %>" />
79                         <button role="menuitem" type="submit">
80                           <i class="fa fa-lg fa-share-alt fa-fw"></i> Workflow Composer
81                         </button>
82                       </form>
83                     </li>
84                   <% end %>
85                 <% if Rails.configuration.Services.Workbench2.ExternalURL != URI("") %>
86                 <li role="menuitem">
87                   <%
88                     wb2_url = Rails.configuration.Services.Workbench2.ExternalURL.to_s
89                     wb2_url += '/' if wb2_url[-1] != '/'
90                     wb2_url += 'token'
91                   %>
92                   <form action="<%= wb2_url %>" method="GET">
93                     <input type="hidden" name="api_token" value="<%= Thread.current[:arvados_api_token] %>">
94                     <button role="menuitem" type="submit">
95                       <i class="fa fa-lg fa-share-square fa-fw"></i> Go to Workbench 2
96                     </button>
97                   </form>
98                 </li>
99                 <% end %>
100                 <li role="menuitem">
101                   <%= link_to virtual_machines_user_path(current_user), role: 'menu-item' do %>
102                     <i class="fa fa-lg fa-terminal fa-fw"></i> Virtual machines
103                   <% end %>
104                 </li>
105                 <% if Rails.configuration.Workbench.Repositories %>
106                 <li role="menuitem"><a href="/repositories" role="menuitem"><i class="fa fa-lg fa-code-fork fa-fw"></i> Repositories </a></li>
107                 <% end -%>
108                 <li role="menuitem"><a href="/current_token" role="menuitem"><i class="fa fa-lg fa-ticket fa-fw"></i> Current token</a></li>
109                 <li role="menuitem">
110                   <%= link_to ssh_keys_user_path(current_user), role: 'menu-item' do %>
111                     <i class="fa fa-lg fa-key fa-fw"></i> SSH keys
112                   <% end %>
113 </li>
114                 <li role="menuitem"><a href="/users/link_account" role="menuitem"><i class="fa fa-lg fa-link fa-fw"></i> Link account </a></li>
115                 <% if !Rails.configuration.Workbench.UserProfileFormFields.empty? %>
116                   <li role="menuitem"><a href="/users/<%=current_user.uuid%>/profile" role="menuitem"><i class="fa fa-lg fa-user fa-fw"></i> Manage profile</a></li>
117                 <% end %>
118                 <% end %>
119                 <li role="presentation" class="divider"></li>
120                 <li role="menuitem"><a href="<%= logout_path %>" role="menuitem"><i class="fa fa-lg fa-sign-out fa-fw"></i> Log out</a></li>
121                 <% if user_notifications.any? %>
122                   <li role="presentation" class="divider"></li>
123                   <% user_notifications.each_with_index do |n, i| %>
124                     <% if i > 0 %><li class="divider"></li><% end %>
125                     <li class="notification"><%= n.call(self) %></li>
126                   <% end %>
127                 <% end %>
128               </ul>
129             </li>
130
131             <% if current_user.is_admin %>
132               <li class="dropdown">
133                 <a href="#" class="dropdown-toggle" data-toggle="dropdown" id="system-menu">
134                   <span class="fa fa-lg fa-gear"></span>
135                   <span class="caret"></span>
136                 </a>
137                 <ul class="dropdown-menu" role="menu">
138                   <li role="presentation" class="dropdown-header">
139                     Admin Settings
140                   </li>
141                   <% if Rails.configuration.Workbench.Repositories %>
142                   <li role="menuitem"><a href="/repositories">
143                       <i class="fa fa-lg fa-code-fork fa-fw"></i> Repositories
144                   </a></li>
145                   <% end -%>
146                   <li role="menuitem"><a href="/virtual_machines">
147                       <i class="fa fa-lg fa-terminal fa-fw"></i> Virtual machines
148                   </a></li>
149                   <li role="menuitem"><a href="/authorized_keys">
150                       <i class="fa fa-lg fa-key fa-fw"></i> SSH keys
151                   </a></li>
152                   <li role="menuitem"><a href="/api_client_authorizations">
153                       <i class="fa fa-lg fa-ticket fa-fw"></i> API tokens
154                   </a></li>
155                   <li role="menuitem"><a href="/links">
156                       <i class="fa fa-lg fa-arrows-h fa-fw"></i> Links
157                   </a></li>
158                   <li role="menuitem"><a href="/users">
159                       <i class="fa fa-lg fa-user fa-fw"></i> Users
160                   </a></li>
161                   <li role="menuitem"><a href="/groups">
162                       <i class="fa fa-lg fa-users fa-fw"></i> Groups
163                   </a></li>
164                   <li role="menuitem"><a href="/nodes">
165                       <i class="fa fa-lg fa-cloud fa-fw"></i> Compute nodes
166                   </a></li>
167                   <li role="menuitem"><a href="/keep_services">
168                       <i class="fa fa-lg fa-exchange fa-fw"></i> Keep services
169                   </a></li>
170                   <li role="menuitem"><a href="/keep_disks">
171                       <i class="fa fa-lg fa-hdd-o fa-fw"></i> Keep disks
172                   </a></li>
173                 </ul>
174               </li>
175             <% end %>
176           <% else %>
177             <% if !Rails.configuration.Users.AnonymousUserToken.empty? and Rails.configuration.Workbench.EnablePublicProjectsPage %>
178               <li><%= link_to 'Browse public projects', "/projects/public" %></li>
179             <% end %>
180             <li class="dropdown hover-dropdown login-menu">
181               <a href="<%= arvados_api_client.arvados_login_url(return_to: request.url) %>">Log in</a>
182               <ul class="dropdown-menu">
183                 <li>
184                   <a href="<%= arvados_api_client.arvados_login_url(return_to: request.url) %>">
185                     <span class="fa fa-lg fa-sign-in"></span>
186                     <p style="margin-left: 1.6em; margin-top: -1.35em; margin-bottom: 0em; margin-right: 0.5em;">Log in or register with<br/>any Google account</p>
187                   </a>
188                 </li>
189               </ul>
190             </li>
191           <% end %>
192
193           <li class="dropdown help-menu">
194             <a href="#" class="dropdown-toggle" data-toggle="dropdown" id="arv-help">
195               <span class="fa fa-lg fa-question-circle"></span>
196               <span class="caret"></span>
197             </a>
198             <ul class="dropdown-menu">
199               <li role="presentation" class="dropdown-header">
200                 Help
201               </li>
202               <% if Rails.configuration.Workbench.EnableGettingStartedPopup %>
203                 <li>
204                 <%= link_to raw('<i class="fa fa-fw fa-info"></i> Getting Started ...'), "#",
205                      {'data-toggle' => "modal", 'data-target' => '#getting-started-modal-window'}  %>
206                 </li>
207               <% end %>
208               <% if !Rails.configuration.Workbench.ArvadosPublicDataDocURL.empty? %>
209                 <li><%= link_to raw('<i class="fa fa-book fa-fw"></i> Public Pipelines and Data sets'), "#{Rails.configuration.Workbench.ArvadosPublicDataDocURL}", target: "_blank" %></li>
210               <% end %>
211               <li><%= link_to raw('<i class="fa fa-book fa-fw"></i> Tutorials and User guide'), "#{Rails.configuration.Workbench.ArvadosDocsite}/user", target: "_blank" %></li>
212               <li><%= link_to raw('<i class="fa fa-book fa-fw"></i> API Reference'), "#{Rails.configuration.Workbench.ArvadosDocsite}/api", target: "_blank" %></li>
213               <li><%= link_to raw('<i class="fa fa-book fa-fw"></i> SDK Reference'), "#{Rails.configuration.Workbench.ArvadosDocsite}/sdk", target: "_blank" %></li>
214               <li role="presentation" class="divider"></li>
215               <li> <%= link_to report_issue_popup_path(popup_type: 'version', current_location: request.url, current_path: request.fullpath, action_method: 'post'),
216                       {class: 'report-issue-modal-window', remote: true, return_to: request.url} do %>
217                        <i class="fa fa-fw fa-support"></i> Show version / debugging info ...
218                       <% end %>
219               </li>
220               <li> <%= link_to report_issue_popup_path(popup_type: 'report', current_location: request.url, current_path: request.fullpath, action_method: 'post'),
221                       {class: 'report-issue-modal-window', remote: true, return_to: request.url} do %>
222                        <i class="fa fa-fw fa-support"></i> Report a problem ...
223                       <% end %>
224               </li>
225             </ul>
226           </li>
227         </ul>
228       </div><!-- /.navbar-collapse -->
229     </nav>
230
231     <% if current_user.andand.is_active %>
232       <%= render partial: 'breadcrumbs' %>
233     <% elsif !current_user %>   <%# anonymous %>
234       <% if (@name_link or @object) and (project_breadcrumbs.any?) %>
235         <nav class="navbar navbar-default breadcrumbs" role="navigation">
236           <ul class="nav navbar-nav navbar-left">
237             <li>
238               <a href="/projects/public">Public Projects</a>
239             </li>
240             <% project_breadcrumbs.each do |p| %>
241               <li class="nav-separator">
242                 <i class="fa fa-lg fa-angle-double-right"></i>
243               </li>
244               <li>
245                 <%= link_to(p.name, project_path(p.uuid), data: {object_uuid: p.uuid, name: 'name'}) %>
246               </li>
247             <% end %>
248           </ul>
249         </nav>
250       <% end %>
251     <% end %>
252
253     <%= render partial: 'browser_unsupported' %><%# requires JS support below %>
254     <%= render partial: 'getting_started/getting_started_popup' %>
255
256     <div id="page-wrapper">
257       <%= yield %>
258     </div>
259   </div>
260
261   <%= yield :footer_html %>
262
263 <div class="modal-container"></div>
264 <div id="report-issue-modal-window"></div>
265 <script src="/browser_unsupported.js"></script>
266
267 <%  if Rails.configuration.Workbench.EnableGettingStartedPopup and current_user and !current_user.prefs[:getting_started_shown] and
268        !request.url.include?("/profile") and
269        !request.url.include?("/user_agreements") and
270        !request.url.include?("/inactive")%>
271   <script>
272     $("#getting-started-modal-window").modal('show');
273   </script>
274   <%
275     prefs = current_user.prefs
276     prefs[:getting_started_shown] = Time.now
277     current_user.update_attributes prefs: prefs.to_json
278   %>
279 <% end %>