Skip to content

Commit

Permalink
Convert EuiTableOfRecords to simpler table component in scripted fiel…
Browse files Browse the repository at this point in the history
…ds table. (elastic#16901)

* Convert EuiTableOfRecords to EuiBasicTable in scripted fields table.
* Convert from EuiBasicTable to EuiInMemoryTable.
* Fix bug with filtering and show 'no items' message when the filter doens't match any scripted fields.
  • Loading branch information
cjcenizal committed Mar 9, 2018
1 parent 03d9c42 commit 95524e7
Show file tree
Hide file tree
Showing 13 changed files with 314 additions and 564 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

exports[`ScriptedFieldsTable should filter based on the lang filter 1`] = `
<div>
<header />
<header
addScriptedFieldUrl="#"
/>
<call-outs
deprecatedLangsInUse={
Array [
Expand All @@ -11,11 +13,6 @@ exports[`ScriptedFieldsTable should filter based on the lang filter 1`] = `
}
painlessDocLink="painlessDocs"
/>
<eui-button
data-test-subj="addScriptedFieldLink"
>
Add scripted field
</eui-button>
<eui-spacer
size="l"
/>
Expand All @@ -27,52 +24,33 @@ exports[`ScriptedFieldsTable should filter based on the lang filter 1`] = `
"getScriptedFields": [Function],
}
}
model={
Object {
"criteria": Object {
"page": Object {
"index": 0,
"size": 10,
},
"sort": Object {
"direction": "asc",
"field": "name",
},
items={
Array [
Object {
"lang": "painless",
"name": "ScriptedField",
"script": "x++",
},
"data": Object {
"records": Array [
Object {
"lang": "painless",
"name": "ScriptedField",
"script": "x++",
},
Object {
"lang": "painless",
"name": "JustATest",
"script": "z++",
},
],
"totalRecordCount": 2,
Object {
"lang": "painless",
"name": "JustATest",
"script": "z++",
},
}
]
}
onDataCriteriaChange={[Function]}
/>
</div>
`;

