Skip to content

Commit 74d5459

Browse files
committed
Merge branch 'main' into feature/latest-models
2 parents af616ac + 13abd1d commit 74d5459

File tree

7 files changed

+45
-11
lines changed

7 files changed

+45
-11
lines changed

.env.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Provide frontend configuration settings from environment variables
2+
SHOW_KEYS_ENABLED=true

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2+
*env
23
*api-keys.env
34
**/*.ipynb_checkpoints/
4-
55
.DS_Store
66
build/
77
dist/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"ag-grid-enterprise": "^32.0.2",
1717
"ag-grid-react": "^32.0.2",
1818
"d3": "^7.3.0",
19-
"dompurify": "^3.1.7",
19+
"dompurify": "^3.2.4",
2020
"localforage": "^1.10.0",
2121
"lodash": "^4.17.21",
2222
"markdown-to-jsx": "^7.4.0",

py-src/data_formulator/app.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
# Load the single environment file
5454
load_dotenv(os.path.join(APP_ROOT, "..", "..", 'api-keys.env'))
5555
load_dotenv(os.path.join(APP_ROOT, 'api-keys.env'))
56+
load_dotenv(os.path.join(APP_ROOT, '.env'))
5657

5758
# Configure root logger for general application logging
5859
logging.basicConfig(
@@ -539,6 +540,13 @@ def request_code_expl():
539540
expl = ""
540541
return expl
541542

543+
@app.route('/app-config', methods=['GET'])
544+
def get_app_config():
545+
"""Provide frontend configuration settings from environment variables"""
546+
config = {
547+
"SHOW_KEYS_ENABLED": os.getenv("SHOW_KEYS_ENABLED", "true").lower() == "true"
548+
}
549+
return flask.jsonify(config)
542550

543551
def parse_args() -> argparse.Namespace:
544552
parser = argparse.ArgumentParser(description="Data Formulator")

src/app/utils.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ export function getUrls() {
4949
VEGA_DATASET_LIST: `${appConfig.serverUrl}/vega-datasets`,
5050
VEGA_DATASET_REQUEST_PREFIX: `${appConfig.serverUrl}/vega-dataset/`,
5151

52+
APP_CONFIG: `${appConfig.serverUrl}/app-config`,
53+
5254
AUTH_INFO_PREFIX: `${appConfig.serverUrl}/.auth/`
5355
};
5456
}

src/views/ModelSelectionDialog.tsx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ import HelpOutlineIcon from '@mui/icons-material/HelpOutline';
5454

5555
import { getUrls } from '../app/utils';
5656

57+
// Add interface for app configuration
58+
interface AppConfig {
59+
SHOW_KEYS_ENABLED: boolean;
60+
}
61+
5762
export const GroupHeader = styled('div')(({ theme }) => ({
5863
position: 'sticky',
5964
padding: '8px 8px',
@@ -84,6 +89,19 @@ export const ModelSelectionButton: React.FC<{}> = ({ }) => {
8489
'ollama': []
8590
});
8691
const [isLoadingModelOptions, setIsLoadingModelOptions] = useState<boolean>(false);
92+
const [appConfig, setAppConfig] = useState<AppConfig>({ SHOW_KEYS_ENABLED: true });
93+
94+
// Fetch app configuration
95+
useEffect(() => {
96+
fetch(getUrls().APP_CONFIG)
97+
.then(response => response.json())
98+
.then(data => {
99+
setAppConfig(data);
100+
})
101+
.catch(error => {
102+
console.error("Failed to fetch app configuration:", error);
103+
});
104+
}, []);
87105

88106
let updateModelStatus = (model: ModelConfig, status: 'ok' | 'error' | 'testing' | 'unknown', message: string) => {
89107
dispatch(dfActions.updateModelStatus({id: model.id, status, message}));
@@ -509,10 +527,12 @@ export const ModelSelectionButton: React.FC<{}> = ({ }) => {
509527
{modelTable}
510528
</DialogContent>
511529
<DialogActions>
512-
<Button sx={{marginRight: 'auto'}} endIcon={showKeys ? <VisibilityOffIcon /> : <VisibilityIcon />} onClick={()=>{
513-
setShowKeys(!showKeys);}}>
514-
{showKeys ? 'hide' : 'show'} keys
515-
</Button>
530+
{appConfig.SHOW_KEYS_ENABLED && (
531+
<Button sx={{marginRight: 'auto'}} endIcon={showKeys ? <VisibilityOffIcon /> : <VisibilityIcon />} onClick={()=>{
532+
setShowKeys(!showKeys);}}>
533+
{showKeys ? 'hide' : 'show'} keys
534+
</Button>
535+
)}
516536
<Button disabled={getStatus(tempSelectedModelId) !== 'ok'}
517537
variant={(selectedModelId == tempSelectedModelId) ? 'text' : 'contained'}
518538
onClick={()=>{

yarn.lock

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@
12001200
resolved "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.3.tgz#cef09e3ec9af1d63d2a6cc5b383a737e24e6dcf5"
12011201
integrity sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==
12021202

1203-
"@types/trusted-types@*":
1203+
"@types/trusted-types@*", "@types/trusted-types@^2.0.7":
12041204
version "2.0.7"
12051205
resolved "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz#baccb07a970b91707df3a3e8ba6896c57ead2d11"
12061206
integrity sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==
@@ -2150,10 +2150,12 @@ dom-helpers@^5.0.1:
21502150
"@babel/runtime" "^7.8.7"
21512151
csstype "^3.0.2"
21522152

2153-
dompurify@^3.1.7:
2154-
version "3.1.7"
2155-
resolved "https://registry.npmjs.org/dompurify/-/dompurify-3.1.7.tgz#711a8c96479fb6ced93453732c160c3c72418a6a"
2156-
integrity sha512-VaTstWtsneJY8xzy7DekmYWEOZcmzIe3Qb3zPd4STve1OBTa+e+WmS1ITQec1fZYXI3HCsOZZiSMpG6oxoWMWQ==
2153+
dompurify@^3.2.4:
2154+
version "3.2.4"
2155+
resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-3.2.4.tgz#af5a5a11407524431456cf18836c55d13441cd8e"
2156+
integrity sha512-ysFSFEDVduQpyhzAob/kkuJjf5zWkZD8/A9ywSp1byueyuCfHamrCBa14/Oc2iiB0e51B+NpxSl5gmzn+Ms/mg==
2157+
optionalDependencies:
2158+
"@types/trusted-types" "^2.0.7"
21572159

21582160
emoji-regex@^8.0.0:
21592161
version "8.0.0"

0 commit comments

Comments
 (0)