From 62ad53d5698a58080fdf1c71cc4bfa998b2b6814 Mon Sep 17 00:00:00 2001 From: Griffin Tarpenning Date: Wed, 22 Jan 2025 13:30:42 -0800 Subject: [PATCH] fix(weave): navigate properly when deleting obj/op version fullscreen (#3465) --- .../pages/ObjectsPage/ObjectDeleteButtons.tsx | 30 +++++++++++++++++-- .../Browse3/pages/OpsPage/OpVersionPage.tsx | 30 +++++++++++++++++-- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/ObjectsPage/ObjectDeleteButtons.tsx b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/ObjectsPage/ObjectDeleteButtons.tsx index 7d9aaf4cee99..f86d40c6f873 100644 --- a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/ObjectsPage/ObjectDeleteButtons.tsx +++ b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/ObjectsPage/ObjectDeleteButtons.tsx @@ -1,8 +1,13 @@ import {Button} from '@wandb/weave/components/Button'; import {maybePluralizeWord} from '@wandb/weave/core/util/string'; -import React, {useState} from 'react'; +import React, {useContext, useState} from 'react'; +import {useHistory} from 'react-router-dom'; -import {useClosePeek} from '../../context'; +import { + useClosePeek, + useWeaveflowCurrentRouteContext, + WeaveflowPeekContext, +} from '../../context'; import {DeleteModal} from '../common/DeleteModal'; import {useWFHooks} from '../wfReactInterface/context'; import {ObjectVersionSchema} from '../wfReactInterface/wfDataModelHooksInterface'; @@ -13,6 +18,9 @@ export const DeleteObjectButtonWithModal: React.FC<{ }> = ({objVersionSchema, overrideDisplayStr}) => { const {useObjectDeleteFunc} = useWFHooks(); const closePeek = useClosePeek(); + const {isPeeking} = useContext(WeaveflowPeekContext); + const routerContext = useWeaveflowCurrentRouteContext(); + const history = useHistory(); const {objectVersionsDelete} = useObjectDeleteFunc(); const [deleteModalOpen, setDeleteModalOpen] = useState(false); @@ -20,6 +28,22 @@ export const DeleteObjectButtonWithModal: React.FC<{ overrideDisplayStr ?? `${objVersionSchema.objectId}:v${objVersionSchema.versionIndex}`; + const onSuccess = () => { + if (isPeeking) { + closePeek(); + } else { + history.push( + routerContext.objectVersionsUIUrl( + objVersionSchema.entity, + objVersionSchema.project, + { + objectName: objVersionSchema.objectId, + } + ) + ); + } + }; + return ( <>