mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
* Display packs page at /packs/manage * Adds NumberPill component * Filter packs list * Render the pack info side panel when no packs are selected * Adds packs list * Moves state management to page component * Display selected pack count * Render bulk action buttons * API client - update pack * API client - destroy pack * Adds update/destroy functions to packs redux config * Bulk actions (enable, disable, delete) * Selecting a pack updates state * PackDetailsSidePanel updates pack status * Link to edit pack on side panel * sets selected pack in URL * Sets color for unsettled buttons * Loads scheduled queries for selected pack in All Packs Page * PackDetailsSidePanel component * PackDetailsSidePanel styles * styles PacksList component * Stop rendering flash when pack status is updated * Makes full row clickable * highlight selected pack
78 lines
2.3 KiB
JavaScript
78 lines
2.3 KiB
JavaScript
import React, { Component, PropTypes } from 'react';
|
|
import classnames from 'classnames';
|
|
import { includes } from 'lodash';
|
|
|
|
import Checkbox from 'components/forms/fields/Checkbox';
|
|
import packInterface from 'interfaces/pack';
|
|
import Row from 'components/packs/PacksList/Row';
|
|
|
|
const baseClass = 'packs-list';
|
|
|
|
class PacksList extends Component {
|
|
static propTypes = {
|
|
allPacksChecked: PropTypes.bool,
|
|
checkedPackIDs: PropTypes.arrayOf(PropTypes.number),
|
|
className: PropTypes.string,
|
|
onCheckAllPacks: PropTypes.func.isRequired,
|
|
onCheckPack: PropTypes.func.isRequired,
|
|
onSelectPack: PropTypes.func.isRequired,
|
|
packs: PropTypes.arrayOf(packInterface),
|
|
selectedPack: packInterface,
|
|
};
|
|
|
|
static defaultProps = {
|
|
checkedPackIDs: [],
|
|
packs: [],
|
|
selectedPack: {},
|
|
};
|
|
|
|
renderPack = (pack) => {
|
|
const { checkedPackIDs, onCheckPack, onSelectPack, selectedPack } = this.props;
|
|
const checked = includes(checkedPackIDs, pack.id);
|
|
const selected = pack.id === selectedPack.id;
|
|
|
|
return (
|
|
<Row
|
|
checked={checked}
|
|
key={`pack-row-${pack.id}`}
|
|
onCheck={onCheckPack}
|
|
onSelect={onSelectPack}
|
|
pack={pack}
|
|
selected={selected}
|
|
/>
|
|
);
|
|
}
|
|
|
|
render () {
|
|
const { allPacksChecked, className, onCheckAllPacks, packs } = this.props;
|
|
const { renderPack } = this;
|
|
const tableClassName = classnames(baseClass, className);
|
|
|
|
return (
|
|
<table className={tableClassName}>
|
|
<thead>
|
|
<tr>
|
|
<th className={`${baseClass}__th`}>
|
|
<Checkbox
|
|
name="select-all-packs"
|
|
onChange={onCheckAllPacks}
|
|
value={allPacksChecked}
|
|
wrapperClassName={`${baseClass}__select-all`}
|
|
/>
|
|
</th>
|
|
<th className={`${baseClass}__th ${baseClass}__th-pack-name`}>Pack Name</th>
|
|
<th className={`${baseClass}__th`}>Queries</th>
|
|
<th className={`${baseClass}__th`}>Status</th>
|
|
<th className={`${baseClass}__th`}>Hosts</th>
|
|
<th className={`${baseClass}__th`}>Last Modified</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{packs.map(pack => renderPack(pack))}
|
|
</tbody>
|
|
</table>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default PacksList;
|