forked from Graylog2/graylog2-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Frontend documentation and components gallery (Graylog2#4383)
* Add react-styleguidist module * Add basic react styleguidist configuration - Include shared components in the gallery - Add build scripts to build the gallery and serve it * Add some more content to UI documentation * Add documentation * Add stylesheets to component gallery * Add EntityList documentation * Add examples to documented common components * Add some more documentation * Add styles for typeahead * Add documentation for PageErrorOverview * Remove missing id warning in example * Add documentation for Page component * Add PageHeader documentation * Add PaginatedList documentation * Correct header tags * Add SearchForm documentation * Use deprecated annotation * Let consumers of `Select` customize `displayKey` React Select uses `labelKey` instead of `displayKey` so pass the right prop down. * Add documentation for Select component * Add SelectableList documentation * Add SortableList and SortableListItem documentation * Fix props definition in TableList component * Fix display of select all Input This prop was not updated when we migrated to our own Input component. * Add documentation for TableList component * Add documentation for Timestamp component * Add documentation for TimeUnit component * Add TimeUnitInput documentation * Fix error while rendering component We used the wrong import here, `moment` doesn't know about timezones. * Be more explicit about the prop we support As we specify the `onChange` prop in the TimezoneSelect prop types, we should at least use it instead of passing it down as other props that are not listed. We should restrict the supported props at some point, protecting our code from changes in underlying components. * Add documentation for TimezoneSelect component * Add documentation for TypeAheadDataFilter component * Add TypeAheadFieldInput documentation * Fix some TypeAheadDataFilter documentation * Add TypeAheadInput documentation * Add documentation for ReactGridContainer * Add some basic docs * Update yarn.lock
- Loading branch information
Showing
66 changed files
with
2,627 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
Please help us to keep this documentation updated! | ||
|
||
We all benefit from documenting our processes and components, as it help us to | ||
use them without expending too much time reading at the source code, and also | ||
to think twice about how we solved a certain problem. | ||
|
||
|
||
## How to document your components | ||
|
||
This guide was created using [React Styleguidist](https://react-styleguidist.js.org), | ||
so that is a good place to get started if you want to know how to contribute to | ||
this document. | ||
|
||
Here is a summary of what to do if you just want to document a component: | ||
|
||
1. Use [JSDoc](http://usejsdoc.org) to write documentation for the component | ||
and its props, as those are the main API the component provides to its | ||
consumers. | ||
2. The component documentation **must** be placed just before the component | ||
declaration and **must** contain a brief explanation of what the component | ||
intents to do, followed by any warnings, notes, or deprecations if needed. | ||
Please **do not** include code examples in here unless you cannot create an | ||
example for some reason. | ||
3. Each `propType` definition **must** be preceded by its documentation. Pay | ||
special attention to: | ||
|
||
- Document data structures the component expect in array and object props | ||
- Document when a callback function will be called. This is specially | ||
helpful if the prop name is not as clear as it should be | ||
- Document arguments any callback functions will receive | ||
|
||
4. In order to write a usage example of the component, you need to create a | ||
[Markdown](https://en.wikipedia.org/wiki/Markdown) file in the same directory | ||
as the component, with the same name as the component but the `md` extension. | ||
E.g. `ReactGridContainer.md` will contain the examples for | ||
`ReactGridContainer.jsx`. | ||
5. Only write examples to show important use cases of the component, but you | ||
do not need to write an example for each prop and value that the component | ||
can accept. | ||
6. You can write React components in examples, and you should do it if you | ||
feel that showing how the state flows may help understanding how the | ||
component works. | ||
7. Examples do not support `import` statements, but you can `require` any | ||
modules you need. Try to not require too many modules, though, as they will | ||
make the example more obscure and harder to understand. You can also use | ||
object destructuring when requiring more than one thing from the same module. | ||
E.g. `const { Button, ButtonToolbar } = require('react-bootstrap');` can | ||
save a line of the example without making it harder to read. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
### Welcome to the Graylog UI documentation! | ||
|
||
In this page we describe our processes to write frontend code. We also | ||
offer a gallery of shared components that you can use when writing frontend | ||
code for the Graylog web interface or one of our frontend plugins. | ||
|
||
Please take your time to read through this document and make sure you follow | ||
our guidelines. Otherwise your changes may not be merged into our repositories | ||
until you do. | ||
|
||
This document is still in a very early stage, but we will do our best to | ||
make it our to-go reference when writing frontend code. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
We use ESLint to detect some issues in our code. We mostly follow the | ||
[Airbnb Javascript style guide](https://github.com/airbnb/javascript) to write | ||
frontend code, with a few exceptions that we list here: | ||
|
||
|
||
The list may not be up-to-date or complete, but you can take a look at the ESLint | ||
rules we use in our [repository](https://raw.githubusercontent.com/Graylog2/graylog2-server/master/graylog2-web-interface/packages/eslint-config-graylog/index.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
We use [Jest](https://facebook.github.io/jest/) and [Enzime](http://airbnb.io/enzyme/) | ||
to write frontend tests. We encourage you to write tests for any complex logic | ||
that may be easily broken, but you may also write tests for components if you | ||
really feel like it will help to make it more robust without much overhead. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## AppConfig | ||
|
||
## ObjectUtils | ||
__DEPRECATED__: Please use lodash when possible instead of this component. | ||
|
||
Provide util functions to do some common tasks with objects easier. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 15 additions & 3 deletions
18
graylog2-web-interface/src/components/common/ClipboardButton.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
graylog2-web-interface/src/components/common/ClipboardButton.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
```js | ||
<ClipboardButton title="Copy me!" | ||
text="Copy me!" /> | ||
``` | ||
|
||
`ClipboardButton` with `onSuccess` callback: | ||
```js | ||
<div> | ||
<p id="clipboard-button-2">This text will be copied to your clipboard.</p> | ||
<ClipboardButton title="Copy me too!" | ||
target="#clipboard-button-2" | ||
onSuccess={() => alert('Copied to clipboard!')} | ||
bsStyle="info" | ||
bsSize="small" /> | ||
</div> | ||
``` |
6 changes: 6 additions & 0 deletions
6
graylog2-web-interface/src/components/common/ContentPackMarker.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
```js | ||
const entities = [ | ||
{ | ||
id: '1', | ||
title: 'Dr. Emmett Brown', | ||
nickname: 'Doc', | ||
roles: ['Doctor', 'Human'], | ||
description: '1.21 GIGAWATTS!!!', | ||
}, | ||
{ | ||
id: '2', | ||
title: 'Marty McFly', | ||
nickname: 'Marty', | ||
roles: ['Student', 'Human'], | ||
description: 'Nobody calls me chicken', | ||
}, | ||
]; | ||
const filterKeys = ['title', 'nickname']; | ||
const headers = ['', 'Name', 'Nickname', 'Role', 'Quote']; | ||
|
||
const rowFormatter = (entity, idx) => { | ||
return ( | ||
<tr key={entity.id}> | ||
<td>{idx + 1}</td> | ||
<td>{entity.title}</td> | ||
<td>{entity.nickname}</td> | ||
<td>{entity.roles.join(', ')}</td> | ||
<td>{entity.description}</td> | ||
</tr> | ||
); | ||
}; | ||
|
||
<DataTable id="entity-list" | ||
className="table-hover" | ||
headers={headers} | ||
headerCellFormatter={(header) => <th>{header}</th>} | ||
sortByKey={'title'} | ||
rows={entities} | ||
filterBy="role" | ||
filterSuggestions={['Doctor', 'Student', 'Human']} | ||
dataRowFormatter={rowFormatter} | ||
filterLabel="Filter entities" | ||
filterKeys={filterKeys} /> | ||
``` |
11 changes: 11 additions & 0 deletions
11
graylog2-web-interface/src/components/common/DataTableElement.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
graylog2-web-interface/src/components/common/DocumentTitle.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.