component={this.props.component}
conf={this.props.conf}
incremental={this.state.incremental}
+ isInProgress={this.state.isInProgress}
+ isFailed={this.state.isFailed}
+ isPending={this.state.isPending}
/>
<ComponentNavMenu
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
+import * as classNames from 'classnames';
import IncrementalBadge from './IncrementalBadge';
import BranchStatus from '../../../../components/common/BranchStatus';
import { Branch, Component, ComponentConfiguration } from '../../../types';
(window as any).baseUrl +
`/project/background_tasks?id=${encodeURIComponent(props.component.key)}`;
+ const shortBranch = props.branch && isShortLivingBranch(props.branch);
+
if (props.isInProgress) {
const tooltip = canSeeBackgroundTasks
? translateWithParameters('component_navigation.status.in_progress.admin', backgroundTasksUrl)
key="isInProgress"
overlay={<div dangerouslySetInnerHTML={{ __html: tooltip }} />}
mouseLeaveDelay={2}>
- <li>
+ <li className={classNames({ 'navbar-context-meta-branch': shortBranch })}>
<i className="spinner" style={{ marginTop: '-1px' }} />{' '}
<span className="text-info">{translate('background_task.status.IN_PROGRESS')}</span>
</li>
key="isPending"
overlay={<div dangerouslySetInnerHTML={{ __html: tooltip }} />}
mouseLeaveDelay={2}>
- <li>
+ <li className={classNames({ 'navbar-context-meta-branch': shortBranch })}>
<PendingIcon /> <span>{translate('background_task.status.PENDING')}</span>
</li>
</Tooltip>
key="isFailed"
overlay={<div dangerouslySetInnerHTML={{ __html: tooltip }} />}
mouseLeaveDelay={2}>
- <li>
+ <li className={classNames({ 'navbar-context-meta-branch': shortBranch })}>
<span className="badge badge-danger">
{translate('background_task.status.FAILED')}
</span>
);
}
- if (props.component.analysisDate && (!props.branch || !isShortLivingBranch(props.branch))) {
+ if (props.component.analysisDate && !shortBranch) {
metaList.push(
<li key="analysisDate">
<DateTimeFormatter date={props.component.analysisDate} />
);
}
- if (props.component.version && (!props.branch || !isShortLivingBranch(props.branch))) {
+ if (props.component.version && !shortBranch) {
metaList.push(
<li key="version">
Version {props.component.version}
if (props.incremental) {
metaList.push(
- <li key="incremental">
+ <li key="incremental" className={classNames({ 'navbar-context-meta-branch': shortBranch })}>
<IncrementalBadge />
</li>
);
}
- if (props.branch && isShortLivingBranch(props.branch)) {
+ if (shortBranch) {
metaList.push(
<li className="navbar-context-meta-branch" key="branch-status">
- <BranchStatus branch={props.branch} />
+ <BranchStatus branch={props.branch!} />
</li>
);
}
--- /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.
+ */
+
+jest.mock('../ComponentNavFavorite', () => ({
+ default: function ComponentNavFavorite() {
+ return null;
+ }
+}));
+
+jest.mock('../ComponentNavBreadcrumbs', () => ({
+ default: function ComponentNavBreadcrumbs() {
+ return null;
+ }
+}));
+
+jest.mock('../ComponentNavMenu', () => ({
+ default: function ComponentNavMenu() {
+ return null;
+ }
+}));
+
+jest.mock('../../../RecentHistory', () => ({
+ default: { add: jest.fn() }
+}));
+
+jest.mock('../../../../../api/ce', () => ({
+ getTasksForComponent: jest.fn(() => Promise.resolve({ queue: [] }))
+}));
+
+import * as React from 'react';
+import { mount, shallow } from 'enzyme';
+import ComponentNav from '../ComponentNav';
+
+const getTasksForComponent = require('../../../../../api/ce').getTasksForComponent as jest.Mock<
+ any
+>;
+
+const component = {
+ breadcrumbs: [{ key: 'component', name: 'component', qualifier: 'TRK' }],
+ key: 'component',
+ name: 'component',
+ organization: 'org',
+ qualifier: 'TRK'
+};
+
+it('loads status', () => {
+ getTasksForComponent.mockClear();
+ mount(<ComponentNav branches={[]} component={component} conf={{}} location={{}} />);
+ expect(getTasksForComponent).toBeCalledWith('component');
+});
+
+it('renders', () => {
+ const wrapper = shallow(
+ <ComponentNav branches={[]} component={component} conf={{}} location={{}} />
+ );
+ wrapper.setState({
+ incremental: true,
+ isFailed: true,
+ isInProgress: true,
+ isPending: true
+ });
+ expect(wrapper).toMatchSnapshot();
+});
--- /dev/null
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`renders 1`] = `
+<ContextNavBar
+ height={65}
+ id="context-navigation"
+>
+ <ComponentNavFavorite
+ component="component"
+ />
+ <ComponentNavBreadcrumbs
+ breadcrumbs={
+ Array [
+ Object {
+ "key": "component",
+ "name": "component",
+ "qualifier": "TRK",
+ },
+ ]
+ }
+ component={
+ Object {
+ "breadcrumbs": Array [
+ Object {
+ "key": "component",
+ "name": "component",
+ "qualifier": "TRK",
+ },
+ ],
+ "key": "component",
+ "name": "component",
+ "organization": "org",
+ "qualifier": "TRK",
+ }
+ }
+ />
+ <ComponentNavMeta
+ component={
+ Object {
+ "breadcrumbs": Array [
+ Object {
+ "key": "component",
+ "name": "component",
+ "qualifier": "TRK",
+ },
+ ],
+ "key": "component",
+ "name": "component",
+ "organization": "org",
+ "qualifier": "TRK",
+ }
+ }
+ conf={Object {}}
+ incremental={true}
+ isFailed={true}
+ isInProgress={true}
+ isPending={true}
+ />
+ <ComponentNavMenu
+ component={
+ Object {
+ "breadcrumbs": Array [
+ Object {
+ "key": "component",
+ "name": "component",
+ "qualifier": "TRK",
+ },
+ ],
+ "key": "component",
+ "name": "component",
+ "organization": "org",
+ "qualifier": "TRK",
+ }
+ }
+ conf={Object {}}
+ location={Object {}}
+ />
+</ContextNavBar>
+`;