Skip to content

Commit

Permalink
fix(weave): navigate properly when deleting obj/op version fullscreen (
Browse files Browse the repository at this point in the history
  • Loading branch information
gtarpenning authored Jan 22, 2025
1 parent 8b3cbc2 commit 62ad53d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -13,13 +18,32 @@ 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);

const deleteStr =
overrideDisplayStr ??
`${objVersionSchema.objectId}:v${objVersionSchema.versionIndex}`;

const onSuccess = () => {
if (isPeeking) {
closePeek();
} else {
history.push(
routerContext.objectVersionsUIUrl(
objVersionSchema.entity,
objVersionSchema.project,
{
objectName: objVersionSchema.objectId,
}
)
);
}
};

return (
<>
<Button
Expand All @@ -39,7 +63,7 @@ export const DeleteObjectButtonWithModal: React.FC<{
[objVersionSchema.versionHash]
)
}
onSuccess={closePeek}
onSuccess={onSuccess}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import {Button} from '@wandb/weave/components/Button';
import React, {useMemo, useState} from 'react';
import React, {useContext, useMemo, useState} from 'react';
import {useHistory} from 'react-router-dom';

import {Icon} from '../../../../../Icon';
import {LoadingDots} from '../../../../../LoadingDots';
import {Tailwind} from '../../../../../Tailwind';
import {useClosePeek} from '../../context';
import {
useClosePeek,
useWeaveflowCurrentRouteContext,
WeaveflowPeekContext,
} from '../../context';
import {NotFoundPanel} from '../../NotFoundPanel';
import {OpCodeViewer} from '../../OpCodeViewer';
import {DeleteModal, useShowDeleteButton} from '../common/DeleteModal';
Expand Down Expand Up @@ -188,13 +193,32 @@ const DeleteOpButtonWithModal: React.FC<{
}> = ({opVersionSchema, overrideDisplayStr}) => {
const {useObjectDeleteFunc} = useWFHooks();
const closePeek = useClosePeek();
const {isPeeking} = useContext(WeaveflowPeekContext);
const routerContext = useWeaveflowCurrentRouteContext();
const history = useHistory();
const {opVersionsDelete} = useObjectDeleteFunc();
const [deleteModalOpen, setDeleteModalOpen] = useState(false);

const deleteStr =
overrideDisplayStr ??
`${opVersionSchema.opId}:v${opVersionSchema.versionIndex}`;

const onSuccess = () => {
if (isPeeking) {
closePeek();
} else {
history.push(
routerContext.opVersionsUIUrl(
opVersionSchema.entity,
opVersionSchema.project,
{
opName: opVersionSchema.opId,
}
)
);
}
};

return (
<>
<Button
Expand All @@ -215,7 +239,7 @@ const DeleteOpButtonWithModal: React.FC<{
[opVersionSchema.versionHash]
)
}
onSuccess={closePeek}
onSuccess={onSuccess}
/>
</>
);
Expand Down

0 comments on commit 62ad53d

Please sign in to comment.