From: Grégoire Aubert Date: Fri, 7 Jul 2017 15:12:00 +0000 (+0200) Subject: Apply several feedbacks X-Git-Tag: 6.5-RC1~15 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b5e582ccc44788e5d57dde7df2ed0b0050f82c1a;p=sonarqube.git Apply several feedbacks * Fix dates serializing * Prevent clicks on event button to activate the graph tooltip * Throttle part of the zoom graph * Reload history when an analysis is deleted * Fix multiple style flaws --- diff --git a/server/sonar-web/src/main/js/api/projectActivity.js b/server/sonar-web/src/main/js/api/projectActivity.js index 8ffe600e8df..19dd91243dc 100644 --- a/server/sonar-web/src/main/js/api/projectActivity.js +++ b/server/sonar-web/src/main/js/api/projectActivity.js @@ -19,6 +19,7 @@ */ // @flow import { getJSON, postJSON, post } from '../helpers/request'; +import throwGlobalError from '../app/utils/throwGlobalError'; type GetProjectActivityResponse = { analyses: Array, @@ -38,7 +39,8 @@ type GetProjectActivityOptions = { export const getProjectActivity = ( data: GetProjectActivityOptions -): Promise => getJSON('/api/project_analyses/search', data); +): Promise => + getJSON('/api/project_analyses/search', data).catch(throwGlobalError); type CreateEventResponse = { analysis: string, @@ -61,11 +63,11 @@ export const createEvent = ( if (description) { data.description = description; } - return postJSON('/api/project_analyses/create_event', data).then(r => r.event); + return postJSON('/api/project_analyses/create_event', data).then(r => r.event, throwGlobalError); }; export const deleteEvent = (event: string): Promise<*> => - post('/api/project_analyses/delete_event', { event }); + post('/api/project_analyses/delete_event', { event }).catch(throwGlobalError); export const changeEvent = ( event: string, @@ -79,8 +81,8 @@ export const changeEvent = ( if (description) { data.description = description; } - return postJSON('/api/project_analyses/update_event', data).then(r => r.event); + return postJSON('/api/project_analyses/update_event', data).then(r => r.event, throwGlobalError); }; export const deleteAnalysis = (analysis: string): Promise<*> => - post('/api/project_analyses/delete', { analysis }); + post('/api/project_analyses/delete', { analysis }).catch(throwGlobalError); diff --git a/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.js b/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.js index 9746ea02c4a..05856e6601e 100644 --- a/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.js +++ b/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.js @@ -22,7 +22,6 @@ import React from 'react'; import { Link } from 'react-router'; import Analysis from './Analysis'; import PreviewGraph from './PreviewGraph'; -import throwGlobalError from '../../../app/utils/throwGlobalError'; import { getMetrics } from '../../../api/metrics'; import { getProjectActivity } from '../../../api/projectActivity'; import { translate } from '../../../helpers/l10n'; @@ -72,7 +71,7 @@ export default class AnalysesList extends React.PureComponent { if (this.mounted) { this.setState({ analyses: response[0].analyses, metrics: response[1], loading: false }); } - }, throwGlobalError); + }); } renderList(analyses: Array) { diff --git a/server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.js b/server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.js index d94a9f626c4..c165f9740b8 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.js @@ -88,7 +88,8 @@ jest.mock('moment', () => date => ({ valueOf: () => `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}` }; }, - toDate: () => new Date(date) + toDate: () => new Date(date), + format: format => `Formated.${format}:${date.valueOf()}` })); describe('generateCoveredLinesMetric', () => { @@ -164,11 +165,11 @@ describe('parseQuery', () => { describe('serializeQuery', () => { it('should serialize query for api request', () => { expect(utils.serializeQuery(QUERY)).toEqual({ - from: '2017-04-27T06:21:32.000Z', + from: 'Formated.YYYY-MM-DDTHH:mm:ssZZ:1493274092000', project: 'foo' }); expect(utils.serializeQuery({ ...QUERY, graph: 'coverage', category: 'test' })).toEqual({ - from: '2017-04-27T06:21:32.000Z', + from: 'Formated.YYYY-MM-DDTHH:mm:ssZZ:1493274092000', project: 'foo', category: 'test' }); @@ -178,14 +179,14 @@ describe('serializeQuery', () => { describe('serializeUrlQuery', () => { it('should serialize query for url', () => { expect(utils.serializeUrlQuery(QUERY)).toEqual({ - from: '2017-04-27T06:21:32.000Z', + from: 'Formated.YYYY-MM-DDTHH:mm:ssZZ:1493274092000', id: 'foo', custom_metrics: 'foo,bar,baz' }); expect( utils.serializeUrlQuery({ ...QUERY, graph: 'coverage', category: 'test', customMetrics: [] }) ).toEqual({ - from: '2017-04-27T06:21:32.000Z', + from: 'Formated.YYYY-MM-DDTHH:mm:ssZZ:1493274092000', id: 'foo', graph: 'coverage', category: 'test' diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/Event.js b/server/sonar-web/src/main/js/apps/projectActivity/components/Event.js index 6e1a3878c88..f5bc0579b16 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/Event.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/Event.js @@ -56,7 +56,8 @@ export default class Event extends React.PureComponent { this.mounted = false; } - startChanging = () => { + startChanging = (e: MouseEvent) => { + e.stopPropagation(); this.setState({ changing: true }); }; @@ -66,7 +67,8 @@ export default class Event extends React.PureComponent { } }; - startDeleting = () => { + startDeleting = (e: MouseEvent) => { + e.stopPropagation(); this.setState({ deleting: true }); }; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js index 9c98102a95e..a0a8a41dd31 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js @@ -118,6 +118,7 @@ export default class ProjectActivityAnalysesList extends React.PureComponent { } } }; + handleScroll = () => this.updateStickyBadges(true); resetScrollTop = (newScrollTop: number, forceBadgeAlignement?: boolean) => { diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js index 842b3ff8a44..72490f7d41b 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js @@ -45,6 +45,8 @@ export default class ProjectActivityAnalysis extends React.PureComponent { handleClick = () => this.props.updateSelectedDate(this.props.analysis.date); + stopPropagation = (e: Event) => e.stopPropagation(); + render() { const { analysis, isFirst, canAdmin } = this.props; const { date, events } = analysis; @@ -69,7 +71,8 @@ export default class ProjectActivityAnalysis extends React.PureComponent {