File tree Expand file tree Collapse file tree 4 files changed +50
-12
lines changed Expand file tree Collapse file tree 4 files changed +50
-12
lines changed Original file line number Diff line number Diff line change 1- import { Link } from "react-router"
21import { Button , Panel , PanelMain } from "@patternfly/react-core"
2+ import { Link , useLocation , useSearchParams } from "react-router"
33
44import Tile from "./welcome/Tile"
55import Result from "../view/Result"
@@ -11,7 +11,11 @@ import { hasResult } from "../helpers"
1111
1212import DemoIcon from "@patternfly/react-icons/dist/esm/icons/sun-icon"
1313
14- function demoTiles ( ) {
14+ function DemoTiles ( ) {
15+ const { hash } = useLocation ( )
16+ const [ searchParams ] = useSearchParams ( )
17+ const s = searchParams . toString ( )
18+
1519 return demos . map ( ( demo ) => {
1620 // TODO useMemo()
1721 const data = JSON . parse ( demo . trace )
@@ -33,7 +37,14 @@ function demoTiles() {
3337 }
3438 >
3539 < Button isInline variant = "link" >
36- < Link to = { "/demos/" + encodeURIComponent ( demo . name ) } >
40+ < Link
41+ to = {
42+ "/demos/" +
43+ encodeURIComponent ( demo . name ) +
44+ ( s ? `?${ s } ` : "" ) +
45+ hash
46+ }
47+ >
3748 Show this Demo
3849 </ Link >
3950 </ Button >
@@ -47,7 +58,7 @@ export default function Demos() {
4758 < Welcome
4859 breadcrumb1 = "Demos"
4960 intro = "Here are some built-in PDL demos"
50- tiles = { demoTiles ( ) }
61+ tiles = { < DemoTiles /> }
5162 />
5263 )
5364}
Original file line number Diff line number Diff line change 1- import { Link } from "react-router"
21import { Button , Panel , PanelMain } from "@patternfly/react-core"
2+ import { Link , useLocation , useSearchParams } from "react-router"
33
44import Tile from "./welcome/Tile"
55import Result from "../view/Result"
@@ -11,7 +11,11 @@ import { nonNullable } from "../helpers"
1111
1212import MyIcon from "@patternfly/react-icons/dist/esm/icons/user-icon"
1313
14- function myTiles ( ) {
14+ function MyTiles ( ) {
15+ const { hash } = useLocation ( )
16+ const [ searchParams ] = useSearchParams ( )
17+ const s = searchParams . toString ( )
18+
1519 return getMyTraces ( )
1620 . map ( ( { title, filename, value } ) => {
1721 try {
@@ -35,7 +39,11 @@ function myTiles() {
3539 }
3640 >
3741 < Button isInline variant = "link" >
38- < Link to = { "/my/" + encodeURIComponent ( title ) } >
42+ < Link
43+ to = {
44+ "/my/" + encodeURIComponent ( title ) + ( s ? `?${ s } ` : "" ) + hash
45+ }
46+ >
3947 Show this Trace
4048 </ Link >
4149 </ Button >
@@ -53,7 +61,7 @@ export default function MyTraces() {
5361 < Welcome
5462 breadcrumb1 = "My Traces"
5563 intro = "Here are your recently uploaded traces"
56- tiles = { myTiles ( ) }
64+ tiles = { < MyTiles /> }
5765 />
5866 )
5967}
Original file line number Diff line number Diff line change 1- import { Link } from "react-router"
21import { Button } from "@patternfly/react-core"
2+ import { Link , useLocation , useSearchParams } from "react-router"
33
44import Tile from "../Tile"
55import demos from "../../../demos/demos"
66
77import DemoIcon from "@patternfly/react-icons/dist/esm/icons/sun-icon"
88
99export default function Demos ( ) {
10+ const { hash } = useLocation ( )
11+ const [ searchParams ] = useSearchParams ( )
12+ const s = searchParams . toString ( )
13+
1014 return (
1115 < Tile
1216 title = "View a Demo"
@@ -15,7 +19,14 @@ export default function Demos() {
1519 >
1620 { demos . map ( ( demo ) => (
1721 < Button key = { demo . name } isInline variant = "link" >
18- < Link to = { "/demos/" + encodeURIComponent ( demo . name ) } >
22+ < Link
23+ to = {
24+ "/demos/" +
25+ encodeURIComponent ( demo . name ) +
26+ ( s ? `?${ s } ` : "" ) +
27+ hash
28+ }
29+ >
1930 { demo . name }
2031 </ Link >
2132 </ Button >
Original file line number Diff line number Diff line change 1- import { Link } from "react-router"
21import { Button } from "@patternfly/react-core"
2+ import { Link , useLocation , useSearchParams } from "react-router"
33
44import Tile from "../Tile"
55import { getMyTraces } from "../../MyTraces"
66
77import MyIcon from "@patternfly/react-icons/dist/esm/icons/user-icon"
88
99export default function MyTraces ( ) {
10+ const { hash } = useLocation ( )
11+ const [ searchParams ] = useSearchParams ( )
12+ const s = searchParams . toString ( )
13+
1014 const myTraces = getMyTraces ( )
1115
1216 return (
@@ -17,7 +21,11 @@ export default function MyTraces() {
1721 >
1822 { myTraces . map ( ( { title, filename } ) => (
1923 < Button key = { filename } isInline variant = "link" >
20- < Link to = { "/my/" + encodeURIComponent ( title ) } > { title } </ Link >
24+ < Link
25+ to = { "/my/" + encodeURIComponent ( title ) + ( s ? `?${ s } ` : "" ) + hash }
26+ >
27+ { title }
28+ </ Link >
2129 </ Button >
2230 ) ) }
2331 </ Tile >
You can’t perform that action at this time.
0 commit comments