diff --git a/src/webui/src/components/NoItems/index.js b/src/webui/src/components/NoItems/index.js new file mode 100644 index 000000000..67430f2eb --- /dev/null +++ b/src/webui/src/components/NoItems/index.js @@ -0,0 +1,18 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +import classes from './noItems.scss'; + +const NoItems = (props) => { + return ( +
+

{props.text}

+
+ ); +}; + +NoItems.propTypes = { + text: PropTypes.string.isRequired +}; + +export default NoItems; diff --git a/src/webui/src/components/NoItems/noItems.scss b/src/webui/src/components/NoItems/noItems.scss new file mode 100644 index 000000000..81a2a9ec9 --- /dev/null +++ b/src/webui/src/components/NoItems/noItems.scss @@ -0,0 +1,3 @@ +.noItems { + margin: 5em 0; +} diff --git a/src/webui/src/components/PackageList/index.js b/src/webui/src/components/PackageList/index.js index 9e3a76e3d..ded3885b9 100644 --- a/src/webui/src/components/PackageList/index.js +++ b/src/webui/src/components/PackageList/index.js @@ -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 {
{this.renderTitle()} - {this.isTherePackages() ? this.renderList(): this.renderHelp()} + {this.isTherePackages() ? this.renderList(): this.renderOptions()}
); @@ -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 ; + } + renderHelp() { + if (this.props.help === false) { + return; + } return ; } diff --git a/src/webui/src/modules/home/index.js b/src/webui/src/modules/home/index.js index ef0dc7ad0..75f5a4e14 100644 --- a/src/webui/src/modules/home/index.js +++ b/src/webui/src/modules/home/index.js @@ -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 ; @@ -117,7 +119,7 @@ export default class Home extends React.Component { } renderPackageList() { - return ; + return ; } }