Skip to content

Commit 18ede88

Browse files
kchawlani19ntkathole
authored andcommitted
Make feature server URL configurable in UI
Signed-off-by: kchawlani19 <kchawlan@redhat.com>
1 parent eeaa6db commit 18ede88

2 files changed

Lines changed: 23 additions & 8 deletions

File tree

docs/reference/alpha-web-ui.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ Options:
3535

3636
This will spin up a Web UI on localhost which automatically refreshes its view of the registry every `registry_ttl_sec`
3737

38+
#### Curl Generator Feature Server URL
39+
40+
The Curl Generator uses a default Feature Server URL when building the example curl command. You can configure
41+
this default at build time using:
42+
43+
```bash
44+
REACT_APP_FEAST_FEATURE_SERVER_URL="http://your-server:6566"
45+
```
46+
47+
If this environment variable is not set, the UI falls back to `http://localhost:6566`. A user-edited value in
48+
the UI is still stored in localStorage and will take precedence for that browser.
49+
3850
### Importing as a module to integrate with an existing React App
3951

4052
This is the recommended way to use Feast UI for teams maintaining their own internal UI for their deployment of Feast.

ui/src/pages/feature-views/CurlGeneratorTab.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect } from "react";
1+
import React, { useState } from "react";
22
import {
33
EuiPanel,
44
EuiTitle,
@@ -16,23 +16,22 @@ import {
1616
import { CodeBlock, github } from "react-code-blocks";
1717
import { RegularFeatureViewCustomTabProps } from "../../custom-tabs/types";
1818

19+
const defaultServerUrl =
20+
process.env.REACT_APP_FEAST_FEATURE_SERVER_URL || "http://localhost:6566";
21+
1922
const CurlGeneratorTab = ({
2023
feastObjectQuery,
2124
}: RegularFeatureViewCustomTabProps) => {
2225
const data = feastObjectQuery.data as any;
2326
const [serverUrl, setServerUrl] = useState(() => {
2427
const savedUrl = localStorage.getItem("feast-feature-server-url");
25-
return savedUrl || "http://localhost:6566";
28+
return savedUrl || defaultServerUrl;
2629
});
2730
const [entityValues, setEntityValues] = useState<Record<string, string>>({});
2831
const [selectedFeatures, setSelectedFeatures] = useState<
2932
Record<string, boolean>
3033
>({});
3134

32-
useEffect(() => {
33-
localStorage.setItem("feast-feature-server-url", serverUrl);
34-
}, [serverUrl]);
35-
3635
if (feastObjectQuery.isLoading) {
3736
return <EuiText>Loading...</EuiText>;
3837
}
@@ -106,8 +105,12 @@ const CurlGeneratorTab = ({
106105
<EuiFormRow label="Feature Server URL">
107106
<EuiFieldText
108107
value={serverUrl}
109-
onChange={(e) => setServerUrl(e.target.value)}
110-
placeholder="http://localhost:6566"
108+
onChange={(e) => {
109+
const nextValue = e.target.value;
110+
setServerUrl(nextValue);
111+
localStorage.setItem("feast-feature-server-url", nextValue);
112+
}}
113+
placeholder={defaultServerUrl}
111114
/>
112115
</EuiFormRow>
113116

0 commit comments

Comments
 (0)