Name query filter on targets (#3144)

* Name query filter on targets

* s/name/filter

* Apply ?filter=<string> on all Filtered wrappers
This commit is contained in:
Jaco Greeff 2020-07-08 13:03:35 +02:00 committed by GitHub
parent 449b5f2446
commit f5efb7769b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,9 +2,11 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import React from 'react';
import queryString from 'query-string';
import React, { useEffect } from 'react';
import { Input, Toggle } from '@polkadot/react-components';
import { useApi } from '@polkadot/react-hooks';
import { isString } from '@polkadot/util';
import { useTranslation } from './translate';
@ -21,6 +23,16 @@ function Filtering ({ children, className, nameFilter, setNameFilter, setWithIde
const { t } = useTranslation();
const { api } = useApi();
// on load, parse the query string and extract the filter
useEffect((): void => {
const queryFilter = queryString.parse(location.href.split('?')[1]).filter;
if (isString(queryFilter)) {
setNameFilter(queryFilter);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return (
<div className={className}>
<Input