mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
Fix filter redirect on paginated overview page (#1535)
Fix unnecessary redirect on paginated overview pages which cuts the page number from url.
This commit is contained in:
2
gradle/changelog/filter_on_pagination.yaml
Normal file
2
gradle/changelog/filter_on_pagination.yaml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
- type: fixed
|
||||||
|
description: Wrong redirect on paginated overviews ([#1535](https://github.com/scm-manager/scm-manager/pull/1535))
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
import React, { FC } from "react";
|
import React, { FC, useState } from "react";
|
||||||
import { useHistory, useLocation } from "react-router-dom";
|
import { useHistory, useLocation } from "react-router-dom";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { Button, DropDown, urls } from "./index";
|
import { Button, DropDown, urls } from "./index";
|
||||||
@@ -50,6 +50,7 @@ const OverviewPageActions: FC<Props> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
const [filterValue, setFilterValue] = useState(urls.getQueryStringFromLocation(location));
|
||||||
const groupSelector = groups && (
|
const groupSelector = groups && (
|
||||||
<div className={"column is-flex"}>
|
<div className={"column is-flex"}>
|
||||||
<DropDown
|
<DropDown
|
||||||
@@ -72,6 +73,15 @@ const OverviewPageActions: FC<Props> = ({
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const filter = (filter: string) => {
|
||||||
|
if ((filter && filter !== filterValue) || (!filter && filterValue)) {
|
||||||
|
history.push(`/${link}/?q=${filter}`);
|
||||||
|
} else {
|
||||||
|
history.push(`${location.pathname}?q=${filter}`);
|
||||||
|
}
|
||||||
|
setFilterValue(filter);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={"columns is-tablet"}>
|
<div className={"columns is-tablet"}>
|
||||||
{groupSelector}
|
{groupSelector}
|
||||||
@@ -79,9 +89,7 @@ const OverviewPageActions: FC<Props> = ({
|
|||||||
<FilterInput
|
<FilterInput
|
||||||
placeholder={searchPlaceholder}
|
placeholder={searchPlaceholder}
|
||||||
value={urls.getQueryStringFromLocation(location)}
|
value={urls.getQueryStringFromLocation(location)}
|
||||||
filter={filter => {
|
filter={filter}
|
||||||
history.push(`/${link}/?q=${filter}`);
|
|
||||||
}}
|
|
||||||
testId={testId + "-filter"}
|
testId={testId + "-filter"}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user