Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend documentation and components gallery #4383

Merged
merged 37 commits into from
Dec 4, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4aa5ea0
Add react-styleguidist module
Nov 21, 2017
c48847d
Add basic react styleguidist configuration
Nov 21, 2017
3ee7a37
Add some more content to UI documentation
Nov 21, 2017
bc2a9de
Add documentation
Nov 21, 2017
ef48200
Add stylesheets to component gallery
Nov 22, 2017
bd9c219
Add EntityList documentation
Nov 22, 2017
70f2160
Add examples to documented common components
Nov 22, 2017
d42d901
Add some more documentation
Nov 22, 2017
ec9074f
Add styles for typeahead
Nov 22, 2017
7fcd93d
Add documentation for PageErrorOverview
Nov 23, 2017
5dd3d42
Remove missing id warning in example
Nov 23, 2017
5566701
Add documentation for Page component
Nov 23, 2017
3916d85
Add PageHeader documentation
Nov 23, 2017
c7e8f6d
Add PaginatedList documentation
Nov 23, 2017
36a80b2
Correct header tags
Nov 23, 2017
e397d9b
Add SearchForm documentation
Nov 23, 2017
6f56b5b
Use deprecated annotation
Nov 24, 2017
80f7a9e
Let consumers of `Select` customize `displayKey`
Nov 24, 2017
5210608
Add documentation for Select component
Nov 24, 2017
a2bb26d
Add SelectableList documentation
Nov 25, 2017
d36d48f
Add SortableList and SortableListItem documentation
Nov 28, 2017
aae6f74
Fix props definition in TableList component
Nov 28, 2017
e23e215
Fix display of select all Input
Nov 28, 2017
78cc3dd
Add documentation for TableList component
Nov 28, 2017
61ab145
Add documentation for Timestamp component
Nov 28, 2017
ddadb80
Add documentation for TimeUnit component
Nov 28, 2017
8962306
Add TimeUnitInput documentation
Nov 28, 2017
b23020c
Fix error while rendering component
Nov 29, 2017
18da2fe
Be more explicit about the prop we support
Nov 29, 2017
556c7cb
Add documentation for TimezoneSelect component
Nov 29, 2017
eb16dab
Add documentation for TypeAheadDataFilter component
Nov 29, 2017
e4ca42c
Add TypeAheadFieldInput documentation
Nov 29, 2017
338ef15
Fix some TypeAheadDataFilter documentation
Nov 29, 2017
1e2e8e9
Add TypeAheadInput documentation
Nov 29, 2017
04294f7
Add documentation for ReactGridContainer
Nov 29, 2017
f1037b7
Add some basic docs
Nov 29, 2017
cfef7ac
Update yarn.lock
Nov 29, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add documentation for TableList component
  • Loading branch information
Edmundo Alvarez committed Nov 28, 2017
commit 78cc3dd66bb3d99260025330d898d51f04524ae0
34 changes: 34 additions & 0 deletions graylog2-web-interface/src/components/common/TableList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,49 @@ import { Col, ListGroup, ListGroupItem, Row } from 'react-bootstrap';
import { Input } from 'components/bootstrap';
import { TypeAheadDataFilter } from 'components/common';

/**
* Component that renders a list of items in a table-like structure. The list
* also includes a filter input that can be used to search for specific
* items or elements matching a string.
*
* The component can render action elements for each item, and also for
* performing bulk-operation. In that second case, action elements will
* appear in the header once the user selects more than one item by clicking
* in the checkboxes next to them.
*/
const TableList = React.createClass({
propTypes: {
/** Specifies key to use as item ID. */
idKey: PropTypes.string,
/** Specifies a key to use as item title. */
titleKey: PropTypes.string,
/** Specifies key to use as item description. */
descriptionKey: PropTypes.string,
/** Object keys to use for filtering. Use an empty array to disable filtering. */
filterKeys: PropTypes.arrayOf(PropTypes.string).isRequired,
/** Label to use next to the filter input. */
filterLabel: PropTypes.string,
/**
* Immutable List of objects to display in the list. Objects are expected
* to have an ID (`idKey` prop), a title (`title` prop), and an optional
* description (`descriptionKey` prop).
*/
items: PropTypes.instanceOf(Immutable.List).isRequired,
/**
* Function that generates react elements to render in the header.
* Those elements are meant to display actions that affect more than one
* item in the list, so they will only be displayed when more than one
* item is checked.
* The function receives a list of IDs corresponding to all selected
* elements as argument.
*/
headerActionsFactory: PropTypes.func,
/**
* Function that generates react elements to render for each item.
* Those elements are meant to display actions that affect that specific
* item.
* The function will receive the whole item object as an argument.
*/
itemActionsFactory: PropTypes.func,
},
getDefaultProps() {
Expand Down
61 changes: 61 additions & 0 deletions graylog2-web-interface/src/components/common/TableList.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
```js
const createReactClass = require('create-react-class');
const Immutable = require('immutable');
const Button = require('react-bootstrap').Button;

const TableListExample = createReactClass({
getInitialState() {
return {
items: Immutable.List([
{ id: '1', title: 'One', secret_key: 'uno', description: 'First number' },
{ id: '2', title: 'Two', secret_key: 'dos', description: 'Second number' },
{ id: '3', title: 'Three', secret_key: 'tres', description: 'Third number' },
{ id: '4', title: 'Four', secret_key: 'cuatro', description: 'Fourth number' },
{ id: '5', title: 'Five', secret_key: 'cinco', description: 'Fifth number' },
]),
};
},

action(text) {
return () => {
alert(`This is an action for "${text}"`);
};
},

headerActionsFactory(selectedNumbers) {
return (
<div className="pull-right" style={{ marginTop: 10 }}>
<Button bsStyle="info"
bsSize="xsmall"
onClick={this.action(selectedNumbers.join(', '))}>
Bulk-operation
</Button>
</div>
);
},

itemActionsFactory(selectedNumber) {
return (
<Button bsStyle="primary"
bsSize="xsmall"
onClick={this.action(JSON.stringify(selectedNumber))}>
Do something
</Button>
);
},

render() {
const { items } = this.state;

return (
<TableList items={items}
filterKeys={['title', 'secret_key']}
filterLabel=""
headerActionsFactory={this.headerActionsFactory}
itemActionsFactory={this.itemActionsFactory} />
);
},
});

<TableListExample />
```