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