]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9245 Enhance the top bar close button on the projects page
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Wed, 31 May 2017 10:10:29 +0000 (12:10 +0200)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Fri, 9 Jun 2017 06:26:48 +0000 (08:26 +0200)
server/sonar-web/src/main/js/apps/projects/components/AllProjects.js
server/sonar-web/src/main/js/apps/projects/components/PageHeader.js
server/sonar-web/src/main/js/apps/projects/components/ProjectsOptionBar.js
server/sonar-web/src/main/js/apps/projects/components/__tests__/ProjectOptionBar-test.js
server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/PageHeader-test.js.snap
server/sonar-web/src/main/js/apps/projects/components/__tests__/__snapshots__/ProjectOptionBar-test.js.snap
server/sonar-web/src/main/js/apps/projects/styles.css

index 93c68c438ce18d39e2305b223a586cb5eb36bb49..3adb8c5e0e83ef89c5ff5e7056b48cfc2bb25753 100644 (file)
@@ -119,7 +119,8 @@ export default class AllProjects extends React.PureComponent {
     const visualization = query.visualization || 'risk';
     const selectedSort = query.sort || 'name';
 
-    const top = (organization ? 95 : 30) + (optionBarOpen ? 45 : 0);
+    const sideBarTop = (organization ? 95 : 30) + (optionBarOpen ? 45 : 0);
+    const contentTop = optionBarOpen ? 65 : 20;
 
     return (
       <div>
@@ -137,7 +138,7 @@ export default class AllProjects extends React.PureComponent {
 
         <div className="layout-page projects-page">
           <div className="layout-page-side-outer">
-            <div className="layout-page-side projects-page-side" style={{ top }}>
+            <div className="layout-page-side projects-page-side" style={{ top: sideBarTop }}>
               <div className="layout-page-side-inner">
                 <div className="layout-page-filters">
                   <PageSidebar
@@ -152,13 +153,16 @@ export default class AllProjects extends React.PureComponent {
             </div>
           </div>
 
-          <div className="layout-page-main">
+          <div
+            className="layout-page-main projects-page-content"
+            style={{ paddingTop: contentTop }}>
             <div className="layout-page-main-inner">
               <PageHeaderContainer
                 query={query}
                 isFavorite={isFavorite}
                 organization={organization}
                 onOpenOptionBar={this.openOptionBar}
+                optionBarOpen={optionBarOpen}
               />
               {view !== 'visualizations' &&
                 <ProjectsListContainer
index 00022b1954595f208bde5a5789ec3fd0e8872157..b4104652feb8dfd4401a97e8260b5e5e0113ad9a 100644 (file)
@@ -26,6 +26,7 @@ type Props = {
   isFavorite?: boolean,
   loading: boolean,
   onOpenOptionBar: () => void,
+  optionBarOpen?: boolean,
   organization?: { key: string },
   query: { [string]: string },
   total?: number
@@ -40,11 +41,13 @@ export default function PageHeader(props: Props) {
         query={props.query}
       />
       <div className="page-actions projects-page-actions text-right">
-        <div className="spacer-bottom">
-          <a className="button js-projects-topbar-open" href="#" onClick={props.onOpenOptionBar}>
+        {!props.optionBarOpen &&
+          <a
+            className="button js-projects-topbar-open spacer-right"
+            href="#"
+            onClick={props.onOpenOptionBar}>
             {translate('projects.view_settings')}
-          </a>
-        </div>
+          </a>}
 
         {!!props.loading && <i className="spinner spacer-right" />}
 
index 14a0b01f4b2f723389bbbca42a60e98b70173270..ada472b4beb887ac4581f75efb6a5ebbe4293b84 100644 (file)
@@ -20,7 +20,6 @@
 //@flow
 import React from 'react';
 import classNames from 'classnames';
-import CloseIcon from '../../../components/icons-components/CloseIcon';
 import Tooltip from '../../../components/controls/Tooltip';
 import PerspectiveSelect from './PerspectiveSelect';
 import ProjectsSortingSelect from './ProjectsSortingSelect';
@@ -83,17 +82,19 @@ export default class ProjectsOptionBar extends React.PureComponent {
     return (
       <div className="projects-topbar">
         <div className={classNames('projects-topbar-actions', { open })}>
-          <a className="projects-topbar-button button-icon" href="#" onClick={this.closeBar}>
-            <CloseIcon />
-          </a>
           <div className="projects-topbar-actions-inner">
-            <PerspectiveSelect
-              className="projects-topbar-item js-projects-perspective-select"
-              onChange={this.props.onPerspectiveChange}
-              view={this.props.view}
-              visualization={this.props.visualization}
-            />
-            {this.renderSortingSelect()}
+            <button className="projects-topbar-button" onClick={this.closeBar}>
+              {translate('close')}
+            </button>
+            <div className="projects-topbar-items">
+              <PerspectiveSelect
+                className="projects-topbar-item js-projects-perspective-select"
+                onChange={this.props.onPerspectiveChange}
+                view={this.props.view}
+                visualization={this.props.visualization}
+              />
+              {this.renderSortingSelect()}
+            </div>
           </div>
         </div>
       </div>
index 5b08f5d644ec6642b29ddc2242d4fc409b924032..446bf98b57aa2f5121f9c0c1948d2c8fb6902e8e 100644 (file)
@@ -49,6 +49,6 @@ it('should render disabled sorting options for visualizations', () => {
 it('should call close method correctly', () => {
   const toggle = jest.fn();
   const wrapper = shallow(<ProjectsOptionBar open={true} view="leak" onToggleOptionBar={toggle} />);
-  click(wrapper.find('a.projects-topbar-button'));
+  click(wrapper.find('.projects-topbar-button'));
   expect(toggle.mock.calls).toMatchSnapshot();
 });
index 9783b6a6c35b0f2989d0d9c0fc58f63a7a0d87a8..c554011553ed7d5867dda097350111cf69a72ade 100644 (file)
@@ -14,16 +14,12 @@ exports[`should render correctly 1`] = `
   <div
     className="page-actions projects-page-actions text-right"
   >
-    <div
-      className="spacer-bottom"
+    <a
+      className="button js-projects-topbar-open spacer-right"
+      href="#"
     >
-      <a
-        className="button js-projects-topbar-open"
-        href="#"
-      >
-        projects.view_settings
-      </a>
-    </div>
+      projects.view_settings
+    </a>
     <span>
       <strong
         id="projects-total"
@@ -52,16 +48,12 @@ exports[`should render correctly while loading 1`] = `
   <div
     className="page-actions projects-page-actions text-right"
   >
-    <div
-      className="spacer-bottom"
+    <a
+      className="button js-projects-topbar-open spacer-right"
+      href="#"
     >
-      <a
-        className="button js-projects-topbar-open"
-        href="#"
-      >
-        projects.view_settings
-      </a>
-    </div>
+      projects.view_settings
+    </a>
     <i
       className="spinner spacer-right"
     />
index 5b5ca60dce644decb539f15e0bf8e128152d23e6..12099c9db00645ba3617ef3f9e05939f3e01b303 100644 (file)
@@ -15,32 +15,35 @@ exports[`should render disabled sorting options for visualizations 1`] = `
   <div
     className="projects-topbar-actions open"
   >
-    <a
-      className="projects-topbar-button button-icon"
-      href="#"
-      onClick={[Function]}
-    >
-      <CloseIcon />
-    </a>
     <div
       className="projects-topbar-actions-inner"
     >
-      <PerspectiveSelect
-        className="projects-topbar-item js-projects-perspective-select"
-        view="visualizations"
-        visualization="coverage"
-      />
-      <Tooltip
-        overlay="projects.sort.disabled"
-        placement="bottom"
+      <button
+        className="projects-topbar-button"
+        onClick={[Function]}
+      >
+        close
+      </button>
+      <div
+        className="projects-topbar-items"
       >
-        <div>
-          <ProjectsSortingSelect
-            className="projects-topbar-item js-projects-sorting-select disabled"
-            view="visualizations"
-          />
-        </div>
-      </Tooltip>
+        <PerspectiveSelect
+          className="projects-topbar-item js-projects-perspective-select"
+          view="visualizations"
+          visualization="coverage"
+        />
+        <Tooltip
+          overlay="projects.sort.disabled"
+          placement="bottom"
+        >
+          <div>
+            <ProjectsSortingSelect
+              className="projects-topbar-item js-projects-sorting-select disabled"
+              view="visualizations"
+            />
+          </div>
+        </Tooltip>
+      </div>
     </div>
   </div>
 </div>
@@ -53,24 +56,27 @@ exports[`should render option bar closed 1`] = `
   <div
     className="projects-topbar-actions"
   >
-    <a
-      className="projects-topbar-button button-icon"
-      href="#"
-      onClick={[Function]}
-    >
-      <CloseIcon />
-    </a>
     <div
       className="projects-topbar-actions-inner"
     >
-      <PerspectiveSelect
-        className="projects-topbar-item js-projects-perspective-select"
-        view="overall"
-      />
-      <ProjectsSortingSelect
-        className="projects-topbar-item js-projects-sorting-select"
-        view="overall"
-      />
+      <button
+        className="projects-topbar-button"
+        onClick={[Function]}
+      >
+        close
+      </button>
+      <div
+        className="projects-topbar-items"
+      >
+        <PerspectiveSelect
+          className="projects-topbar-item js-projects-perspective-select"
+          view="overall"
+        />
+        <ProjectsSortingSelect
+          className="projects-topbar-item js-projects-sorting-select"
+          view="overall"
+        />
+      </div>
     </div>
   </div>
 </div>
@@ -83,25 +89,28 @@ exports[`should render option bar open 1`] = `
   <div
     className="projects-topbar-actions open"
   >
-    <a
-      className="projects-topbar-button button-icon"
-      href="#"
-      onClick={[Function]}
-    >
-      <CloseIcon />
-    </a>
     <div
       className="projects-topbar-actions-inner"
     >
-      <PerspectiveSelect
-        className="projects-topbar-item js-projects-perspective-select"
-        view="leak"
-        visualization="risk"
-      />
-      <ProjectsSortingSelect
-        className="projects-topbar-item js-projects-sorting-select"
-        view="leak"
-      />
+      <button
+        className="projects-topbar-button"
+        onClick={[Function]}
+      >
+        close
+      </button>
+      <div
+        className="projects-topbar-items"
+      >
+        <PerspectiveSelect
+          className="projects-topbar-item js-projects-perspective-select"
+          view="leak"
+          visualization="risk"
+        />
+        <ProjectsSortingSelect
+          className="projects-topbar-item js-projects-sorting-select"
+          view="leak"
+        />
+      </div>
     </div>
   </div>
 </div>
index 0cb08e097d105c506703805a444870323da15f50..2243200772e25f7f8734e77098a4cf270312e8bf 100644 (file)
@@ -6,6 +6,10 @@
   transition: top 150ms ease-out;
 }
 
+.projects-page-content {
+  transition: padding-top 150ms ease-out;
+}
+
 .projects-topbar {
   position: fixed;
   width: 100%;
   left: 0;
   right: 0;
   top: -50px;
-  display: flex;
-  flex-direction: row-reverse;
   z-index: 50;
   flex-grow: 0.000001;
+  border-bottom: 1px solid #e6e6e6;
   background-color: #fff;
   transition: top 150ms ease-out;
 }
 }
 
 .projects-topbar-actions-inner {
+  position: relative;
+  margin: auto;
+  padding: 0 20px;
+  min-width: 1040px;
+  max-width: 1280px;
+}
+
+.projects-topbar-items {
   display: flex;
   flex-wrap: nowrap;
   justify-content: center;
   align-items: center;
   flex-grow: 1;
-  border-bottom: 1px solid #e6e6e6;
+  height: 46px;
 }
 
 .projects-topbar-item {
 }
 
 .projects-topbar-button {
-  box-sizing: border-box;
-  float: right;
-  padding: 11px;
-  padding-top: 15px;
-  border: none;
-  border-left: 1px solid #e6e6e6;
-  border-bottom: 1px solid #e6e6e6;
-  width: 46px;
-  height: 46px;
-  text-align: center;
-  text-decoration: none;
-  cursor: pointer;
+  position: absolute;
+  right: 20px;
+  top: 10px;
 }
 
 .projects-sidebar {