mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-11-13 03:35:52 +01:00
fix: Display message if there are no items on search
This commit is contained in:
parent
19490ffc51
commit
3a187945dc
18
src/webui/src/components/NoItems/index.js
Normal file
18
src/webui/src/components/NoItems/index.js
Normal file
@ -0,0 +1,18 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import classes from './noItems.scss';
|
||||
|
||||
const NoItems = (props) => {
|
||||
return (
|
||||
<div className={classes.noItems}>
|
||||
<h2>{props.text}</h2>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
NoItems.propTypes = {
|
||||
text: PropTypes.string.isRequired
|
||||
};
|
||||
|
||||
export default NoItems;
|
3
src/webui/src/components/NoItems/noItems.scss
Normal file
3
src/webui/src/components/NoItems/noItems.scss
Normal file
@ -0,0 +1,3 @@
|
||||
.noItems {
|
||||
margin: 5em 0;
|
||||
}
|
@ -4,13 +4,15 @@ import isEmpty from 'lodash/isEmpty';
|
||||
|
||||
import Package from '../Package';
|
||||
import Help from '../Help';
|
||||
import NoItems from '../NoItems';
|
||||
|
||||
import classes from './packageList.scss';
|
||||
|
||||
export default class PackageList extends React.Component {
|
||||
|
||||
static propTypes = {
|
||||
packages: PropTypes.array
|
||||
packages: PropTypes.array,
|
||||
help: PropTypes.bool
|
||||
}
|
||||
|
||||
render() {
|
||||
@ -18,7 +20,7 @@ export default class PackageList extends React.Component {
|
||||
<div>
|
||||
<div className={classes.pkgContainer}>
|
||||
{this.renderTitle()}
|
||||
{this.isTherePackages() ? this.renderList(): this.renderHelp()}
|
||||
{this.isTherePackages() ? this.renderList(): this.renderOptions()}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@ -38,7 +40,22 @@ export default class PackageList extends React.Component {
|
||||
));
|
||||
}
|
||||
|
||||
renderOptions() {
|
||||
if (this.isTherePackages() === false && this.props.help) {
|
||||
return this.renderHelp();
|
||||
} else {
|
||||
return this.renderNoItems();
|
||||
}
|
||||
}
|
||||
|
||||
renderNoItems() {
|
||||
return <NoItems text={'No items were found with that query'}/>;
|
||||
}
|
||||
|
||||
renderHelp() {
|
||||
if (this.props.help === false) {
|
||||
return;
|
||||
}
|
||||
return <Help/>;
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ export default class Home extends React.Component {
|
||||
|
||||
state = {
|
||||
loading: true,
|
||||
fistTime: true,
|
||||
query: ''
|
||||
}
|
||||
|
||||
@ -74,6 +75,7 @@ export default class Home extends React.Component {
|
||||
if (this.state.query === query) {
|
||||
this.setState({
|
||||
packages: this.req.data,
|
||||
fistTime: false,
|
||||
loading: false
|
||||
});
|
||||
}
|
||||
@ -106,7 +108,7 @@ export default class Home extends React.Component {
|
||||
}
|
||||
|
||||
renderSearchBar() {
|
||||
if (this.isTherePackages()) {
|
||||
if (this.isTherePackages() && this.state.fistTime) {
|
||||
return;
|
||||
}
|
||||
return <Search handleSearchInput={ this.handleSearchInput } />;
|
||||
@ -117,7 +119,7 @@ export default class Home extends React.Component {
|
||||
}
|
||||
|
||||
renderPackageList() {
|
||||
return <PackageList packages={this.state.packages} />;
|
||||
return <PackageList help={this.state.fistTime} packages={this.state.packages} />;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user