-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add a react tool bar search box Create basic react toolbar elements and update uiframework docs * Package.json: put back ngreact (edits got overwritten) * Add jest tests * Combine basic tests into one, eliminate helper functions * Address code review comments - move tool_bar_footer into it’s own file. - some stylistic html changes - comments * Remove toolbar_with_search_only It isn’t being used in kibana currently, so we probably don’t need to support it in our ui_Framework, and the need for the custom “className="kuiToolBar--searchOnly”” indicates we should resdesign it if we do need it some day. * Fix issue with default to named conversion merge * rename commonHtmlProps = requiredProps
- Loading branch information
1 parent
2803fd3
commit 5984a4a
Showing
23 changed files
with
325 additions
and
118 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
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
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,11 @@ | ||
import 'ngreact'; | ||
|
||
import { | ||
KuiToolBarSearchBox, | ||
} from 'ui_framework/components'; | ||
|
||
import { uiModules } from 'ui/modules'; | ||
const app = uiModules.get('app/kibana', ['react']); | ||
app.directive('toolBarSearchBox', function (reactDirective) { | ||
return reactDirective(KuiToolBarSearchBox); | ||
}); |
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
11 changes: 11 additions & 0 deletions
11
ui_framework/components/tool_bar/__snapshots__/tool_bar.test.js.snap
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,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`renders KuiToolBar 1`] = ` | ||
<div | ||
aria-label="aria-label" | ||
class="kuiToolBar testClass1 testClass2" | ||
data-test-subj="test subject string" | ||
> | ||
children | ||
</div> | ||
`; |
11 changes: 11 additions & 0 deletions
11
ui_framework/components/tool_bar/__snapshots__/tool_bar_footer.test.js.snap
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,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`renders KuiToolBarFooter 1`] = ` | ||
<div | ||
aria-label="aria-label" | ||
class="kuiToolBarFooter testClass1 testClass2" | ||
data-test-subj="test subject string" | ||
> | ||
children | ||
</div> | ||
`; |
44 changes: 44 additions & 0 deletions
44
ui_framework/components/tool_bar/__snapshots__/tool_bar_search_box.test.js.snap
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 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`filter initializes search box value 1`] = ` | ||
<div | ||
class="kuiToolBarSearch" | ||
> | ||
<div | ||
class="kuiToolBarSearchBox" | ||
> | ||
<div | ||
class="kuiToolBarSearchBox__icon kuiIcon fa-search" | ||
/> | ||
<input | ||
aria-label="Filter" | ||
class="kuiToolBarSearchBox__input" | ||
placeholder="Search..." | ||
type="text" | ||
value="My Query" | ||
/> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`renders KuiToolBarSearchBox 1`] = ` | ||
<div | ||
aria-label="aria-label" | ||
class="kuiToolBarSearch testClass1 testClass2" | ||
data-test-subj="test subject string" | ||
> | ||
<div | ||
class="kuiToolBarSearchBox" | ||
> | ||
<div | ||
class="kuiToolBarSearchBox__icon kuiIcon fa-search" | ||
/> | ||
<input | ||
aria-label="Filter" | ||
class="kuiToolBarSearchBox__input" | ||
placeholder="Search..." | ||
type="text" | ||
/> | ||
</div> | ||
</div> | ||
`; |
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,3 @@ | ||
export { KuiToolBarSearchBox } from './tool_bar_search_box'; | ||
export { KuiToolBar } from './tool_bar'; | ||
export { KuiToolBarFooter } from './tool_bar_footer'; |
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,11 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
export const KuiToolBar = ({ children, className, ...rest }) => { | ||
const classes = classNames('kuiToolBar', className); | ||
return <div className={classes} {...rest} >{children}</div>; | ||
}; | ||
KuiToolBar.propTypes = { | ||
children: React.PropTypes.node, | ||
className: React.PropTypes.string, | ||
}; |
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 @@ | ||
import React from 'react'; | ||
import { render } from 'enzyme'; | ||
import { requiredProps } from '../../test/required_props'; | ||
|
||
import { | ||
KuiToolBar, | ||
} from './tool_bar'; | ||
|
||
test('renders KuiToolBar', () => { | ||
const component = <KuiToolBar { ...requiredProps }>children</KuiToolBar>; | ||
expect(render(component)).toMatchSnapshot(); | ||
}); | ||
|
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,11 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
export const KuiToolBarFooter = ({ children, className, ...rest }) => { | ||
const classes = classNames('kuiToolBarFooter', className); | ||
return <div className={classes} {...rest}>{children}</div>; | ||
}; | ||
KuiToolBarFooter.propTypes = { | ||
children: React.PropTypes.node, | ||
className: React.PropTypes.string, | ||
}; |
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,12 @@ | ||
import React from 'react'; | ||
import { render } from 'enzyme'; | ||
import { requiredProps } from '../../test/required_props'; | ||
|
||
import { | ||
KuiToolBarFooter, | ||
} from './tool_bar_footer'; | ||
|
||
test('renders KuiToolBarFooter', () => { | ||
const component = <KuiToolBarFooter { ...requiredProps }>children</KuiToolBarFooter>; | ||
expect(render(component)).toMatchSnapshot(); | ||
}); |
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,27 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
export function KuiToolBarSearchBox({ filter, onFilter, className, ...rest }) { | ||
function onChange(event) { | ||
onFilter(event.target.value); | ||
} | ||
const classes = classNames('kuiToolBarSearch', className); | ||
return <div className={ classes } { ...rest } > | ||
<div className="kuiToolBarSearchBox"> | ||
<div className="kuiToolBarSearchBox__icon kuiIcon fa-search"></div> | ||
<input | ||
className="kuiToolBarSearchBox__input" | ||
type="text" | ||
placeholder="Search..." | ||
aria-label="Filter" | ||
defaultValue={ filter } | ||
onChange={ onChange } | ||
/> | ||
</div> | ||
</div>; | ||
} | ||
|
||
KuiToolBarSearchBox.propTypes = { | ||
filter: React.PropTypes.string, | ||
onFilter: React.PropTypes.func.isRequired | ||
}; |
33 changes: 33 additions & 0 deletions
33
ui_framework/components/tool_bar/tool_bar_search_box.test.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,33 @@ | ||
import React from 'react'; | ||
import { render, mount } from 'enzyme'; | ||
import sinon from 'sinon'; | ||
import { requiredProps } from '../../test/required_props'; | ||
|
||
import { | ||
KuiToolBarSearchBox, | ||
} from './tool_bar_search_box'; | ||
|
||
const onFilter = sinon.spy(); | ||
|
||
test('renders KuiToolBarSearchBox', () => { | ||
const component = <KuiToolBarSearchBox onFilter={onFilter} { ...requiredProps } />; | ||
expect(render(component)).toMatchSnapshot(); | ||
}); | ||
|
||
describe('onFilter', () => { | ||
test('is called on change event, with the value entered', () => { | ||
const searchBox = mount(<KuiToolBarSearchBox onFilter={onFilter} { ...requiredProps } />); | ||
onFilter.reset(); | ||
const event = { target: { value: 'a' } }; | ||
searchBox.find('input').simulate('change', event); | ||
sinon.assert.calledWith(onFilter, 'a'); | ||
}); | ||
}); | ||
|
||
describe('filter', () => { | ||
test('initializes search box value', () => { | ||
const component = <KuiToolBarSearchBox onFilter={onFilter} filter="My Query" />; | ||
expect(render(component)).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
This file was deleted.
Oops, something went wrong.
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,59 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
KuiToolBar, | ||
KuiToolBarSearchBox, | ||
KuiButton, | ||
KuiButtonIcon, | ||
KuiButtonGroup, | ||
} from '../../../../components'; | ||
|
||
export const ToolBar = () => ( | ||
<KuiToolBar> | ||
<KuiToolBarSearchBox onFilter={() => {}} /> | ||
|
||
<div> | ||
<select className="kuiSelect"> | ||
<option>Past hour</option> | ||
<option>Past day</option> | ||
<option>Past week</option> | ||
</select> | ||
</div> | ||
|
||
<div className="kuiToolBarSection"> | ||
<KuiButton | ||
type="primary" | ||
icon={<KuiButtonIcon type="create" />} | ||
> | ||
Create | ||
</KuiButton> | ||
|
||
<KuiButton | ||
type="danger" | ||
icon={<KuiButtonIcon type="delete" />} | ||
> | ||
Delete | ||
</KuiButton> | ||
</div> | ||
|
||
<div className="kuiToolBarSection"> | ||
|
||
<div className="kuiToolBarText"> | ||
1 – 20 of 33 | ||
</div> | ||
|
||
<KuiButtonGroup isUnited> | ||
<KuiButton | ||
type="basic" | ||
icon={<KuiButtonIcon type="previous" />} | ||
> | ||
</KuiButton> | ||
<KuiButton | ||
type="basic" | ||
icon={<KuiButtonIcon type="next" />} | ||
> | ||
</KuiButton> | ||
</KuiButtonGroup> | ||
</div> | ||
</KuiToolBar> | ||
); |
Oops, something went wrong.