Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
// File name: "EuiCustomLink.js".
import React from "react";
import { EuiLink } from "@elastic/eui";
import { useNavigate, useHref } from "react-router-dom";
import { EuiLink, type EuiLinkAnchorProps } from "@elastic/eui";
import { useNavigate, useHref, type To } from "react-router-dom";

const isModifiedEvent = (event) =>
interface EuiCustomLinkProps extends Omit<EuiLinkAnchorProps, 'href'> {
to: To;
}

const isModifiedEvent = (event: React.MouseEvent) =>
!!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);

const isLeftClickEvent = (event) => event.button === 0;
const isLeftClickEvent = (event: React.MouseEvent) => event.button === 0;

const isTargetBlank = (event) => {
const target = event.target.getAttribute("target");
const isTargetBlank = (event: React.MouseEvent) => {
const target = (event.target as Element).getAttribute("target");
return target && target !== "_self";
};

export default function EuiCustomLink({ to, ...rest }) {
export default function EuiCustomLink({ to, ...rest }: EuiCustomLinkProps) {
// This is the key!
const navigate = useNavigate();

function onClick(event) {
const onClick: React.MouseEventHandler<HTMLAnchorElement> = (event) => {
if (event.defaultPrevented) {
return;
}
Expand All @@ -41,6 +44,5 @@ export default function EuiCustomLink({ to, ...rest }) {
// Generate the correct link href (with basename accounted for)
const href = useHref(to);

const props = { ...rest, href, onClick };
return <EuiLink {...props} />;
return <EuiLink {...rest} href={href} onClick={onClick} />;
}
1 change: 0 additions & 1 deletion ui/src/components/FeaturesInServiceDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const FeaturesInServiceList = ({ featureViews }: FeatureViewsListInterace) => {
render: (name: string) => {
return (
<EuiCustomLink
href={`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-view/${name}`}
to={`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-view/${name}`}
>
{name}
Expand Down
1 change: 0 additions & 1 deletion ui/src/components/FeaturesListDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const FeaturesList = ({
field: "name",
render: (item: string) => (
<EuiCustomLink
href={`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-view/${featureViewName}/feature/${item}`}
to={`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-view/${featureViewName}/feature/${item}`}
>
{item}
Expand Down
1 change: 0 additions & 1 deletion ui/src/pages/data-sources/DataSourcesListingTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const DatasourcesListingTable = ({
render: (name: string) => {
return (
<EuiCustomLink
href={`${process.env.PUBLIC_URL || ""}/p/${projectName}/data-source/${name}`}
to={`${process.env.PUBLIC_URL || ""}/p/${projectName}/data-source/${name}`}
>
{name}
Expand Down
1 change: 0 additions & 1 deletion ui/src/pages/entities/EntitiesListingTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const EntitiesListingTable = ({ entities }: EntitiesListingTableProps) => {
render: (name: string) => {
return (
<EuiCustomLink
href={`${process.env.PUBLIC_URL || ""}/p/${projectName}/entity/${name}`}
to={`${process.env.PUBLIC_URL || ""}/p/${projectName}/entity/${name}`}
>
{name}
Expand Down
1 change: 0 additions & 1 deletion ui/src/pages/entities/FeatureViewEdgesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ const FeatureViewEdgesList = ({ fvNames }: FeatureViewEdgesListInterace) => {
render: ({ name }: { name: string }) => {
return (
<EuiCustomLink
href={`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-view/${name}`}
to={`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-view/${name}`}
>
{name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const FeatureServiceListingTable = ({
render: (name: string) => {
return (
<EuiCustomLink
href={`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-service/${name}`}
to={`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-service/${name}`}
>
{name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const ConsumingFeatureServicesList = ({
render: ({ name }: { name: string }) => {
return (
<EuiCustomLink
href={`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-service/${name}`}
to={`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-service/${name}`}
>
{name}
Expand Down
1 change: 0 additions & 1 deletion ui/src/pages/feature-views/FeatureViewListingTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const FeatureViewListingTable = ({
render: (name: string, item: genericFVType) => {
return (
<EuiCustomLink
href={`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-view/${name}`}
to={`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-view/${name}`}
>
{name} {(item.type === "ondemand" && <EuiBadge>ondemand</EuiBadge>) || (item.type === "stream" && <EuiBadge>stream</EuiBadge>)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ const StreamFeatureViewOverviewTab = ({
</EuiText>
<EuiTitle size="s">
<EuiCustomLink
href={`${process.env.PUBLIC_URL || ""}/p/${projectName}/data-source/${inputGroup?.name}`}
to={`${process.env.PUBLIC_URL || ""}/p/${projectName}/data-source/${inputGroup?.name}`}
>
{inputGroup?.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const FeatureViewProjectionDisplayPanel = (featureViewProjection: RequestDataDis
<EuiSpacer size="xs" />
<EuiTitle size="s">
<EuiCustomLink
href={`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-view/${featureViewProjection.featureViewName}`}
to={`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-view/${featureViewProjection.featureViewName}`}
>
{featureViewProjection?.featureViewName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const RequestDataDisplayPanel = ({
<EuiSpacer size="xs" />
<EuiTitle size="s">
<EuiCustomLink
href={`${process.env.PUBLIC_URL || ""}/p/${projectName}/data-source/${requestDataSource?.name}`}
to={`${process.env.PUBLIC_URL || ""}/p/${projectName}/data-source/${requestDataSource?.name}`}
>
{requestDataSource?.name}
Expand Down
4 changes: 2 additions & 2 deletions ui/src/pages/features/FeatureOverviewTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ const FeatureOverviewTab = () => {
<EuiDescriptionListTitle>FeatureView</EuiDescriptionListTitle>
<EuiDescriptionListDescription>
<EuiCustomLink
href={`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-view/${FeatureViewName}`}
to={`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-view/${FeatureViewName}`}>
to={`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-view/${FeatureViewName}`}
>
{FeatureViewName}
</EuiCustomLink>
</EuiDescriptionListDescription>
Expand Down
1 change: 0 additions & 1 deletion ui/src/pages/saved-data-sets/DatasetsListingTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const DatasetsListingTable = ({ datasets }: DatasetsListingTableProps) => {
render: (name: string) => {
return (
<EuiCustomLink
href={`${process.env.PUBLIC_URL || ""}/p/${projectName}/data-set/${name}`}
to={`${process.env.PUBLIC_URL || ""}/p/${projectName}/data-set/${name}`}
>
{name}
Expand Down