Browse Source

SONAR-9927 Project admins see "Cancel All" button on Background Tasks page

tags/6.7-RC1
Stas Vilchik 6 years ago
parent
commit
7a230c2fa9

+ 12
- 2
server/sonar-web/src/main/js/apps/background-tasks/__tests__/background-tasks-test.js View File

@@ -102,7 +102,12 @@ describe('Stats', () => {

it('should show cancel pending button', () => {
const result = shallow(
<Stats pendingCount={5} onCancelAllPending={stub} onShowFailing={stub} />
<Stats
isSystemAdmin={true}
pendingCount={5}
onCancelAllPending={stub}
onShowFailing={stub}
/>
);
expect(result.find('.js-cancel-pending').length).toBe(1);
});
@@ -110,7 +115,12 @@ describe('Stats', () => {
it('should trigger cancelling pending', () => {
const spy = jest.fn();
const result = shallow(
<Stats pendingCount={5} onCancelAllPending={spy} onShowFailing={stub} />
<Stats
isSystemAdmin={true}
pendingCount={5}
onCancelAllPending={spy}
onShowFailing={stub}
/>
);
expect(spy).not.toBeCalled();
click(result.find('.js-cancel-pending'));

+ 2
- 2
server/sonar-web/src/main/js/apps/background-tasks/components/BackgroundTasksApp.js View File

@@ -26,7 +26,7 @@ import { connect } from 'react-redux';
import { DEFAULT_FILTERS, DEBOUNCE_DELAY, STATUSES, CURRENTS } from './../constants';
import Header from './Header';
import Footer from './Footer';
import Stats from '../components/Stats';
import StatsContainer from '../components/StatsContainer';
import Search from '../components/Search';
import Tasks from '../components/Tasks';
import {
@@ -220,7 +220,7 @@ class BackgroundTasksApp extends React.PureComponent {
<Helmet title={translate('background_tasks.page')} />
<Header component={component} />

<Stats
<StatsContainer
component={component}
pendingCount={pendingCount}
failingCount={failingCount}

+ 30
- 29
server/sonar-web/src/main/js/apps/background-tasks/components/Stats.js View File

@@ -19,11 +19,13 @@
*/
/* @flow */
import React from 'react';
import Tooltip from '../../../components/controls/Tooltip';
import { translate } from '../../../helpers/l10n';

/*::
type Props = {
failingCount: number,
isSystemAdmin?: boolean,
pendingCount: number,
onShowFailing: () => void,
onCancelAllPending: () => void
@@ -38,17 +40,17 @@ export default class Stats extends React.PureComponent {
/*:: props: Props; */
/*:: state: State; */

handleCancelAllPending(e /*: Object */) {
e.preventDefault();
e.target.blur();
handleCancelAllPending = (event /*: Object */) => {
event.preventDefault();
event.currentTarget.blur();
this.props.onCancelAllPending();
}
};

handleShowFailing(e /*: Object */) {
e.preventDefault();
e.target.blur();
handleShowFailing = (event /*: Object */) => {
event.preventDefault();
event.currentTarget.blur();
this.props.onShowFailing();
}
};

renderPending() {
if (this.props.pendingCount == null) {
@@ -60,13 +62,15 @@ export default class Stats extends React.PureComponent {
<span className="js-pending-count emphasised-measure">{this.props.pendingCount}</span>
&nbsp;
{translate('background_tasks.pending')}
<a
onClick={this.handleCancelAllPending.bind(this)}
className="js-cancel-pending icon-delete spacer-left"
title={translate('background_tasks.cancel_all_tasks')}
data-toggle="tooltip"
href="#"
/>
{this.props.isSystemAdmin && (
<Tooltip overlay={translate('background_tasks.cancel_all_tasks')}>
<a
className="js-cancel-pending icon-delete spacer-left"
href="#"
onClick={this.handleCancelAllPending}
/>
</Tooltip>
)}
</span>
);
} else {
@@ -92,14 +96,14 @@ export default class Stats extends React.PureComponent {
if (this.props.failingCount > 0) {
return (
<span>
<a
onClick={this.handleShowFailing.bind(this)}
className="js-failures-count emphasised-measure"
data-toggle="tooltip"
title="Count of projects where processing of most recent analysis report failed"
href="#">
{this.props.failingCount}
</a>
<Tooltip overlay={translate('background_tasks.failing_count')}>
<a
className="js-failures-count emphasised-measure"
href="#"
onClick={this.handleShowFailing}>
{this.props.failingCount}
</a>
</Tooltip>
&nbsp;
{translate('background_tasks.failures')}
</span>
@@ -107,12 +111,9 @@ export default class Stats extends React.PureComponent {
} else {
return (
<span>
<span
className="js-failures-count emphasised-measure"
data-toggle="tooltip"
title="Count of projects where processing of most recent analysis report failed">
{this.props.failingCount}
</span>
<Tooltip overlay={translate('background_tasks.failing_count')}>
<span className="js-failures-count emphasised-measure">{this.props.failingCount}</span>
</Tooltip>
&nbsp;
{translate('background_tasks.failures')}
</span>

+ 28
- 0
server/sonar-web/src/main/js/apps/background-tasks/components/StatsContainer.tsx View File

@@ -0,0 +1,28 @@
/*
* SonarQube
* Copyright (C) 2009-2016 SonarSource SA
* mailto:contact AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { connect } from 'react-redux';
import Stats from './Stats';
import { getAppState } from '../../../store/rootReducer';

const mapStateToProps = (state: any) => ({
isSystemAdmin: !!getAppState(state).canAdmin
});

export default connect(mapStateToProps)(Stats as any);

+ 1
- 0
sonar-core/src/main/resources/org/sonar/l10n/core.properties View File

@@ -2213,6 +2213,7 @@ background_tasks.change_number_of_workers=Edit CE Workers
background_tasks.change_number_of_workers.hint=If your queue backs up behind the analysis reports from large projects, increasing the number of Compute Engine workers will allow you to take full advantage of having configured increased Compute Engine memory on a multi-core server (vertical scaling).
background_tasks.add_more_with_governance=Add more with Governance
background_tasks.search_by_task_or_component=Search by Task or Component
background_tasks.failing_count=Count of projects where processing of most recent analysis report failed




Loading…
Cancel
Save