]> source.dussan.org Git - sonarqube.git/commitdiff
apply applications feedback (#2297)
authorStas Vilchik <stas.vilchik@sonarsource.com>
Thu, 27 Jul 2017 07:13:54 +0000 (09:13 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 31 Jul 2017 09:27:51 +0000 (11:27 +0200)
server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js
server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js
server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.js
server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.js
server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.js
server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAnalysesList-test.js
server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityPageHeader-test.js
server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityAnalysesList-test.js.snap
server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityApp-test.js.snap
server/sonar-web/src/main/js/apps/projectActivity/components/projectActivity.css
server/sonar-web/src/main/js/apps/projectActivity/utils.js

index e6622a72ef7776ba6ce6c70b49a5e71516767352..a7e94e0ef84e0cd41d89d3cebd9a317b5c7052d7 100644 (file)
@@ -44,6 +44,7 @@ type Props = {
   deleteAnalysis: (analysis: string) => Promise<*>,
   deleteEvent: (analysis: string, event: string) => Promise<*>,
   loading: boolean,
+  project: { qualifier: string },
   query: Query,
   updateQuery: RawQuery => void
 };
@@ -166,7 +167,8 @@ export default class ProjectActivityAnalysesList extends React.PureComponent {
       <ul
         className={classNames('project-activity-versions-list', this.props.className)}
         onScroll={this.handleScroll}
-        ref={element => (this.scrollContainer = element)}>
+        ref={element => (this.scrollContainer = element)}
+        style={{ paddingTop: this.props.project.qualifier === 'APP' ? undefined : 52 }}>
         {byVersionByDay.map((version, idx) => {
           const days = Object.keys(version.byDay);
           if (days.length <= 0) {
@@ -197,6 +199,7 @@ export default class ProjectActivityAnalysesList extends React.PureComponent {
                             addVersion={this.props.addVersion}
                             analysis={analysis}
                             canAdmin={this.props.canAdmin}
+                            canCreateVersion={this.props.project.qualifier !== 'APP'}
                             changeEvent={this.props.changeEvent}
                             deleteAnalysis={this.props.deleteAnalysis}
                             deleteEvent={this.props.deleteEvent}
index a94b2f6ce26cbfd3ed1d72cb75d5c37326c91588..72067b95261d58ecbfe9f204622010a67432598e 100644 (file)
@@ -32,6 +32,7 @@ type Props = {
   addVersion: (analysis: string, version: string) => Promise<*>,
   analysis: Analysis,
   canAdmin: boolean,
+  canCreateVersion: boolean,
   changeEvent: (event: string, name: string) => Promise<*>,
   deleteAnalysis: (analysis: string) => Promise<*>,
   deleteEvent: (analysis: string, event: string) => Promise<*>,
@@ -77,6 +78,7 @@ export default class ProjectActivityAnalysis extends React.PureComponent {
               </button>
               <ul className="dropdown-menu dropdown-menu-right">
                 {!hasVersion &&
+                  this.props.canCreateVersion &&
                   <li>
                     <AddEventForm
                       addEvent={this.props.addVersion}
index 0af7a5acd8597bb9d3da53ad32bf88a8ea67bbeb..fb825ed45add11ccf0d7b7aa02d40f51563f7da2 100644 (file)
@@ -38,7 +38,12 @@ type Props = {
   deleteEvent: (analysis: string, event: string) => Promise<*>,
   graphLoading: boolean,
   loading: boolean,
-  project: { configuration?: { showHistory: boolean }, key: string, leakPeriodDate: string },
+  project: {
+    configuration?: { showHistory: boolean },
+    key: string,
+    leakPeriodDate: string,
+    qualifier: string
+  },
   metrics: Array<Metric>,
   measuresHistory: Array<MeasureHistory>,
   query: Query,
@@ -56,6 +61,7 @@ export default function ProjectActivityApp(props: Props) {
       <ProjectActivityPageHeader
         category={query.category}
         from={query.from}
+        project={props.project}
         to={query.to}
         updateQuery={props.updateQuery}
       />
@@ -73,6 +79,7 @@ export default function ProjectActivityApp(props: Props) {
             deleteAnalysis={props.deleteAnalysis}
             deleteEvent={props.deleteEvent}
             loading={props.loading}
+            project={props.project}
             query={props.query}
             updateQuery={props.updateQuery}
           />
index 1f9a5f2ab91f8bbfcc407ff3e42e62bafc033b70..0ca8c21f1a6bbfd0094b5ab0299427b60d028cfe 100644 (file)
@@ -44,7 +44,12 @@ import type { Analysis, MeasureHistory, Metric, Paging, Query } from '../types';
 
 type Props = {
   location: { pathname: string, query: RawQuery },
-  project: { configuration?: { showHistory: boolean }, key: string, leakPeriodDate: string },
+  project: {
+    configuration?: { showHistory: boolean },
+    key: string,
+    leakPeriodDate: string,
+    qualifier: string
+  },
   router: {
     push: ({ pathname: string, query?: RawQuery }) => void,
     replace: ({ pathname: string, query?: RawQuery }) => void
index 2f468c7c77643833be34f27a72ead1d55ad159e0..969af31ee63f1113b4c3514d6fb2aecb6cb4843e 100644 (file)
@@ -23,13 +23,14 @@ import Select from 'react-select';
 import ProjectActivityEventSelectOption from './ProjectActivityEventSelectOption';
 import ProjectActivityEventSelectValue from './ProjectActivityEventSelectValue';
 import ProjectActivityDateInput from './ProjectActivityDateInput';
-import { EVENT_TYPES } from '../utils';
+import { EVENT_TYPES, APPLICATION_EVENT_TYPES } from '../utils';
 import { translate } from '../../../helpers/l10n';
 import type { RawQuery } from '../../../helpers/query';
 
 type Props = {
   category?: string,
   from: ?Date,
+  project: { qualifier: string },
   to: ?Date,
   updateQuery: RawQuery => void
 };
@@ -38,18 +39,17 @@ export default class ProjectActivityPageHeader extends React.PureComponent {
   options: Array<{ label: string, value: string }>;
   props: Props;
 
-  constructor(props: Props) {
-    super(props);
-    this.options = EVENT_TYPES.map(category => ({
-      label: translate('event.category', category),
-      value: category
-    }));
-  }
-
   handleCategoryChange = (option: ?{ value: string }) =>
     this.props.updateQuery({ category: option ? option.value : '' });
 
   render() {
+    const eventTypes =
+      this.props.project.qualifier === 'APP' ? APPLICATION_EVENT_TYPES : EVENT_TYPES;
+    this.options = eventTypes.map(category => ({
+      label: translate('event.category', category),
+      value: category
+    }));
+
     return (
       <header className="page-header">
         <Select
index 147fdeca7d611bf86b062b2ece807703f19baaee..c3d7833dd5dca8eef347e67f37d60de06ef1857f 100644 (file)
@@ -78,6 +78,7 @@ const DEFAULT_PROPS = {
   deleteAnalysis: () => {},
   deleteEvent: () => {},
   loading: false,
+  project: { qualifier: 'TRK' },
   query: { category: '', graph: DEFAULT_GRAPH, project: 'org.sonarsource.sonarqube:sonarqube' },
   updateQuery: () => {}
 };
index 9fe17ba339a2a545a0bfb55a5e1560aa20ab4dea..f6faa2a1efabca7fcfcf8b03bbfec8c0fa9823bc 100644 (file)
@@ -27,6 +27,7 @@ it('should render correctly the list of series', () => {
       <ProjectActivityPageHeader
         category=""
         from={new Date('2016-10-27T12:21:15+0200')}
+        project={{}}
         updateQuery={() => {}}
       />
     )
index 53dc51ec3514c0fcfd1cdec81d993fe8a6c834c3..482868b4505321bfdb030981bab249891328eff6 100644 (file)
@@ -4,6 +4,11 @@ exports[`should correctly filter analyses by category 1`] = `
 <ul
   className="project-activity-versions-list"
   onScroll={[Function]}
+  style={
+    Object {
+      "paddingTop": 52,
+    }
+  }
 >
   <li>
     <div
@@ -50,6 +55,7 @@ exports[`should correctly filter analyses by category 1`] = `
               }
             }
             canAdmin={false}
+            canCreateVersion={true}
             changeEvent={[Function]}
             deleteAnalysis={[Function]}
             deleteEvent={[Function]}
@@ -68,6 +74,11 @@ exports[`should correctly filter analyses by date range 1`] = `
 <ul
   className="project-activity-versions-list"
   onScroll={[Function]}
+  style={
+    Object {
+      "paddingTop": 52,
+    }
+  }
 >
   <li>
     <div
@@ -114,6 +125,7 @@ exports[`should correctly filter analyses by date range 1`] = `
               }
             }
             canAdmin={false}
+            canCreateVersion={true}
             changeEvent={[Function]}
             deleteAnalysis={[Function]}
             deleteEvent={[Function]}
@@ -132,6 +144,11 @@ exports[`should render correctly 1`] = `
 <ul
   className="project-activity-versions-list"
   onScroll={[Function]}
+  style={
+    Object {
+      "paddingTop": 52,
+    }
+  }
 >
   <li>
     <div
@@ -178,6 +195,7 @@ exports[`should render correctly 1`] = `
               }
             }
             canAdmin={false}
+            canCreateVersion={true}
             changeEvent={[Function]}
             deleteAnalysis={[Function]}
             deleteEvent={[Function]}
@@ -228,6 +246,7 @@ exports[`should render correctly 1`] = `
               }
             }
             canAdmin={false}
+            canCreateVersion={true}
             changeEvent={[Function]}
             deleteAnalysis={[Function]}
             deleteEvent={[Function]}
@@ -274,6 +293,7 @@ exports[`should render correctly 1`] = `
               }
             }
             canAdmin={false}
+            canCreateVersion={true}
             changeEvent={[Function]}
             deleteAnalysis={[Function]}
             deleteEvent={[Function]}
@@ -321,6 +341,7 @@ exports[`should render correctly 1`] = `
               }
             }
             canAdmin={false}
+            canCreateVersion={true}
             changeEvent={[Function]}
             deleteAnalysis={[Function]}
             deleteEvent={[Function]}
index 9912ce833fcb0afa902c064412f5fbf2d7ad8b51..9a69a6e5a04e281983f4293358ae38029eb710de 100644 (file)
@@ -11,6 +11,12 @@ exports[`should render correctly 1`] = `
   />
   <ProjectActivityPageHeader
     category=""
+    project={
+      Object {
+        "key": "org.sonarsource.sonarqube:sonarqube",
+        "leakPeriodDate": "2017-05-16T13:50:02+0200",
+      }
+    }
     updateQuery={[Function]}
   />
   <div
@@ -65,6 +71,12 @@ exports[`should render correctly 1`] = `
         deleteAnalysis={[Function]}
         deleteEvent={[Function]}
         loading={false}
+        project={
+          Object {
+            "key": "org.sonarsource.sonarqube:sonarqube",
+            "leakPeriodDate": "2017-05-16T13:50:02+0200",
+          }
+        }
         query={
           Object {
             "category": "",
index e7688258d11811ebb199ed7c48033e75a0ed10c9..41ba543df0b90819c04d50113d7732071e5a3c64 100644 (file)
@@ -40,7 +40,6 @@
   overflow: auto;
   flex-grow: 1;
   flex-shrink: 0;
-  padding-top: 52px;
 }
 
 .project-activity-graphs {
index 63558f363cf519a2f07b1971f08d319cc2fa1436..029092481cc6b12b6ada9dedad7fecc0a92d80e9 100644 (file)
@@ -35,6 +35,7 @@ import type { RawQuery } from '../../helpers/query';
 import type { Serie } from '../../components/charts/AdvancedTimeline';
 
 export const EVENT_TYPES = ['VERSION', 'QUALITY_GATE', 'QUALITY_PROFILE', 'OTHER'];
+export const APPLICATION_EVENT_TYPES = ['QUALITY_GATE', 'OTHER'];
 export const DEFAULT_GRAPH = 'issues';
 export const GRAPH_TYPES = ['issues', 'coverage', 'duplications', 'custom'];
 export const GRAPHS_METRICS_DISPLAYED = {