exports[`ScriptedFieldsTable should filter based on the query bar 1`] = `
<div>
<header />
<header
addScriptedFieldUrl="#"
/>
<call-outs
deprecatedLangsInUse={Array []}
painlessDocLink="painlessDocs"
/>
<eui-button
data-test-subj="addScriptedFieldLink"
>
Add scripted field
</eui-button>
<eui-spacer
size="l"
/>
Expand All @@ -84,65 +62,53 @@ exports[`ScriptedFieldsTable should filter based on the query bar 1`] = `
"getScriptedFields": [Function],
}
}
model={
Object {
"criteria": Object {
"page": Object {
"index": 0,
"size": 10,
},
"sort": Object {
"direction": "asc",
"field": "name",
},
},
"data": Object {
"records": Array [
Object {
"lang": "painless",
"name": "JustATest",
"script": "z++",
},
],
"totalRecordCount": 1,
items={
Array [
Object {
"lang": "painless",
"name": "JustATest",
"script": "z++",
},
}
]
}
onDataCriteriaChange={[Function]}
/>
</div>
`;

exports[`ScriptedFieldsTable should hide the table if there are no scripted fields 1`] = `
<div>
<header />
<header
addScriptedFieldUrl="#"
/>
<call-outs
deprecatedLangsInUse={Array []}
painlessDocLink="painlessDocs"
/>
<eui-button
data-test-subj="addScriptedFieldLink"
>
Add scripted field
</eui-button>
<eui-spacer
size="l"
/>
<Table
deleteField={[Function]}
editField={[Function]}
indexPattern={
Object {
"getScriptedFields": [Function],
}
}
items={Array []}
/>
</div>
`;

exports[`ScriptedFieldsTable should render normally 1`] = `
<div>
<header />
<header
addScriptedFieldUrl="#"
/>
<call-outs
deprecatedLangsInUse={Array []}
painlessDocLink="painlessDocs"
/>
<eui-button
data-test-subj="addScriptedFieldLink"
>
Add scripted field
</eui-button>
<eui-spacer
size="l"
/>
Expand All @@ -154,52 +120,33 @@ exports[`ScriptedFieldsTable should render normally 1`] = `
"getScriptedFields": [Function],
}
}
model={
Object {
"criteria": Object {
"page": Object {
"index": 0,
"size": 10,
},
"sort": Object {
"direction": "asc",
"field": "name",
},
items={
Array [
Object {
"lang": "painless",
"name": "ScriptedField",
"script": "x++",
},
"data": Object {
"records": Array [
Object {
"lang": "painless",
"name": "ScriptedField",
"script": "x++",
},
Object {
"lang": "painless",
"name": "JustATest",
"script": "z++",
},
],
"totalRecordCount": 2,
Object {
"lang": "painless",
"name": "JustATest",
"script": "z++",
},
}
]
}
onDataCriteriaChange={[Function]}
/>
</div>
`;

exports[`ScriptedFieldsTable should show a delete modal 1`] = `
<div>
<header />
<header
addScriptedFieldUrl="#"
/>
<call-outs
deprecatedLangsInUse={Array []}
painlessDocLink="painlessDocs"
/>
<eui-button
data-test-subj="addScriptedFieldLink"
>
Add scripted field
</eui-button>
<eui-spacer
size="l"
/>
Expand All @@ -211,36 +158,20 @@ exports[`ScriptedFieldsTable should show a delete modal 1`] = `
"getScriptedFields": [Function],
}
}
model={
Object {
"criteria": Object {
"page": Object {
"index": 0,
"size": 10,
},
"sort": Object {
"direction": "asc",
"field": "name",
},
items={
Array [
Object {
"lang": "painless",
"name": "ScriptedField",
"script": "x++",
},
"data": Object {
"records": Array [
Object {
"lang": "painless",
"name": "ScriptedField",
"script": "x++",
},
Object {
"lang": "painless",
"name": "JustATest",
"script": "z++",
},
],
"totalRecordCount": 2,
Object {
"lang": "painless",
"name": "JustATest",
"script": "z++",
},
}
]
}
onDataCriteriaChange={[Function]}
/>
<eui-overlay-mask>
<eui-confirm-modal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ import { shallow } from 'enzyme';
import { ScriptedFieldsTable } from '../scripted_fields_table';

jest.mock('@elastic/eui', () => ({
EuiButton: 'eui-button',
EuiTableOfRecords: 'eui-table-of-records',
EuiTitle: 'eui-title',
EuiText: 'eui-text',
EuiButton: 'eui-button',
EuiHorizontalRule: 'eui-horizontal-rule',
EuiSpacer: 'eui-spacer',
EuiCallOut: 'eui-call-out',
Expand Down Expand Up @@ -42,7 +39,7 @@ jest.mock('ui/documentation_links', () => ({

const helpers = {
redirectToRoute: () => {},
getRouteHref: () => {},
getRouteHref: () => '#',
};

const indexPattern = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,45 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Header should render normally 1`] = `
<div>
<EuiTitle
size="s"
<EuiFlexGroup
alignItems="center"
component="div"
gutterSize="l"
justifyContent="flexStart"
responsive={true}
wrap={false}
>
<EuiFlexItem
component="div"
grow={true}
>
<h3>
Scripted fields
</h3>
</EuiTitle>
<EuiText>
<p>
You can use scripted fields in visualizations and display them in your documents. However, you cannot search scripted fields.
</p>
</EuiText>
<EuiSpacer
size="s"
/>
</div>
<EuiTitle
size="s"
>
<h3>
Scripted fields
</h3>
</EuiTitle>
<EuiText>
<p>
You can use scripted fields in visualizations and display them in your documents. However, you cannot search scripted fields.
</p>
</EuiText>
</EuiFlexItem>
<EuiFlexItem
component="div"
grow={false}
>
<EuiButton
color="primary"
data-test-subj="addScriptedFieldLink"
fill={false}
href=""
iconSide="left"
type="button"
>
Add scripted field
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Header } from '../header';
describe('Header', () => {
it('should render normally', async () => {
const component = shallow(
<Header/>
<Header addScriptedFieldUrl="" />
);

expect(component).toMatchSnapshot();
Expand Down
Loading

0 comments on commit 95524e7

Please sign in to comment.