From 66db3a9cc99301db460cb60e2254c6f2ede2f092 Mon Sep 17 00:00:00 2001 From: Nik Nasr Date: Thu, 24 Oct 2024 17:53:54 +0100 Subject: [PATCH 1/3] make register dialog sync with query Signed-off-by: Nik Nasr --- .../src/lib/RegisterDeployment/Dialog.tsx | 15 +++++--- .../src/lib/RegisterDeployment/constant.ts | 1 + libs/ui/dialog/src/lib/Dialog.tsx | 36 ++++++++++++++++++- 3 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 libs/features/overview-route/src/lib/RegisterDeployment/constant.ts diff --git a/libs/features/overview-route/src/lib/RegisterDeployment/Dialog.tsx b/libs/features/overview-route/src/lib/RegisterDeployment/Dialog.tsx index b067f629..fe3b7646 100644 --- a/libs/features/overview-route/src/lib/RegisterDeployment/Dialog.tsx +++ b/libs/features/overview-route/src/lib/RegisterDeployment/Dialog.tsx @@ -5,11 +5,14 @@ import { DialogContent, DialogFooter, DialogTrigger, + DialogWithQuery, } from '@restate/ui/dialog'; import { Icon, IconName } from '@restate/ui/icons'; import { PropsWithChildren } from 'react'; import { ErrorBanner } from '@restate/ui/error'; import { RegistrationForm } from './Form'; +import { REGISTER_DEPLOYMENT_QUERY } from './constant'; +import { Link } from '@restate/ui/link'; function RegisterDeploymentFooter({ isDryRun, @@ -67,16 +70,20 @@ export function TriggerRegisterDeploymentDialog({ children = 'Register deployment', }: PropsWithChildren>) { return ( - + - + {RegisterDeploymentFooter} - + ); } diff --git a/libs/features/overview-route/src/lib/RegisterDeployment/constant.ts b/libs/features/overview-route/src/lib/RegisterDeployment/constant.ts new file mode 100644 index 00000000..2b8d3b35 --- /dev/null +++ b/libs/features/overview-route/src/lib/RegisterDeployment/constant.ts @@ -0,0 +1 @@ +export const REGISTER_DEPLOYMENT_QUERY = 'register-deployment'; diff --git a/libs/ui/dialog/src/lib/Dialog.tsx b/libs/ui/dialog/src/lib/Dialog.tsx index f98ef782..845d1507 100644 --- a/libs/ui/dialog/src/lib/Dialog.tsx +++ b/libs/ui/dialog/src/lib/Dialog.tsx @@ -1,4 +1,5 @@ -import { PropsWithChildren } from 'react'; +import { useSearchParams } from '@remix-run/react'; +import { PropsWithChildren, useCallback } from 'react'; import { DialogTrigger } from 'react-aria-components'; interface DialogProps { @@ -17,3 +18,36 @@ export function Dialog({ ); } + +export function DialogWithQuery({ + children, + query, + onOpenChange, +}: PropsWithChildren & { query: string }>) { + const [searchParams, setSearchParams] = useSearchParams(); + const isOpen = Boolean(searchParams.has(query)); + + const close = useCallback(() => { + setSearchParams( + (perv) => { + perv.delete(query); + return perv; + }, + { preventScrollReset: true } + ); + }, [query, setSearchParams]); + + return ( + { + onOpenChange?.(isOpen); + if (!isOpen) { + close(); + } + }} + > + {children} + + ); +} From 69c5a8b15422eabe8a2d1b103a1ff30b97ffbd35 Mon Sep 17 00:00:00 2001 From: Nik Nasr Date: Thu, 24 Oct 2024 17:59:37 +0100 Subject: [PATCH 2/3] update some styling Signed-off-by: Nik Nasr --- libs/features/invocations-route/src/lib/invocations.route.tsx | 4 ++-- libs/ui/tooltip/src/lib/InlineTooltip.tsx | 4 ++-- libs/ui/tooltip/src/lib/TooltipContent.tsx | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/features/invocations-route/src/lib/invocations.route.tsx b/libs/features/invocations-route/src/lib/invocations.route.tsx index 73f51cd6..f920da9a 100644 --- a/libs/features/invocations-route/src/lib/invocations.route.tsx +++ b/libs/features/invocations-route/src/lib/invocations.route.tsx @@ -3,7 +3,7 @@ import { Link } from '@restate/ui/link'; function Component() { return ( -
+

Coming soon!

@@ -19,7 +19,7 @@ function Component() { to manage invocations. Below are a few examples of how you can use CLI commands to perform tasks:

- + #List the invocations restate invocations list diff --git a/libs/ui/tooltip/src/lib/InlineTooltip.tsx b/libs/ui/tooltip/src/lib/InlineTooltip.tsx index b3d5b44f..7c3fad04 100644 --- a/libs/ui/tooltip/src/lib/InlineTooltip.tsx +++ b/libs/ui/tooltip/src/lib/InlineTooltip.tsx @@ -25,11 +25,11 @@ export function InlineTooltip({ {children}
-
{title}
+
{title}
{description} {learnMoreHref && ( Date: Thu, 24 Oct 2024 18:05:18 +0100 Subject: [PATCH 3/3] rename Signed-off-by: Nik Nasr --- .../overview-route/src/lib/RegisterDeployment/Dialog.tsx | 7 +++---- libs/ui/dialog/src/lib/Dialog.tsx | 6 ++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/libs/features/overview-route/src/lib/RegisterDeployment/Dialog.tsx b/libs/features/overview-route/src/lib/RegisterDeployment/Dialog.tsx index fe3b7646..bf3d2406 100644 --- a/libs/features/overview-route/src/lib/RegisterDeployment/Dialog.tsx +++ b/libs/features/overview-route/src/lib/RegisterDeployment/Dialog.tsx @@ -1,11 +1,10 @@ import { Button, SubmitButton } from '@restate/ui/button'; import { - Dialog, DialogClose, DialogContent, DialogFooter, DialogTrigger, - DialogWithQuery, + QueryDialog, } from '@restate/ui/dialog'; import { Icon, IconName } from '@restate/ui/icons'; import { PropsWithChildren } from 'react'; @@ -70,7 +69,7 @@ export function TriggerRegisterDeploymentDialog({ children = 'Register deployment', }: PropsWithChildren>) { return ( - + {RegisterDeploymentFooter} - + ); } diff --git a/libs/ui/dialog/src/lib/Dialog.tsx b/libs/ui/dialog/src/lib/Dialog.tsx index 845d1507..4cbd3407 100644 --- a/libs/ui/dialog/src/lib/Dialog.tsx +++ b/libs/ui/dialog/src/lib/Dialog.tsx @@ -19,11 +19,10 @@ export function Dialog({ ); } -export function DialogWithQuery({ +export function QueryDialog({ children, query, - onOpenChange, -}: PropsWithChildren & { query: string }>) { +}: PropsWithChildren<{ query: string }>) { const [searchParams, setSearchParams] = useSearchParams(); const isOpen = Boolean(searchParams.has(query)); @@ -41,7 +40,6 @@ export function DialogWithQuery({ { - onOpenChange?.(isOpen); if (!isOpen) { close(); }