this.setState({
isPending: r.queue.some(task => task.status === STATUSES.PENDING),
isInProgress: r.queue.some(task => task.status === STATUSES.IN_PROGRESS),
- isFailed: r.current && r.current.status === STATUSES.FAILED
+ isFailed: r.current && r.current.status === STATUSES.FAILED,
+ incremental: r.current && r.current.incremental
});
}
});
*/
import moment from 'moment';
import React from 'react';
+import IncrementalBadge from './IncrementalBadge';
import PendingIcon from '../../../../components/shared/pending-icon';
import { translate, translateWithParameters } from '../../../../helpers/l10n';
-export default class ComponentNavMeta extends React.PureComponent {
- render() {
- const metaList = [];
- const canSeeBackgroundTasks = this.props.conf.showBackgroundTasks;
- const backgroundTasksUrl =
- window.baseUrl +
- `/project/background_tasks?id=${encodeURIComponent(this.props.component.key)}`;
+export default function ComponentNavMeta(props) {
+ const metaList = [];
+ const canSeeBackgroundTasks = props.conf.showBackgroundTasks;
+ const backgroundTasksUrl =
+ window.baseUrl + `/project/background_tasks?id=${encodeURIComponent(props.component.key)}`;
- if (this.props.isInProgress) {
- const tooltip = canSeeBackgroundTasks
- ? translateWithParameters(
- 'component_navigation.status.in_progress.admin',
- backgroundTasksUrl
- )
- : translate('component_navigation.status.in_progress');
- metaList.push(
- <li key="isInProgress" data-toggle="tooltip" title={tooltip}>
- <i className="spinner" style={{ marginTop: '-1px' }} />{' '}
- <span className="text-info">{translate('background_task.status.IN_PROGRESS')}</span>
- </li>
- );
- } else if (this.props.isPending) {
- const tooltip = canSeeBackgroundTasks
- ? translateWithParameters('component_navigation.status.pending.admin', backgroundTasksUrl)
- : translate('component_navigation.status.pending');
- metaList.push(
- <li key="isPending" data-toggle="tooltip" title={tooltip}>
- <PendingIcon /> <span>{translate('background_task.status.PENDING')}</span>
- </li>
- );
- } else if (this.props.isFailed) {
- const tooltip = canSeeBackgroundTasks
- ? translateWithParameters('component_navigation.status.failed.admin', backgroundTasksUrl)
- : translate('component_navigation.status.failed');
- metaList.push(
- <li key="isFailed" data-toggle="tooltip" title={tooltip}>
- <span className="badge badge-danger">
- {translate('background_task.status.FAILED')}
- </span>
- </li>
- );
- }
+ if (props.isInProgress) {
+ const tooltip = canSeeBackgroundTasks
+ ? translateWithParameters('component_navigation.status.in_progress.admin', backgroundTasksUrl)
+ : translate('component_navigation.status.in_progress');
+ metaList.push(
+ <li key="isInProgress" data-toggle="tooltip" title={tooltip}>
+ <i className="spinner" style={{ marginTop: '-1px' }} />{' '}
+ <span className="text-info">{translate('background_task.status.IN_PROGRESS')}</span>
+ </li>
+ );
+ } else if (props.isPending) {
+ const tooltip = canSeeBackgroundTasks
+ ? translateWithParameters('component_navigation.status.pending.admin', backgroundTasksUrl)
+ : translate('component_navigation.status.pending');
+ metaList.push(
+ <li key="isPending" data-toggle="tooltip" title={tooltip}>
+ <PendingIcon /> <span>{translate('background_task.status.PENDING')}</span>
+ </li>
+ );
+ } else if (props.isFailed) {
+ const tooltip = canSeeBackgroundTasks
+ ? translateWithParameters('component_navigation.status.failed.admin', backgroundTasksUrl)
+ : translate('component_navigation.status.failed');
+ metaList.push(
+ <li key="isFailed" data-toggle="tooltip" title={tooltip}>
+ <span className="badge badge-danger">
+ {translate('background_task.status.FAILED')}
+ </span>
+ </li>
+ );
+ }
- if (this.props.analysisDate) {
- metaList.push(
- <li key="analysisDate">
- {moment(this.props.analysisDate).format('LLL')}
- </li>
- );
- }
+ if (props.analysisDate) {
+ metaList.push(
+ <li key="analysisDate">
+ {moment(props.analysisDate).format('LLL')}
+ </li>
+ );
+ }
- if (this.props.version) {
- metaList.push(
- <li key="version">
- Version {this.props.version}
- </li>
- );
- }
+ if (props.version) {
+ metaList.push(
+ <li key="version">
+ Version {props.version}
+ </li>
+ );
+ }
- return (
- <div className="navbar-context-meta">
- <ul className="list-inline">
- {metaList}
- </ul>
- </div>
+ if (props.incremental) {
+ metaList.push(
+ <li key="incremental">
+ <IncrementalBadge />
+ </li>
);
}
+
+ return (
+ <div className="navbar-context-meta">
+ <ul className="list-inline">
+ {metaList}
+ </ul>
+ </div>
+ );
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info 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 React from 'react';
+import Tooltip from '../../../../components/controls/Tooltip';
+import { translate } from '../../../../helpers/l10n';
+
+export default function IncrementalBadge() {
+ return (
+ <Tooltip overlay={translate('incremental.project_tooltip')}>
+ <div className="outline-badge">
+ {translate('incremental')}
+ </div>
+ </Tooltip>
+ );
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info 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 React from 'react';
+import { shallow } from 'enzyme';
+import ComponentNavMeta from '../ComponentNavMeta';
+
+it('renders incremental badge', () => {
+ check(true);
+ check(false);
+
+ function check(incremental) {
+ expect(
+ shallow(
+ <ComponentNavMeta component={{ key: 'foo' }} conf={{}} incremental={incremental} />
+ ).find('IncrementalBadge')
+ ).toHaveLength(incremental ? 1 : 0);
+ }
+});
<span className="note nowrap spacer-left">
{'['}
{translate('background_task.type', task.type)}
+ {task.incremental && ` - ${translate('incremental')}`}
{']'}
</span>
);
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info 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.
+ */
+/* @flow */
+import React from 'react';
+import { shallow } from 'enzyme';
+import TaskType from '../TaskType';
+
+it('renders', () => {
+ expect(shallow(<TaskType task={{ id: 'foo' }} />)).toMatchSnapshot();
+ expect(shallow(<TaskType task={{ incremental: true, id: 'foo' }} />)).toMatchSnapshot();
+});
--- /dev/null
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`renders 1`] = `
+<span
+ className="note nowrap spacer-left"
+>
+ [
+ background_task.type.
+ ]
+</span>
+`;
+
+exports[`renders 2`] = `
+<span
+ className="note nowrap spacer-left"
+>
+ [
+ background_task.type.
+ - incremental
+ ]
+</span>
+`;
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
export type Task = {
+ incremental: boolean,
id: string
};
{{name}}
</a>
{{#if isBuiltIn}}
- <span class="built-in-badge spacer-left" data-toggle="tooltip" data-placement="bottom"
+ <span class="outline-badge spacer-left" data-toggle="tooltip" data-placement="bottom"
title="{{t 'quality_profiles.built_in.description.1'}} {{t 'quality_profiles.built_in.description.2'}}">
{{t 'quality_profiles.built_in'}}
</span>
export default function BuiltInBadge(props: Props) {
const badge = (
- <div className={classNames('built-in-badge', props.className)}>
+ <div className={classNames('outline-badge', props.className)}>
{translate('quality_profiles.built_in')}
</div>
);
export default function PrivateBadge({ className, tooltipPlacement = 'bottom' }: Props) {
return (
<Tooltip overlay={translate('visibility.private.description')} placement={tooltipPlacement}>
- <div className={classNames('private-badge', className)}>
+ <div className={classNames('outline-badge', className)}>
{translate('visibility.private')}
</div>
</Tooltip>
background-color: @middleGrey;
}
-.private-badge,
-.built-in-badge {
+.outline-badge {
display: inline-block;
vertical-align: middle;
height: 20px;
identifier_abbreviated=Id
inactive=Inactive
including_abbreviated=incl.
+incremental=Incremental
+incrementa.project_tooltip=Overall project status could be incomplete: incremental mode was used in the last analysis, so only changed files were examined.
info=Info
issue=Issue
issues=Issues