]> source.dussan.org Git - sonarqube.git/commitdiff
SONARCLOUD-345 Disable new feature notifications for anonymous users
authorWouter Admiraal <wouter.admiraal@sonarsource.com>
Wed, 9 Jan 2019 08:09:38 +0000 (09:09 +0100)
committerSonarTech <sonartech@sonarsource.com>
Thu, 10 Jan 2019 19:21:02 +0000 (20:21 +0100)
server/sonar-web/src/main/js/app/components/nav/global/GlobalNav.tsx
server/sonar-web/src/main/js/app/components/nav/global/__tests__/GlobalNav-test.tsx
server/sonar-web/src/main/js/app/components/nav/global/__tests__/__snapshots__/GlobalNav-test.tsx.snap

index 732e536022a7200f5e8dbb27308cf75bb004ce3d..958a537094fb0b87dd80d634621f40d6b726f5ac 100644 (file)
@@ -181,6 +181,7 @@ export class GlobalNav extends React.PureComponent<Props, State> {
 
         <ul className="global-navbar-menu global-navbar-menu-right">
           {isSonarCloud() &&
+            isLoggedIn(currentUser) &&
             news.length > 0 && (
               <NavLatestNotification
                 lastNews={news[0]}
@@ -207,6 +208,7 @@ export class GlobalNav extends React.PureComponent<Props, State> {
           <GlobalNavUserContainer appState={appState} currentUser={currentUser} />
         </ul>
         {isSonarCloud() &&
+          isLoggedIn(currentUser) &&
           this.state.notificationSidebar && (
             <NotificationsSidebar
               fetchMoreFeatureNews={this.fetchMoreFeatureNews}
index 72a882c59df21563144d56d0e6ae5369a70c3810..14c200dff93b4c7cc5fd0abc0c41faa9deaac6e6 100644 (file)
@@ -96,18 +96,16 @@ it('should render for SonarQube', async () => {
 
 it('should render for SonarCloud', () => {
   (isSonarCloud as jest.Mock).mockImplementation(() => true);
-
-  const wrapper = shallowRender();
+  const wrapper = shallowRender({ currentUser: { isLoggedIn: true } });
 
   expect(wrapper).toMatchSnapshot();
-  wrapper.setProps({ currentUser: { isLoggedIn: true } });
   expect(wrapper.find('[data-test="global-nav-plus"]').exists()).toBe(true);
 });
 
 it('should render correctly if there are new features', async () => {
   (isSonarCloud as jest.Mock).mockImplementation(() => true);
-
   const wrapper = shallowRender();
+  wrapper.setProps({ currentUser: { isLoggedIn: true } });
 
   await waitAndUpdate(wrapper);
   expect(fetchPrismicRefs).toHaveBeenCalled();
index adf97af0f51af6436b39ef7482e4e39232cd546c..c6743186aa0b7ead8cd2ff7b0e35481e8c5a5e12 100644 (file)
@@ -19,7 +19,7 @@ exports[`should render correctly if there are new features 1`] = `
     }
     currentUser={
       Object {
-        "isLoggedIn": false,
+        "isLoggedIn": true,
       }
     }
     location={
@@ -72,10 +72,15 @@ exports[`should render correctly if there are new features 1`] = `
       }
       currentUser={
         Object {
-          "isLoggedIn": false,
+          "isLoggedIn": true,
         }
       }
     />
+    <ContextConsumer
+      data-test="global-nav-plus"
+    >
+      <Component />
+    </ContextConsumer>
     <Connect(withRouter(GlobalNavUser))
       appState={
         Object {
@@ -87,7 +92,7 @@ exports[`should render correctly if there are new features 1`] = `
       }
       currentUser={
         Object {
-          "isLoggedIn": false,
+          "isLoggedIn": true,
         }
       }
     />
@@ -114,7 +119,7 @@ exports[`should render for SonarCloud 1`] = `
     }
     currentUser={
       Object {
-        "isLoggedIn": false,
+        "isLoggedIn": true,
       }
     }
     location={
@@ -146,10 +151,15 @@ exports[`should render for SonarCloud 1`] = `
       }
       currentUser={
         Object {
-          "isLoggedIn": false,
+          "isLoggedIn": true,
         }
       }
     />
+    <ContextConsumer
+      data-test="global-nav-plus"
+    >
+      <Component />
+    </ContextConsumer>
     <Connect(withRouter(GlobalNavUser))
       appState={
         Object {
@@ -161,7 +171,7 @@ exports[`should render for SonarCloud 1`] = `
       }
       currentUser={
         Object {
-          "isLoggedIn": false,
+          "isLoggedIn": true,
         }
       }
     />