Skip to content
Snippets Groups Projects
Commit c6c1396d authored by Václav Bartoš's avatar Václav Bartoš
Browse files

TheHiveButton: lists of observables are now collapsible

Collapsed automatically when there are more than 3 observables.
parent 0f4af460
No related branches found
No related tags found
No related merge requests found
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
"build": "plugin-helpers build" "build": "plugin-helpers build"
}, },
"dependencies": { "dependencies": {
"request": "^2.88.0", "request": "^2.88.0"
"@elastic/eui": "10.4.2",
"react": "^16.8.0"
}, },
"devDependencies": { "devDependencies": {
"@elastic/eslint-config-kibana": "link:../../packages/eslint-config-kibana", "@elastic/eslint-config-kibana": "link:../../packages/eslint-config-kibana",
......
...@@ -24,6 +24,7 @@ import { ...@@ -24,6 +24,7 @@ import {
EuiSuperSelect, EuiSuperSelect,
EuiBasicTable, EuiBasicTable,
EuiCheckbox, EuiCheckbox,
EuiAccordion,
makeId, makeId,
} from '@elastic/eui'; } from '@elastic/eui';
...@@ -406,7 +407,7 @@ class ModalContent extends Component { ...@@ -406,7 +407,7 @@ class ModalContent extends Component {
/> />
</EuiFormRow> </EuiFormRow>
{this.props.fields.length > 0 && <EuiTitle size="s"><h3>Add observables from current query ...</h3></EuiTitle>} {this.props.fields.length > 0 && <><EuiTitle size="s"><h3>Add observables from current query ...</h3></EuiTitle><EuiSpacer size="m" /></>}
{this.props.fields.map((field,ix) => ( {this.props.fields.map((field,ix) => (
<ObservablesTable <ObservablesTable
key={field.name + ":" + this.props.resetCnt} key={field.name + ":" + this.props.resetCnt}
...@@ -508,28 +509,33 @@ class ObservablesTable extends Component { ...@@ -508,28 +509,33 @@ class ObservablesTable extends Component {
return ( return (
<> <>
<EuiTitle size="xs"><h4>{this.props.fieldName}</h4></EuiTitle> <EuiAccordion
<EuiBasicTable id="accordion-{this.props.fieldName}"
ref={this.tableRef} buttonContent={<EuiTitle size="xs"><h4>{this.props.fieldName} ({n_obs})</h4></EuiTitle>}
columns={this.columns} initialIsOpen={n_obs <= 3}
items={this.table_data} >
itemId={(item3) => item3.id} <EuiBasicTable
selection={ {onSelectionChange: (selectedItems) => this.props.onObsSelectionChange(this.props.fieldName, selectedItems) } } ref={this.tableRef}
noItemsMessage="No observables found" columns={this.columns}
rowProps={{ items={this.table_data}
// Hack to allow selection by clicking anywhere in the table row itemId={(item3) => item3.id}
// (except input elements) selection={ {onSelectionChange: (selectedItems) => this.props.onObsSelectionChange(this.props.fieldName, selectedItems) } }
onClick: (e) => { noItemsMessage="No observables found"
if (e.target.tagName != "INPUT") { rowProps={{
// simulate click on the first checkbox in the row to (de)select the row // A hack to allow selection by clicking anywhere in the table row
e.currentTarget.querySelector("input").click(); // (except input elements)
e.currentTarget.blur(); // without this the focus remains on the row after click (results in different color) onClick: (e) => {
} if (e.target.tagName != "INPUT") {
}, // simulate click on the first checkbox in the row to (de)select the row
tabIndex: "-1", // prevents focus on row by keyboard navigation e.currentTarget.querySelector("input").click();
}} e.currentTarget.blur(); // without this the focus remains on the row after click (results in different color)
/> }
<EuiSpacer size="l" /> },
tabIndex: "-1", // prevents focus on row by keyboard navigation
}}
/>
</EuiAccordion>
<EuiSpacer size="m" />
</> </>
) )
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment