Skip to content

Commit 3579553

Browse files
author
David GABISON
committed
feat: allow third party plugin to add filters
1 parent a8166d1 commit 3579553

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Views/Components/ListTable/Filters/index.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ export const Filter = ({filter, value = null, onChange, debouncedOnChange}) => {
5151
};
5252

5353
// figure out what the initial filter state should be based on the filter configuration
54-
export const getInitialFilterState = (filters) => {
54+
export const getInitialFilterState = (filters, apiSettings) => {
5555
const state = {};
5656
const urlParams = new URLSearchParams(window.location.search);
57+
58+
// Allow third party extends filters
59+
filters = wp.hooks.applyFilters(`give-${apiSettings.table.id}-list-table-filters`, filters);
5760
filters.map((filter) => {
5861
// if the search parameters contained a value for the filter, use that
5962
const filterQuery = decodeURI(urlParams.get(filter.name));

src/Views/Components/ListTable/ListTablePage/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export default function ListTablePage({
8484
}: ListTablePageProps) {
8585
const [page, setPage] = useState<number>(1);
8686
const [perPage, setPerPage] = useState<number>(30);
87-
const [filters, setFilters] = useState(getInitialFilterState(filterSettings));
87+
const [filters, setFilters] = useState(getInitialFilterState(filterSettings, apiSettings));
8888
const [modalContent, setModalContent] = useState<{confirm; action; label; type?: 'normal' | 'warning' | 'danger'}>({
8989
confirm: (selected) => {},
9090
action: (selected) => {},

0 commit comments

Comments
 (0)