From 94fef500fcee4f3eb33d27c10423e5762a0f44a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rge=20N=C3=A6ss?= Date: Fri, 10 Nov 2023 14:42:32 +0100 Subject: [PATCH] dev(test-studio): add router debugging tool (#5170) --- .../plugins/router-debug/RouterDebug.tsx | 90 +++++++++++++++++++ dev/test-studio/plugins/router-debug/index.ts | 1 + .../plugins/router-debug/plugin.tsx | 40 +++++++++ dev/test-studio/plugins/router-debug/types.ts | 7 ++ dev/test-studio/sanity.config.ts | 3 + 5 files changed, 141 insertions(+) create mode 100644 dev/test-studio/plugins/router-debug/RouterDebug.tsx create mode 100644 dev/test-studio/plugins/router-debug/index.ts create mode 100644 dev/test-studio/plugins/router-debug/plugin.tsx create mode 100644 dev/test-studio/plugins/router-debug/types.ts diff --git a/dev/test-studio/plugins/router-debug/RouterDebug.tsx b/dev/test-studio/plugins/router-debug/RouterDebug.tsx new file mode 100644 index 000000000000..5569c536b91e --- /dev/null +++ b/dev/test-studio/plugins/router-debug/RouterDebug.tsx @@ -0,0 +1,90 @@ +import React from 'react' +import {Button, Card, Code, Flex, Stack, Text} from '@sanity/ui' +import {IntentLink, RouteScope, StateLink, useRouter, useStateLink} from 'sanity/router' + +export function RouterDebug() { + const {navigate} = useRouter() + + const link = useStateLink({ + state: { + section: 'abc', + _searchParams: [['viewParam', 'from link']], + }, + }) + + return ( + + + + Tool home + + Go to section "abc", with search params + + + + Resolve intent + +