Skip to content

Commit

Permalink
Fix jest test and remove getting filter param from parent
Browse files Browse the repository at this point in the history
  • Loading branch information
jloleysens committed Jun 2, 2020
1 parent c40ade5 commit 0f5f80a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { WithAppDependencies, services } from './setup_environment';
const testBedConfig: TestBedConfig = {
store: () => indexManagementStore(services as any),
memoryRouter: {
initialEntries: [`${BASE_PATH}indices?includeHidden=true`],
initialEntries: [`${BASE_PATH}indices?includeHiddenIndices=true`],
componentRoutePath: `${BASE_PATH}:section(indices|templates)`,
},
doMountAsync: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ import React from 'react';
import { DetailPanel } from './detail_panel';
import { IndexTable } from './index_table';

export function IndexList({
match: {
params: { filter },
},
}) {
export function IndexList() {
return (
<div className="im-snapshotTestSubject" data-test-subj="indicesList">
<IndexTable filterFromURI={filter} />
<IndexTable />
<DetailPanel />
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export class IndexTable extends Component {

this.state = {
includeHiddenIndices: false,
dataStreamFilter: undefined,
selectedIndicesMap: {},
};
}
Expand All @@ -106,10 +105,10 @@ export class IndexTable extends Component {
() => this.props.reloadIndices(this.props.indices.map((i) => i.name)),
REFRESH_RATE_INDEX_LIST
);
const { filterChanged, filterFromURI } = this.props;

if (filterFromURI) {
const decodedFilter = decodeURIComponent(filterFromURI);
const { location, filterChanged } = this.props;
const { filter } = qs.parse((location && location.search) || '');
if (filter) {
const decodedFilter = decodeURIComponent(filter);

try {
const filter = EuiSearchBar.Query.parse(decodedFilter);
Expand All @@ -118,19 +117,21 @@ export class IndexTable extends Component {
this.setState({ filterError: e });
}
}
this.syncUrlParams();

this.syncFromUrlParams();
}
componentWillUnmount() {
clearInterval(this.interval);
}

componentDidUpdate() {
this.syncUrlParams();
this.syncFromUrlParams();
}

syncUrlParams() {
syncFromUrlParams() {
const { location } = this.props;
const { includeHiddenIndices } = qs.parse((location && location.search) || '');

const nextValue = includeHiddenIndices === 'true';
if (this.state.includeHiddenIndices !== nextValue) {
this.setState({ includeHiddenIndices: nextValue });
Expand Down

0 comments on commit 0f5f80a

Please sign in to comment.