Skip to content

Commit

Permalink
fix(ui): links dont push to history twice (#3446)
Browse files Browse the repository at this point in the history
  • Loading branch information
gtarpenning authored Jan 22, 2025
1 parent b267e27 commit 60cf461
Showing 1 changed file with 5 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '@wandb/weave/common/css/color.styles';
import {WeaveObjectRef} from '@wandb/weave/react';
import React from 'react';
import {Link as LinkComp, useHistory} from 'react-router-dom';
import {Link as LinkComp} from 'react-router-dom';
import styled, {css} from 'styled-components';

import {TargetBlank} from '../../../../../../common/util/links';
Expand Down Expand Up @@ -161,7 +161,6 @@ export const ObjectVersionLink: React.FC<{
color?: string;
hideVersionSuffix?: boolean;
}> = props => {
const history = useHistory();
const {peekingRouter} = useWeaveflowRouteContext();
// const text = props.hideName
// ? props.version
Expand All @@ -177,15 +176,9 @@ export const ObjectVersionLink: React.FC<{
props.filePath,
props.refExtra
);
const onClick = () => {
history.push(to);
};

return (
<LinkWrapper
onClick={onClick}
fullWidth={props.fullWidth}
color={props.color}>
<LinkWrapper fullWidth={props.fullWidth} color={props.color}>
<LinkTruncater fullWidth={props.fullWidth}>
<Link
to={to}
Expand Down Expand Up @@ -244,7 +237,6 @@ export const OpVersionLink: React.FC<{
fullWidth?: boolean;
color?: string;
}> = props => {
const history = useHistory();
const {peekingRouter} = useWeaveflowRouteContext();
// const text = props.hideName
// ? props.version
Expand All @@ -256,14 +248,8 @@ export const OpVersionLink: React.FC<{
props.opName,
props.version
);
const onClick = () => {
history.push(to);
};
return (
<LinkWrapper
onClick={onClick}
fullWidth={props.fullWidth}
color={props.color}>
<LinkWrapper fullWidth={props.fullWidth} color={props.color}>
<LinkTruncater fullWidth={props.fullWidth}>
<Link $variant={props.variant} to={to}>
{text}
Expand All @@ -276,7 +262,6 @@ export const OpVersionLink: React.FC<{
export const CallRefLink: React.FC<{
callRef: WeaveObjectRef;
}> = props => {
const history = useHistory();
const {peekingRouter} = useWeaveflowRouteContext();
const callId = props.callRef.artifactName;
const to = peekingRouter.callUIUrl(
Expand All @@ -285,16 +270,13 @@ export const CallRefLink: React.FC<{
'',
callId
);
const onClick = () => {
history.push(to);
};

if (props.callRef.weaveKind !== 'call') {
return null;
}

return (
<LinkWrapper onClick={onClick}>
<LinkWrapper>
<LinkTruncater>
<Link
to={to}
Expand Down Expand Up @@ -327,7 +309,6 @@ export const CallLink: React.FC<{
color?: string;
isEval?: boolean;
}> = props => {
const history = useHistory();
const {peekingRouter} = useWeaveflowRouteContext();

const opName = opNiceName(props.opName);
Expand Down Expand Up @@ -360,15 +341,9 @@ export const CallLink: React.FC<{
showTraceTree,
showFeedbackExpand
);
const onClick = () => {
history.push(to);
};

return (
<LinkWrapper
onClick={onClick}
fullWidth={props.fullWidth}
color={props.color}>
<LinkWrapper fullWidth={props.fullWidth} color={props.color}>
<LinkTruncater fullWidth={props.fullWidth}>
<Link
$variant={props.variant}
Expand Down

0 comments on commit 60cf461

Please sign in to comment.