Skip to content

Commit 2f0f7b3

Browse files
peruukkiredhatHameed
authored andcommitted
feat!: Include PUBLIC_URL in defaultProjectListPromise URL in /ui
We currently always fetch the project list from the root path by default, even if the UI is served from a non-root path via PUBLIC_URL. It seems reasonable to assume that the project list would be served from the same path as the UI by default, so change the default project list URL to include the basename from PUBLIC_URL. This way you don't need to specify a custom `projectListPromise` for this base case, as shown by the changes in ui/src/index.tsx. BREAKING CHANGE: The PUBLIC_URL environment variable is now taken into account by default when fetching the projects list. This is a breaking change only if all these points apply: 1. You're using Feast UI as a module 2. You're serving the UI files from a non-root path via the PUBLIC_URL environment variable 3. You're serving the project list from the root path 4. You're not passing the `feastUIConfigs.projectListPromise` prop to the FeastUI component In this case, you need to explicitly fetch the project list from the root path via the `feastUIConfigs.projectListPromise` prop: ```diff const root = createRoot(document.getElementById("root")!); root.render( <React.StrictMode> - <FeastUI /> + <FeastUI + feastUIConfigs={{ + projectListPromise: fetch("/projects-list.json", { + headers: { + "Content-Type": "application/json", + }, + }).then((res) => res.json()) + }} + /> </React.StrictMode> ); ``` Signed-off-by: Harri Lehtola <[email protected]>
1 parent 2ac4906 commit 2f0f7b3

File tree

5 files changed

+9
-16
lines changed

5 files changed

+9
-16
lines changed

docs/reference/alpha-web-ui.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ The advantage of importing Feast UI as a module is in the ease of customization.
102102

103103
##### Fetching the Project List
104104

105-
You can use `projectListPromise` to provide a promise that overrides where the Feast UI fetches the project list from.
105+
By default, the Feast UI fetches the project list from the app root path. You can use `projectListPromise` to provide a promise that overrides where it's fetched from.
106106

107107
```jsx
108108
<FeastUI

ui/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ The advantage of importing Feast UI as a module is in the ease of customization.
7777

7878
##### Fetching the Project List
7979

80-
You can use `projectListPromise` to provide a promise that overrides where the Feast UI fetches the project list from.
80+
By default, the Feast UI fetches the project list from the app root path. You can use `projectListPromise` to provide a promise that overrides where it's fetched from.
8181

8282
```jsx
8383
<FeastUI

ui/src/FeastUI.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const FeastUI = ({ reactQueryClient, feastUIConfigs }: FeastUIProps) => {
2525
>
2626
<QueryClientProvider client={queryClient}>
2727
<QueryParamProvider adapter={ReactRouter6Adapter}>
28-
<FeastUISansProviders feastUIConfigs={feastUIConfigs} />
28+
<FeastUISansProviders basename={basename} feastUIConfigs={feastUIConfigs} />
2929
</QueryParamProvider>
3030
</QueryClientProvider>
3131
</BrowserRouter>

ui/src/FeastUISansProviders.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ interface FeastUIConfigs {
4040
projectListPromise?: Promise<any>;
4141
}
4242

43-
const defaultProjectListPromise = () => {
44-
return fetch("/projects-list.json", {
43+
const defaultProjectListPromise = (basename: string) => {
44+
return fetch(`${basename}/projects-list.json`, {
4545
headers: {
4646
"Content-Type": "application/json",
4747
},
@@ -51,8 +51,10 @@ const defaultProjectListPromise = () => {
5151
};
5252

5353
const FeastUISansProviders = ({
54+
basename = "",
5455
feastUIConfigs,
5556
}: {
57+
basename?: string;
5658
feastUIConfigs?: FeastUIConfigs;
5759
}) => {
5860
const projectListContext: ProjectsListContextInterface =
@@ -61,7 +63,7 @@ const FeastUISansProviders = ({
6163
projectsListPromise: feastUIConfigs?.projectListPromise,
6264
isCustom: true,
6365
}
64-
: { projectsListPromise: defaultProjectListPromise(), isCustom: false };
66+
: { projectsListPromise: defaultProjectListPromise(basename), isCustom: false };
6567

6668
return (
6769
<EuiProvider colorMode="light">

ui/src/index.tsx

+1-10
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,7 @@ root.render(
9696
<React.StrictMode>
9797
<FeastUI
9898
reactQueryClient={queryClient}
99-
feastUIConfigs={{
100-
tabsRegistry: tabsRegistry,
101-
projectListPromise: fetch((process.env.PUBLIC_URL || "") + "/projects-list.json", {
102-
headers: {
103-
"Content-Type": "application/json",
104-
},
105-
}).then((res) => {
106-
return res.json();
107-
})
108-
}}
99+
feastUIConfigs={{ tabsRegistry }}
109100
/>
110101
</React.StrictMode>
111102
);

0 commit comments

Comments
 (0)