Skip to content

Commit 9265cfc

Browse files
authored
chore: Set router basename to simplify paths in /ui (#5004)
1 parent 87a7c23 commit 9265cfc

21 files changed

+33
-47
lines changed

ui/src/FeastUI.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ const defaultQueryClient = new QueryClient();
1515

1616
const FeastUI = ({ reactQueryClient, feastUIConfigs }: FeastUIProps) => {
1717
const queryClient = reactQueryClient || defaultQueryClient;
18+
const basename = process.env.PUBLIC_URL ?? '';
1819

1920
return (
2021
// Disable v7_relativeSplatPath: custom tab routes don't currently work with it
21-
<BrowserRouter future={{ v7_relativeSplatPath: false, v7_startTransition: true }}>
22+
<BrowserRouter
23+
basename={basename}
24+
future={{ v7_relativeSplatPath: false, v7_startTransition: true }}
25+
>
2226
<QueryClientProvider client={queryClient}>
2327
<QueryParamProvider adapter={ReactRouter6Adapter}>
2428
<FeastUISansProviders feastUIConfigs={feastUIConfigs} />

ui/src/FeastUISansProviders.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ const FeastUISansProviders = ({
6262
isCustom: true,
6363
}
6464
: { projectsListPromise: defaultProjectListPromise(), isCustom: false };
65-
66-
const BASE_URL = process.env.PUBLIC_URL || ""
6765

6866
return (
6967
<EuiProvider colorMode="light">
@@ -76,9 +74,9 @@ const FeastUISansProviders = ({
7674
>
7775
<ProjectListContext.Provider value={projectListContext}>
7876
<Routes>
79-
<Route path={BASE_URL + "/"} element={<Layout />}>
77+
<Route path="/" element={<Layout />}>
8078
<Route index element={<RootProjectSelectionPage />} />
81-
<Route path={BASE_URL + "/p/:projectName/*"} element={<NoProjectGuard />}>
79+
<Route path="/p/:projectName/*" element={<NoProjectGuard />}>
8280
<Route index element={<ProjectOverviewPage />} />
8381
<Route path="data-source/" element={<DatasourceIndex />} />
8482
<Route

ui/src/components/FeaturesInServiceDisplay.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ const FeaturesInServiceList = ({ featureViews }: FeatureViewsListInterace) => {
2828
field: "featureViewName",
2929
render: (name: string) => {
3030
return (
31-
<EuiCustomLink
32-
to={`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-view/${name}`}
33-
>
31+
<EuiCustomLink to={`/p/${projectName}/feature-view/${name}`}>
3432
{name}
3533
</EuiCustomLink>
3634
);

ui/src/components/FeaturesListDisplay.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const FeaturesList = ({
2121
field: "name",
2222
render: (item: string) => (
2323
<EuiCustomLink
24-
to={`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-view/${featureViewName}/feature/${item}`}
24+
to={`/p/${projectName}/feature-view/${featureViewName}/feature/${item}`}
2525
>
2626
{item}
2727
</EuiCustomLink>

ui/src/components/ObjectsCountStats.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const ObjectsCountStats = () => {
5555
<EuiFlexItem>
5656
<EuiStat
5757
style={statStyle}
58-
onClick={() => navigate(`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-service`)}
58+
onClick={() => navigate(`/p/${projectName}/feature-service`)}
5959
description="Feature Services→"
6060
title={data.featureServices}
6161
reverse
@@ -65,7 +65,7 @@ const ObjectsCountStats = () => {
6565
<EuiStat
6666
style={statStyle}
6767
description="Feature Views→"
68-
onClick={() => navigate(`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-view`)}
68+
onClick={() => navigate(`/p/${projectName}/feature-view`)}
6969
title={data.featureViews}
7070
reverse
7171
/>
@@ -74,7 +74,7 @@ const ObjectsCountStats = () => {
7474
<EuiStat
7575
style={statStyle}
7676
description="Entities→"
77-
onClick={() => navigate(`${process.env.PUBLIC_URL || ""}/p/${projectName}/entity`)}
77+
onClick={() => navigate(`/p/${projectName}/entity`)}
7878
title={data.entities}
7979
reverse
8080
/>
@@ -83,7 +83,7 @@ const ObjectsCountStats = () => {
8383
<EuiStat
8484
style={statStyle}
8585
description="Data Sources→"
86-
onClick={() => navigate(`${process.env.PUBLIC_URL || ""}/p/${projectName}/data-source`)}
86+
onClick={() => navigate(`/p/${projectName}/data-source`)}
8787
title={data.dataSources}
8888
reverse
8989
/>

ui/src/components/ProjectSelector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const ProjectSelector = () => {
2222

2323
const basicSelectId = useGeneratedHtmlId({ prefix: "basicSelect" });
2424
const onChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
25-
navigate(`${process.env.PUBLIC_URL || ""}/p/${e.target.value}`);
25+
navigate(`/p/${e.target.value}`);
2626
};
2727

2828
return (

ui/src/pages/RootProjectSelectionPage.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ const RootProjectSelectionPage = () => {
2121
useEffect(() => {
2222
if (data && data.default) {
2323
// If a default is set, redirect there.
24-
navigate(`${process.env.PUBLIC_URL || ""}/p/${data.default}`);
24+
navigate(`/p/${data.default}`);
2525
}
2626

2727
if (data && data.projects.length === 1) {
2828
// If there is only one project, redirect there.
29-
navigate(`${process.env.PUBLIC_URL || ""}/p/${data.projects[0].id}`);
29+
navigate(`/p/${data.projects[0].id}`);
3030
}
3131
}, [data, navigate]);
3232

@@ -38,7 +38,7 @@ const RootProjectSelectionPage = () => {
3838
title={`${item.name}`}
3939
description={item?.description || ""}
4040
onClick={() => {
41-
navigate(`${process.env.PUBLIC_URL || ""}/p/${item.id}`);
41+
navigate(`/p/${item.id}`);
4242
}}
4343
/>
4444
</EuiFlexItem>

ui/src/pages/Sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const SideNav = () => {
5353
: ""
5454
}`;
5555

56-
const baseUrl = `${process.env.PUBLIC_URL || ""}/p/${projectName}`;
56+
const baseUrl = `/p/${projectName}`;
5757

5858
const sideNav: React.ComponentProps<typeof EuiSideNav>['items'] = [
5959
{

ui/src/pages/data-sources/DataSourcesListingTable.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ const DatasourcesListingTable = ({
2020
sortable: true,
2121
render: (name: string) => {
2222
return (
23-
<EuiCustomLink
24-
to={`${process.env.PUBLIC_URL || ""}/p/${projectName}/data-source/${name}`}
25-
>
23+
<EuiCustomLink to={`/p/${projectName}/data-source/${name}`}>
2624
{name}
2725
</EuiCustomLink>
2826
);

ui/src/pages/entities/EntitiesListingTable.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ const EntitiesListingTable = ({ entities }: EntitiesListingTableProps) => {
2020
sortable: true,
2121
render: (name: string) => {
2222
return (
23-
<EuiCustomLink
24-
to={`${process.env.PUBLIC_URL || ""}/p/${projectName}/entity/${name}`}
25-
>
23+
<EuiCustomLink to={`/p/${projectName}/entity/${name}`}>
2624
{name}
2725
</EuiCustomLink>
2826
);

0 commit comments

Comments
 (0)