aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js
diff options
context:
space:
mode:
authorStas Vilchik <stas.vilchik@sonarsource.com>2017-09-01 13:48:40 +0200
committerJanos Gyerik <janos.gyerik@sonarsource.com>2017-09-12 11:34:57 +0200
commit87d44e412ac3b96467ba17c915cfcf45e0bedf22 (patch)
treebb6389c99f31b3c36fdd3478db428f89ff878f5d /server/sonar-web/src/main/js
parent4f4c33f79d27c198d86e105637387c58ca91c166 (diff)
downloadsonarqube-87d44e412ac3b96467ba17c915cfcf45e0bedf22.tar.gz
sonarqube-87d44e412ac3b96467ba17c915cfcf45e0bedf22.zip
SONAR-9736 display analysis date and a version of long-living branch
Diffstat (limited to 'server/sonar-web/src/main/js')
-rw-r--r--server/sonar-web/src/main/js/app/components/ComponentContainer.tsx5
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx4
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMeta-test.tsx26
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavMeta-test.tsx.snap14
4 files changed, 33 insertions, 16 deletions
diff --git a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx
index 27ccf26396e..8aea4c958d8 100644
--- a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx
+++ b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx
@@ -53,7 +53,10 @@ export default class ComponentContainer extends React.PureComponent<Props, State
}
componentDidUpdate(prevProps: Props) {
- if (prevProps.location.query.id !== this.props.location.query.id) {
+ if (
+ prevProps.location.query.id !== this.props.location.query.id ||
+ prevProps.location.query.branch !== this.props.location.query.branch
+ ) {
this.fetchComponent();
}
}
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx
index 3fffc261d4c..3be540c0d4f 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavMeta.tsx
@@ -91,7 +91,7 @@ export default function ComponentNavMeta(props: Props) {
);
}
- if (props.component.analysisDate && (!props.branch || props.branch.isMain)) {
+ if (props.component.analysisDate && (!props.branch || !isShortLivingBranch(props.branch))) {
metaList.push(
<li key="analysisDate">
<DateTimeFormatter date={props.component.analysisDate} />
@@ -99,7 +99,7 @@ export default function ComponentNavMeta(props: Props) {
);
}
- if (props.component.version && (!props.branch || props.branch.isMain)) {
+ if (props.component.version && (!props.branch || !isShortLivingBranch(props.branch))) {
metaList.push(
<li key="version">
Version {props.component.version}
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMeta-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMeta-test.tsx
index 0a94ecf0cfe..6949044c9ca 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMeta-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavMeta-test.tsx
@@ -20,13 +20,17 @@
import * as React from 'react';
import { shallow } from 'enzyme';
import ComponentNavMeta from '../ComponentNavMeta';
-import {
- Branch,
- Component,
- BranchType,
- ShortLivingBranch,
- LongLivingBranch
-} from '../../../../types';
+import { Branch, BranchType, ShortLivingBranch, LongLivingBranch } from '../../../../types';
+
+const component = {
+ analysisDate: '2017-01-02T00:00:00.000Z',
+ breadcrumbs: [],
+ key: 'foo',
+ name: 'Foo',
+ organization: 'org',
+ qualifier: 'TRK',
+ version: '0.0.1'
+};
it('renders incremental badge', () => {
check(true);
@@ -37,7 +41,7 @@ it('renders incremental badge', () => {
shallow(
<ComponentNavMeta
branch={{} as Branch}
- component={{ key: 'foo' } as Component}
+ component={component}
conf={{}}
incremental={incremental}
/>
@@ -55,11 +59,11 @@ it('renders status of short-living branch', () => {
type: BranchType.SHORT
};
expect(
- shallow(<ComponentNavMeta branch={branch} component={{ key: 'foo' } as Component} conf={{}} />)
+ shallow(<ComponentNavMeta branch={branch} component={component} conf={{}} />)
).toMatchSnapshot();
});
-it('renders nothing for long-living branch', () => {
+it('renders meta for long-living branch', () => {
const branch: LongLivingBranch = {
isMain: false,
name: 'release',
@@ -67,6 +71,6 @@ it('renders nothing for long-living branch', () => {
type: BranchType.LONG
};
expect(
- shallow(<ComponentNavMeta branch={branch} component={{ key: 'foo' } as Component} conf={{}} />)
+ shallow(<ComponentNavMeta branch={branch} component={component} conf={{}} />)
).toMatchSnapshot();
});
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavMeta-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavMeta-test.tsx.snap
index 4b296afc2bf..97421e0df87 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavMeta-test.tsx.snap
+++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavMeta-test.tsx.snap
@@ -1,12 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`renders nothing for long-living branch 1`] = `
+exports[`renders meta for long-living branch 1`] = `
<div
className="navbar-context-meta"
>
<ul
className="list-inline"
- />
+ >
+ <li>
+ <DateTimeFormatter
+ date="2017-01-02T00:00:00.000Z"
+ />
+ </li>
+ <li>
+ Version
+ 0.0.1
+ </li>
+ </ul>
</div>
`;