Skip to content

Commit

Permalink
refactor: includeHidden -> includeHiddenIndices
Browse files Browse the repository at this point in the history
  • Loading branch information
jloleysens committed Jun 2, 2020
1 parent 1de542a commit a48df33
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class IndexTable extends Component {
super(props);

this.state = {
showHiddenIndices: false,
includeHiddenIndices: false,
dataStreamFilter: undefined,
selectedIndicesMap: {},
};
Expand Down Expand Up @@ -130,21 +130,20 @@ export class IndexTable extends Component {

syncUrlParams() {
const { location } = this.props;
// Check if the we have the includeHidden query param
const { includeHidden } = qs.parse((location && location.search) || '');
const nextValue = includeHidden === 'true';
if (this.state.includeHidden !== nextValue) {
this.setState({ includeHidden: nextValue });
const { includeHiddenIndices } = qs.parse((location && location.search) || '');
const nextValue = includeHiddenIndices === 'true';
if (this.state.includeHiddenIndices !== nextValue) {
this.setState({ includeHiddenIndices: nextValue });
}
}

setIncludeHiddenParam(hidden) {
const { pathname, search } = this.props.location;
const params = qs.parse(search);
if (hidden) {
params.includeHidden = 'true';
params.includeHiddenIndices = 'true';
} else {
delete params.includeHidden;
delete params.includeHiddenIndices;
}
this.props.history.push(pathname + '?' + qs.stringify(params));
}
Expand Down Expand Up @@ -497,7 +496,7 @@ export class IndexTable extends Component {
<EuiSwitch
id="checkboxShowHiddenIndices"
data-test-subj="indexTableIncludeHiddenIndicesToggle"
checked={this.state.includeHidden}
checked={this.state.includeHiddenIndices}
onChange={(event) => this.setIncludeHiddenParam(event.target.checked)}
label={
<FormattedMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const getFilteredIndices = createSelector(
(indices, allIds, tableState, tableLocation) => {
let indexArray = allIds.map((indexName) => indices[indexName]);
indexArray = filterByToggles(indexArray, tableState.toggleNameToVisibleMap);
const { includeHidden: includeHiddenParam, dataStreams: dataStreamsParam } = qs.parse(
const { includeHiddenIndices: includeHiddenParam, dataStreams: dataStreamsParam } = qs.parse(
tableLocation.search
);
const includeHidden = includeHiddenParam === 'true';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ describe('getFilteredIndices selector', () => {
});

it('includes hidden indices', () => {
expect(getFilteredIndices(state, { location: { search: '?includeHidden=true' } })).toEqual([
expect(
getFilteredIndices(state, { location: { search: '?includeHiddenIndices=true' } })
).toEqual([
{ name: 'index1', hidden: true, dataStream: '123' },
{ name: 'index2', hidden: false },
{ name: 'index3', dataStream: 'abc' },
Expand All @@ -56,7 +58,7 @@ describe('getFilteredIndices selector', () => {
it('filters based on data stream and includes hidden indices', () => {
expect(
getFilteredIndices(state, {
location: { search: '?includeHidden=true&dataStreams=123,abc,does-not-exist' },
location: { search: '?includeHiddenIndices=true&dataStreams=123,abc,does-not-exist' },
})
).toEqual([
{ name: 'index1', hidden: true, dataStream: '123' },
Expand Down

0 comments on commit a48df33

Please sign in to comment.