mirror of
https://github.com/fleetdm/fleet
synced 2026-05-18 22:49:19 +00:00
* Creates new PackComposerPage at /packs/new * Creates PackForm component * Adds PackForm to PackComposerPage * Creates QueriesListItem * Creates QueriesList * Creates QueriesListWrapper * Get all queries when the Packs Composer Page loads * Form HOC handles updates to formData prop * Creates form to configure scheduled queries * QueriesListWrapper renders ConfigurePackQueryForm * search queries input filters queries list * Empty state text * create pack when user submits the new pack form * Adds Edit pack page to /packs/:pack_id/edit * API client - get scheduled queries for a pack * API client - create scheduled query * Redux config for scheduled queries * Remove scheduled queries from packs * Add labels to pack on create * Add disabled state to the select targets dropdown * Adds edit route and pushes to new route on edit click * Adds cancel button to edit pack form * Adds Checkbox that selects all scheduled queries in table
63 lines
1.4 KiB
JavaScript
63 lines
1.4 KiB
JavaScript
import React, { Component, PropTypes } from 'react';
|
|
import classnames from 'classnames';
|
|
|
|
const baseClass = 'form-field';
|
|
|
|
class FormField extends Component {
|
|
static propTypes = {
|
|
children: PropTypes.element,
|
|
className: PropTypes.string,
|
|
error: PropTypes.string,
|
|
hint: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),
|
|
label: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),
|
|
name: PropTypes.string,
|
|
type: PropTypes.string,
|
|
};
|
|
|
|
renderLabel = () => {
|
|
const { error, label, name } = this.props;
|
|
const labelWrapperClasses = classnames(
|
|
`${baseClass}__label`,
|
|
{ [`${baseClass}__label--error`]: error }
|
|
);
|
|
|
|
if (!label) {
|
|
return false;
|
|
}
|
|
|
|
return (
|
|
<label className={labelWrapperClasses} htmlFor={name}>
|
|
{error || label}
|
|
</label>
|
|
);
|
|
}
|
|
|
|
renderHint = () => {
|
|
const { hint } = this.props;
|
|
|
|
if (hint) {
|
|
return <span className={`${baseClass}__hint`}>{hint}</span>;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
render () {
|
|
const { renderLabel, renderHint } = this;
|
|
const { children, className, type } = this.props;
|
|
|
|
const formFieldClass = classnames(baseClass, {
|
|
[`${baseClass}--${type}`]: type,
|
|
}, className);
|
|
|
|
return (
|
|
<div className={formFieldClass}>
|
|
{renderLabel()}
|
|
{children}
|
|
{renderHint()}
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default FormField;
|