doortts doortts 2018-12-11
sidebar: Fix UI bug of anonymous user
@8b05ac237c8eb05249ff9e2eaa8719d9a34665ba
app/models/Organization.java
--- app/models/Organization.java
+++ app/models/Organization.java
@@ -1,23 +1,10 @@
 /**
- * Yobi, Project Hosting SW
- *
- * Copyright 2013 NAVER Corp.
- * http://yobi.io
- *
- * @author Keesun Baik, Wansoon Park, ChangSung Kim
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+ * Yona, 21st Century Project Hosting SW
+ * <p>
+ * Copyright Yona & Yobi Authors & NAVER Corp. & NAVER LABS Corp.
+ * https://yona.io
+ **/
+
 package models;
 
 import com.avaje.ebean.Expr;
@@ -178,6 +165,9 @@
 
     public static List<Organization> findAllOrganizations(String loginId) {
         User user = User.findByLoginId(loginId);
+        if (user.isAnonymous()) {
+            return new ArrayList<>();
+        }
 
         Set<String> owners = new TreeSet<>(new Comparator<String>() {
             @Override
app/views/common/usermenu_tab_content_list.scala.html
--- app/views/common/usermenu_tab_content_list.scala.html
+++ app/views/common/usermenu_tab_content_list.scala.html
@@ -10,7 +10,9 @@
 <div class="tab-pane user-project-list" id="myProjectList">
 @views.html.index.myProjectList(UserApp.currentUser())
 </div>
-<div class="tab-pane user-project-list" id="allProjectList">
+@if(!Application.HIDE_PROJECT_LISTING && !UserApp.currentUser().isGuest){
+    <div class="tab-pane user-project-list" id="allProjectList">
 @views.html.index.allProjectList(UserApp.currentUser())
-</div>
+    </div>
+}
 
app/views/layout.scala.html
--- app/views/layout.scala.html
+++ app/views/layout.scala.html
@@ -100,6 +100,9 @@
                     window.location.href = "@routes.Application.index?path=" + window.location.pathname;
                 } else {
                     window.parent.$(".sidebar").toggle();
+                    if(window.parent.$(".sidebar").text().trim().length < 1) {
+                        window.parent.location.reload();
+                    }
                 }
             });
         })
app/views/layout_framed.scala.html
--- app/views/layout_framed.scala.html
+++ app/views/layout_framed.scala.html
@@ -9,9 +9,18 @@
 @currentUser = @{
     UserApp.currentUser()
 }
-    @iframePath = @{
-        request.getQueryString("path").getOrElse(UserSetting.findByUser(currentUser.id).loginDefaultPage)
+
+@defaultPage = @{
+    if(UserSetting.findByUser(currentUser.id).loginDefaultPage == null) {
+        routes.Application.notifications().toString
+    } else {
+        UserSetting.findByUser(currentUser.id).loginDefaultPage
     }
+}
+
+@iframePath = @{
+    request.getQueryString("path").getOrElse(defaultPage)
+}
 
 <!DOCTYPE html>
 <html lang="@UserApp.currentUser().getPreferredLanguage">
@@ -44,7 +53,9 @@
 
 <body class="@theme" id="html-body">
     <div id="sidebar" class="sidebar">
-    @sidebar()
+        @if(!currentUser.isAnonymous){
+            @sidebar()
+        }
     </div>
     <div id="mainFrame">
         <iframe name="mainFrame" frameborder="0" scrolling="no" height="100%" width="100%" src="@iframePath"  scrolling="no" onload="resizeIframe(this)"></iframe>
app/views/sidebar.scala.html
--- app/views/sidebar.scala.html
+++ app/views/sidebar.scala.html
@@ -24,13 +24,13 @@
 
 
 <div class="row-fluid user-menu-wrap">
-    <span class="user-menu"><a href="@routes.UserApp.userInfo(currentUser.loginId)">
+    <span class="user-menu"><a href="@routes.UserApp.userInfo(currentUser.loginId)" target="mainFrame">
         <span class="avatar-wrap smaller">
             <img src="@currentUser.avatarUrl(32)" />
         </span>
         <span class="caret-text hide-in-mobile">@currentUser.getPureNameOnly</span>
     </a></span>
-    <span class="user-menu"><a href="@routes.UserApp.editUserInfoForm()">@Messages("userinfo.accountSetting")</a></span>
+    <span class="user-menu"><a href="@routes.UserApp.editUserInfoForm()" target="mainFrame">@Messages("userinfo.accountSetting")</a></span>
     @currentAuth() { auth =>
         @if(auth != null) {
             <a href="@routes.Application.oAuthLogout"><span class="user-menu logout label">@Messages("title.logout")</span></a>
@@ -50,11 +50,13 @@
         @Messages("title.project")
         </a>
     </li>
+    @if(!Application.HIDE_PROJECT_LISTING && !UserApp.currentUser().isGuest){
     <li class="allProjectList">
         <a href="#allProjectList" data-toggle="tab">
         @Messages("common.order.all")
         </a>
     </li>
+    }
 </ul>
 <div class="tab-content tab-box">
     <div id="usermenu-tab-content-list" class="tab-content">
@@ -64,8 +66,10 @@
         <div class="tab-pane user-project-list" id="myProjectList">
         @views.html.index.myProjectList(UserApp.currentUser())
         </div>
-        <div class="tab-pane user-project-list" id="allProjectList">
-        @views.html.index.allProjectList(UserApp.currentUser())
-        </div>
+        @if(!Application.HIDE_PROJECT_LISTING && !UserApp.currentUser().isGuest){
+            <div class="tab-pane user-project-list" id="allProjectList">
+            @views.html.index.allProjectList(UserApp.currentUser())
+            </div>
+        }
     </div>
 </div>
Add a comment
List