diff --git a/ui/src/components/featureList.tsx b/ui/src/components/featureList.tsx index 000d18815..511fc48ba 100644 --- a/ui/src/components/featureList.tsx +++ b/ui/src/components/featureList.tsx @@ -1,5 +1,5 @@ import React, { useCallback, useEffect, useState } from "react"; -import { Link, useNavigate } from "react-router-dom"; +import { Link, useNavigate, useSearchParams } from "react-router-dom"; import { DownOutlined } from "@ant-design/icons"; import { Button, @@ -14,7 +14,12 @@ import { import { Feature } from "../models/model"; import { fetchProjects, fetchFeatures } from "../api"; -const FeatureList = () => { +type Props = { + projectProp: string; + keywordProp: string; +}; + +const FeatureList = ({ projectProp, keywordProp }: Props) => { const navigate = useNavigate(); const columns = [ { @@ -171,9 +176,10 @@ const FeatureList = () => { const [page, setPage] = useState(1); const [loading, setLoading] = useState(false); const [tableData, setTableData] = useState(); - const [query, setQuery] = useState(""); + const [query, setQuery] = useState(keywordProp); const [projects, setProjects] = useState([]); - const [project, setProject] = useState(""); + const [project, setProject] = useState(projectProp); + const [, setURLSearchParams] = useSearchParams(); const fetchData = useCallback( async (project) => { @@ -182,8 +188,12 @@ const FeatureList = () => { setPage(page); setTableData(result); setLoading(false); + setURLSearchParams({ + project: project, + keyword: query, + }); }, - [page, query] + [page, query, setURLSearchParams] ); const loadProjects = useCallback(async () => { @@ -196,6 +206,12 @@ const FeatureList = () => { loadProjects(); }, [loadProjects]); + useEffect(() => { + if (projectProp) { + fetchData(projectProp); + } + }, [projectProp, fetchData]); + const onProjectChange = async (value: string) => { setProject(value); fetchData(value); @@ -233,6 +249,7 @@ const FeatureList = () => { > onKeywordChange(e.target.value)} diff --git a/ui/src/pages/feature/featureDetails.tsx b/ui/src/pages/feature/featureDetails.tsx index a65c94b0a..357a35944 100644 --- a/ui/src/pages/feature/featureDetails.tsx +++ b/ui/src/pages/feature/featureDetails.tsx @@ -275,6 +275,9 @@ const FeatureDetails = () => { } else { return ( <> + {data.attributes.name}
diff --git a/ui/src/pages/feature/features.tsx b/ui/src/pages/feature/features.tsx index f5d74d3bb..69ca76af9 100644 --- a/ui/src/pages/feature/features.tsx +++ b/ui/src/pages/feature/features.tsx @@ -1,6 +1,5 @@ -import React from "react"; import { Button, Card, Space, Typography } from "antd"; -import { useNavigate } from "react-router-dom"; +import { useNavigate, useSearchParams } from "react-router-dom"; import FeatureList from "../../components/featureList"; const { Title } = Typography; @@ -10,6 +9,9 @@ const Features = () => { const onCreateFeatureClick = () => { navigate("/new-feature"); }; + const [searchParams] = useSearchParams(); + const project = (searchParams.get("project") as string) ?? ""; + const keyword = (searchParams.get("keyword") as string) ?? ""; return (
@@ -28,7 +30,7 @@ const Features = () => { + Create Feature - +
);