Skip to content

Commit

Permalink
Revert "Clean up EuiSearchBar docs and reorganize code. (#454)" (#470)
Browse files Browse the repository at this point in the history
* Revert "Clean up EuiSearchBar docs and reorganize code. (#454)"
This partially reverts commit 3a910d3.
* Change random.oneOf() to accept an array.
* Export Query and Ast services. Import components into examples via the root components module.
* Fix typos in docs.
* Refactor search bar docs for clearer data flow and render methods.
* Import Enzyme utilities from enzyme root module in tests.
* Use Component instead of React.Component.
* Rename astToES to astToEs.
* Fix line-break in CHANGELOG.
  • Loading branch information
cjcenizal authored Mar 8, 2018
1 parent b1949e6 commit 4377f22
Show file tree
Hide file tree
Showing 47 changed files with 345 additions and 336 deletions.
4 changes: 2 additions & 2 deletions src-docs/src/views/file_picker/file_picker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { Component } from 'react';

import {
EuiFilePicker,
Expand All @@ -7,7 +7,7 @@ import {
EuiText,
} from '../../../../src/components';

export class FilePicker extends React.Component {
export class FilePicker extends Component {

constructor(props) {
super(props);
Expand Down
55 changes: 28 additions & 27 deletions src-docs/src/views/search_bar/search_bar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component, Fragment } from 'react';
import { times } from 'lodash';

import {
EuiHealth,
Expand All @@ -19,8 +20,6 @@ import {
Random,
} from '../../../../src/services';

import { times } from 'lodash';

const random = new Random();

const tags = [{
Expand Down Expand Up @@ -215,10 +214,34 @@ export class SearchBar extends Component {

const esQuery = Query.toESQuery(query);

const content = this.renderError() || (
<EuiFlexGroup>
<EuiFlexItem>
<EuiTitle size="s">
<h3>Elasticsearch query</h3>
</EuiTitle>

<EuiSpacer size="s" />

<EuiCodeBlock language="js">
{esQuery ? JSON.stringify(esQuery, null, 2) : ''}
</EuiCodeBlock>
</EuiFlexItem>

<EuiFlexItem>
<EuiTitle size="s">
<h3>JS execution</h3>
</EuiTitle>

<EuiSpacer size="s" />

{this.renderTable()}
</EuiFlexItem>
</EuiFlexGroup>
);

return (
<Fragment>
{this.renderError()}

<EuiFlexGroup alignItems="center">
<EuiFlexItem>
{this.renderSearch()}
Expand All @@ -235,29 +258,7 @@ export class SearchBar extends Component {

<EuiSpacer size="l" />

<EuiFlexGroup>
<EuiFlexItem>
<EuiTitle size="s">
<h3>Elasticsearch query</h3>
</EuiTitle>

<EuiSpacer size="s" />

<EuiCodeBlock language="js">
{esQuery ? JSON.stringify(esQuery, null, 2) : ''}
</EuiCodeBlock>
</EuiFlexItem>

<EuiFlexItem>
<EuiTitle size="s">
<h3>JS execution</h3>
</EuiTitle>

<EuiSpacer size="s" />

{this.renderTable()}
</EuiFlexItem>
</EuiFlexGroup>
{content}
</Fragment>
);
}
Expand Down
4 changes: 2 additions & 2 deletions src-docs/src/views/table_of_records/implicit_record_action.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { Component } from 'react';
import { times } from 'lodash';

import {
Expand Down Expand Up @@ -43,7 +43,7 @@ function loadPage(pageIndex, pageSize, sort) {
};
}

export default class PeopleTable extends React.Component {
export default class PeopleTable extends Component {

constructor(props) {
super(props);
Expand Down
4 changes: 2 additions & 2 deletions src-docs/src/views/tables/in_memory/in_memory_search.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Fragment } from 'react';
import React, { Component, Fragment } from 'react';
import { formatDate } from '../../../../../src/services/format';
import { createDataStore } from '../data_store';
import {
Expand Down Expand Up @@ -35,7 +35,7 @@ Example country object:

const store = createDataStore();

export class Table extends React.Component {
export class Table extends Component {

constructor(props) {
super(props);
Expand Down
4 changes: 2 additions & 2 deletions src-docs/src/views/tabs/tabs.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import React, { Component } from 'react';

import {
EuiTabs,
EuiTab,
EuiSpacer,
} from '../../../../src/components';

class EuiTabsExample extends React.Component {
class EuiTabsExample extends Component {
constructor(props) {
super(props);

Expand Down
4 changes: 2 additions & 2 deletions src/components/basic_table/collapsed_item_actions.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import React, { Component } from 'react';
import { EuiContextMenuItem, EuiContextMenuPanel } from '../context_menu';
import { EuiPopover } from '../popover';
import { EuiButtonIcon } from '../button';

export class CollapsedItemActions extends React.Component {
export class CollapsedItemActions extends Component {

constructor(props) {
super(props);
Expand Down
4 changes: 2 additions & 2 deletions src/components/basic_table/custom_item_action.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { cloneElement } from 'react';
import React, { Component, cloneElement } from 'react';

export class CustomItemAction extends React.Component {
export class CustomItemAction extends Component {

constructor(props) {
super(props);
Expand Down
4 changes: 2 additions & 2 deletions src/components/basic_table/default_item_action.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import React, { Component } from 'react';
import { isString } from '../../services/predicate';
import { EuiButton, EuiButtonIcon } from '../button';

const defaults = {
color: 'primary'
};

export class DefaultItemAction extends React.Component {
export class DefaultItemAction extends Component {

constructor(props) {
super(props);
Expand Down
9 changes: 4 additions & 5 deletions src/components/basic_table/in_memory_table.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {
EuiBasicTable,
Expand All @@ -8,14 +8,13 @@ import {
import {
defaults as paginationBarDefaults
} from './pagination_bar';
import { Query } from '../../services/query';
import { isBoolean, isString } from '../../services/predicate';
import { Comparators } from '../../services/sort';
import {
Query,
QueryType,
SearchFiltersFiltersType,
SearchBoxConfigPropTypes,
EuiSearchBar,
SearchBoxConfigPropTypes, EuiSearchBar
} from '../search_bar';
import { EuiSpacer } from '../spacer/spacer';

Expand Down Expand Up @@ -60,7 +59,7 @@ const initialCriteria = (props) => {
};
};

export class EuiInMemoryTable extends React.Component {
export class EuiInMemoryTable extends Component {

static propTypes = InMemoryTablePropTypes;
static defaultProps = {
Expand Down
4 changes: 2 additions & 2 deletions src/components/basic_table/loading_table_body.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import React, { Component } from 'react';
import {
EuiTableBody
} from '../table/table_body';

export class LoadingTableBody extends React.Component {
export class LoadingTableBody extends Component {

constructor(props) {
super(props);
Expand Down
4 changes: 2 additions & 2 deletions src/components/filter_group/filter_select_item.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';

Expand All @@ -23,7 +23,7 @@ const resolveIconAndColor = (checked) => {
{ icon: 'cross', color: 'text' };
};

export class EuiFilterSelectItem extends React.Component {
export class EuiFilterSelectItem extends Component {

constructor(props) {
super(props);
Expand Down
4 changes: 2 additions & 2 deletions src/components/form/field_search/field_search.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { Browser } from '../../../services/browser';
Expand Down Expand Up @@ -36,7 +36,7 @@ const defaultProps = {
incremental: false
};

export class EuiFieldSearch extends React.Component {
export class EuiFieldSearch extends Component {

static propTypes = propTypes;
static defaultProps = defaultProps;
Expand Down
2 changes: 1 addition & 1 deletion src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export {
} from './progress';

export {
EuiSearchBar,
EuiSearchBar
} from './search_bar';

export {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ exports[`SearchBar render - provided query, filters 1`] = `
onChange={[Function]}
query={
Query {
"ast": _Ast {
"ast": _AST {
"_clauses": Array [
Object {
"match": "must",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exports[`EuiSearchFilters render - with filters 1`] = `
onChange={[Function]}
query={
Query {
"ast": _Ast {
"ast": _AST {
"_clauses": Array [],
"_indexedClauses": Object {
"field": Object {},
Expand Down Expand Up @@ -62,7 +62,7 @@ exports[`EuiSearchFilters render - with filters 1`] = `
onChange={[Function]}
query={
Query {
"ast": _Ast {
"ast": _AST {
"_clauses": Array [],
"_indexedClauses": Object {
"field": Object {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { isArray, isNil } from '../../../services/predicate';
import { keyCodes } from '../../../services';
Expand All @@ -10,7 +10,7 @@ import { EuiFilterSelectItem, EuiFilterButton } from '../../filter_group';
import { EuiLoadingChart } from '../../loading/loading_chart';
import { EuiSpacer } from '../../spacer/spacer';
import { EuiIcon } from '../../icon/icon';
import { Query } from '../../../services/query';
import { Query } from '../query';

const FieldValueOptionType = PropTypes.shape({
value: PropTypes.any.isRequired,
Expand Down Expand Up @@ -52,7 +52,7 @@ const defaults = {
}
};

export class FieldValueSelectionFilter extends React.Component {
export class FieldValueSelectionFilter extends Component {

static propTypes = FieldValueSelectionFilterPropTypes;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { shallow } from 'enzyme';
import { requiredProps } from '../../../test';
import { shallow } from 'enzyme';
import { FieldValueSelectionFilter } from './field_value_selection_filter';
import { Query } from '../../../services/query';
import { Query } from '../query';

describe('FieldValueSelectionFilter', () => {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { EuiFilterButton } from '../../filter_group';
import { isNil } from '../../../services/predicate';
import { EuiPropTypes } from '../../../utils/prop_types';
import { Query } from '../../../services/query';
import { Query } from '../query';

export const FieldValueToggleFilterConfigType = PropTypes.shape({
type: EuiPropTypes.is('field_value_toggle').isRequired,
Expand All @@ -21,7 +21,7 @@ const FieldValueToggleFilterPropTypes = {
onChange: PropTypes.func.isRequired, // (value: boolean) => void
};

export class FieldValueToggleFilter extends React.Component {
export class FieldValueToggleFilter extends Component {

static propTypes = FieldValueToggleFilterPropTypes;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { shallow } from 'enzyme';
import { requiredProps } from '../../../test';
import { Query } from '../../../services/query';
import { shallow } from 'enzyme';
import { Query } from '../query';
import { FieldValueToggleFilter } from './field_value_toggle_filter';

describe('FieldValueToggleFilter', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { EuiFilterButton } from '../../filter_group';
import { EuiPropTypes } from '../../../utils/prop_types';
import { Query } from '../../../services/query';
import { Query } from '../query';

export const FieldValueToggleGroupFilterItemType = PropTypes.shape({
value: PropTypes.string.isRequired,
Expand All @@ -24,7 +24,7 @@ const FieldValueToggleGroupFilterPropTypes = {
onChange: PropTypes.func.isRequired, // (value: boolean) => void
};

export class FieldValueToggleGroupFilter extends React.Component {
export class FieldValueToggleGroupFilter extends Component {

static propTypes = FieldValueToggleGroupFilterPropTypes;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { shallow } from 'enzyme';
import { requiredProps } from '../../../test';
import { Query } from '../../../services/query';
import { shallow } from 'enzyme';
import { Query } from '../query';
import { FieldValueToggleGroupFilter } from './field_value_toggle_group_filter';

describe('TermToggleGroupFilter', () => {
Expand Down
Loading

0 comments on commit 4377f22

Please sign in to comment.