Sha256: 5d2e308a2d4c406a03ffeff9c200fa6d7067010a271d744d637a201b2186ebb3

Contents?: true

Size: 1.97 KB

Versions: 21

Compression:

Stored size: 1.97 KB

Contents

import React, { Component } from 'react';
import { ListView, noop } from 'patternfly-react';
import PropTypes from 'prop-types';
import ListItem from './Components/ListItem';
import EmptyState from './Components/EmptyState';
import ErrorState from './Components/ErrorState';
import './accountList.scss';

class AccountList extends Component {
  componentDidMount() {
    const { fetchAccountsStatus, startAccountStatusPolling } = this.props;
    fetchAccountsStatus();
    const pollingProcessID = setInterval(fetchAccountsStatus, 5000);
    startAccountStatusPolling(pollingProcessID);
  }

  componentWillUnmount() {
    const { stopAccountStatusPolling, pollingProcessID } = this.props;
    stopAccountStatusPolling(pollingProcessID);
  }

  render() {
    const { accounts, error } = this.props;
    const accountIds = Object.keys(accounts);

    if (error) {
      return <ErrorState error={error} />;
    }

    if (accountIds.length === 0) {
      return <EmptyState />;
    }
    const items = accountIds.map((accountID, index) => {
      const account = accounts[accountID];
      return (
        <ListItem
          key={index}
          accountID={accountID}
          account={account}
          initExpanded={index === 0}
        />
      );
    });
    return <ListView className="account_list">{items}</ListView>;
  }
}

AccountList.propTypes = {
  fetchAccountsStatus: PropTypes.func,
  startAccountStatusPolling: PropTypes.func,
  stopAccountStatusPolling: PropTypes.func,
  pollingProcessID: PropTypes.number,
  account: PropTypes.shape({
    generate_report_status: PropTypes.string,
    upload_report_status: PropTypes.string,
  }),
  accounts: PropTypes.object,
  error: PropTypes.string,
};

AccountList.defaultProps = {
  fetchAccountsStatus: noop,
  startAccountStatusPolling: noop,
  stopAccountStatusPolling: noop,
  pollingProcessID: 0,
  account: {
    generate_report_status: 'unknown',
    upload_report_status: 'unknown',
  },
  accounts: {},
  error: '',
};

export default AccountList;

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
foreman_rh_cloud-0.9.6 webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js
foreman_rh_cloud-1.0.6 webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js
foreman_rh_cloud-2.0.6 webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js
foreman_rh_cloud-0.9.5 webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js
foreman_rh_cloud-1.0.5 webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js
foreman_rh_cloud-2.0.5 webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js
foreman_rh_cloud-0.9.4.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js
foreman_rh_cloud-1.0.4.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js
foreman_rh_cloud-1.0.4 webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js
foreman_rh_cloud-2.0.4 webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js
foreman_rh_cloud-0.9.4 webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js
foreman_inventory_upload-2.0.4.pre.2 webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js
foreman_inventory_upload-2.0.4.pre.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js
foreman_inventory_upload-2.0.3 webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js
foreman_inventory_upload-1.0.3 webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js
foreman_inventory_upload-0.9.2 webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js
foreman_inventory_upload-1.0.2 webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js
foreman_inventory_upload-0.9.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js
foreman_inventory_upload-1.0.1 webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js
foreman_inventory_upload-0.9.0 webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js