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);
});
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'));
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 {
<Helmet title={translate('background_tasks.page')} />
<Header component={component} />
- <Stats
+ <StatsContainer
component={component}
pendingCount={pendingCount}
failingCount={failingCount}
*/
/* @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
/*:: 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) {
<span className="js-pending-count emphasised-measure">{this.props.pendingCount}</span>
{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 {
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>
{translate('background_tasks.failures')}
</span>
} 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>
{translate('background_tasks.failures')}
</span>
--- /dev/null
+/*
+ * 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);
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