Skip to content

Commit

Permalink
Merge pull request Netflix#18 from outerbounds/bug/trigger-link-basename
Browse files Browse the repository at this point in the history
 Use Link instead of a
  • Loading branch information
obgibson authored Feb 27, 2024
2 parents 7f8798d + 0d2aaf2 commit 8560559
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
24 changes: 15 additions & 9 deletions src/components/Trigger/__tests__/Trigger.test.cypress.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
import React from 'react';
import { mount } from '@cypress/react';
import { ThemeProvider } from 'styled-components';
import { BrowserRouter as Router } from 'react-router-dom';
import theme from '../../../theme';
import Trigger from '..';

const flow_name = 'HelloFlow';
const run_id = 'argo-helloflow-atykf';
const basename = 'abasename';

describe('Trigger test', () => {
it('Shows event', () => {
mount(
<ThemeProvider theme={theme}>
<Trigger
triggerEventsValue={{
name: 'metaflow_flow_run_succeeded',
timestamp: '1663184739',
id: `${flow_name}/${run_id}`,
type: 'run',
}}
/>
<Router basename={basename}>
<Trigger
triggerEventsValue={{
name: 'metaflow_flow_run_succeeded',
timestamp: '1663184739',
id: `${flow_name}/${run_id}`,
type: 'run',
}}
/>
</Router>
</ThemeProvider>,
);

cy.get('a').should('have.attr', 'href', `/${flow_name}/${run_id}`).and('contain', 'HelloFlow/...flow-atykf');
cy.get('a')
.should('have.attr', 'href', `/${basename}/${flow_name}/${run_id}`)
.and('contain', 'HelloFlow/...flow-atykf');
});
});
13 changes: 8 additions & 5 deletions src/components/Trigger/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import Icon from '../Icon';
import styled from 'styled-components';
import Tooltip from '../Tooltip';
import { Link } from 'react-router-dom';

const MAX_LABEL_WIDTH = 20; // number of characters to show before truncating

Expand Down Expand Up @@ -44,10 +45,12 @@ const Trigger: React.FC<Props> = ({ triggerEventsValue, className, showToolTip =

return (
<TriggerLine key={id} data-tip data-for={tooltipId} className={className}>
<TriggerLink href={link}>
<StyledIcon name="arrow" linkToRun={linkToRun} />
{showToolTip ? displayLabel : id}
</TriggerLink>
{link && (
<TriggerLink to={link}>
<StyledIcon name="arrow" linkToRun={linkToRun} />
{showToolTip ? displayLabel : id}
</TriggerLink>
)}
{showToolTip && <Tooltip id={tooltipId}>{label}</Tooltip>}
</TriggerLine>
);
Expand All @@ -63,7 +66,7 @@ const TriggerLine = styled.div`
position: relative;
`;

const TriggerLink = styled.a`
const TriggerLink = styled(Link)`
text-decoration: none;
color: inherit;
`;
Expand Down

0 comments on commit 8560559

Please sign in to comment.