Pārlūkot izejas kodu

Fix docs old version warning.

tags/7.6
Grégoire Aubert pirms 5 gadiem
vecāks
revīzija
79097cecde

+ 9
- 9
server/sonar-docs/src/layouts/components/Sidebar.js Parādīt failu

@@ -124,9 +124,11 @@ export default class Sidebar extends React.PureComponent {
};

render() {
const isOnCurrentVersion =
this.props.version === 'latest' ||
this.state.versions.find(v => v.value === this.props.version) !== undefined;
const { versions } = this.state;
const currentVersion = versions.find(v => v.current);
const selectedVersionValue =
currentVersion && this.props.version === 'latest' ? currentVersion.value : this.props.version;
const isOnCurrentVersion = !currentVersion || selectedVersionValue === currentVersion.value;
return (
<div className="page-sidebar">
<div className="sidebar-header">
@@ -140,11 +142,10 @@ export default class Sidebar extends React.PureComponent {
/>
</Link>
<VersionSelect
location={this.props.location}
version={this.props.version}
versions={this.state.versions}
isOnCurrentVersion={isOnCurrentVersion}
selectedVersionValue={selectedVersionValue}
versions={versions}
/>

{this.state.loaded &&
!isOnCurrentVersion && (
<div className="alert alert-warning">
@@ -160,8 +161,7 @@ export default class Sidebar extends React.PureComponent {
onResultsChange={this.handleSearch}
pages={this.props.pages}
/>
{this.state.query !== '' && this.renderResults()}
{this.state.query === '' && this.renderCategories(NavigationTree)}
{this.state.query !== '' ? this.renderResults() : this.renderCategories(NavigationTree)}
</div>
<div className="sidebar-footer">
<a href="https://www.sonarqube.org/" rel="noopener noreferrer" target="_blank">

+ 2
- 8
server/sonar-docs/src/layouts/components/VersionSelect.js Parādīt failu

@@ -18,7 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
import fetch from 'isomorphic-fetch';
import ChevronDownIcon from './icons/ChevronDownIcon';
import ChevronUpIcon from './icons/ChevronUpIcon';
import OutsideClickHandler from './OutsideClickHandler';
@@ -35,18 +34,13 @@ export default class VersionSelect extends React.PureComponent {
};

render() {
const { versions } = this.props;
const { isOnCurrentVersion, selectedVersionValue, versions } = this.props;
const hasVersions = versions.length > 1;
const currentVersion = versions.find(v => v.current);
const versionLabel =
this.props.version === 'latest' && currentVersion ? currentVersion.value : this.props.version;
const isOnCurrentVersion =
!hasVersions || (currentVersion && versionLabel === currentVersion.value);

return (
<div className="version-select">
<button onClick={this.handleClick} type="button">
Docs <span className={isOnCurrentVersion ? 'current' : ''}>{versionLabel}</span>
Docs <span className={isOnCurrentVersion ? 'current' : ''}>{selectedVersionValue}</span>
{hasVersions && !this.state.open && <ChevronDownIcon size={10} />}
{hasVersions && this.state.open && <ChevronUpIcon size={10} />}
</button>

Notiek ielāde…
Atcelt
Saglabāt