Skip to content

Commit d41c02c

Browse files
committed
cleanups after reviewing PR
1 parent b23f0c1 commit d41c02c

File tree

9 files changed

+13
-20
lines changed

9 files changed

+13
-20
lines changed

.storybook/preview-head.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
<!-- Load runtime app config before stories so requireAppConfig() can initialize -->
21
<script src="/config.js"></script>
32
<script>
43
window.global = window
5-
// Note: /config.js sets window.__APP_CONFIG__ at runtime for Storybook too.
6-
// Our preview.tsx will validate it early via initAppConfig().
74
</script>

.storybook/preview.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ const preview: Preview = {
2323
},
2424
decorators: [
2525
(Story) => {
26-
// Validate runtime app config once when Storybook starts. This will read window.__APP_CONFIG__
27-
// that we inject via preview-head.html (/config.js) and cache it for requireAppConfig().
2826
const result = initAppConfig()
2927
if (!result.ok) {
3028
console.error('Storybook runtime config invalid/missing:', result.message)

cypress.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ export default defineConfig({
3838
codeCoverage: {
3939
exclude: ['tests/**/*.*', '**/ErrorPage.tsx']
4040
}
41-
},
41+
}
4242
})

public/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ window.__APP_CONFIG__ = {
1414
// All auth-related storage keys will be prefixed with this string
1515
localStorageKeyPrefix: 'DV_'
1616
},
17-
// UI languages available to users
17+
// UI languages available to users (if more than one is provided a language switcher will be shown)
1818
languages: [
1919
{ code: 'en', name: 'English' },
2020
{ code: 'es', name: 'Español' }

src/config.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ declare global {
88

99
let CONFIG: AppConfig | undefined
1010

11-
/**
12-
* This function initializes the application configuration by validating and loading it from the global window object.
13-
* There is a script tag in index.html that loads /config.js at runtime, which sets window.__APP_CONFIG__.
14-
* This helps changing configuration at runtime without rebuilding the application.
15-
* It returns an object indicating whether the initialization was successful or not, along with the configuration value or an error message.
16-
*/
17-
1811
const AppConfigSchema = z.object({
1912
backendUrl: z.url(),
2013
oidc: z.object({
@@ -39,6 +32,12 @@ export type AppConfigResult =
3932
| { ok: true; value: AppConfig }
4033
| { ok: false; message: string; schemaError?: string }
4134

35+
/**
36+
* This function initializes the application configuration by validating and loading it from the global window object.
37+
* There is a script tag in index.html that loads /config.js at runtime, which sets window.__APP_CONFIG__.
38+
* This helps changing configuration at runtime without rebuilding the application.
39+
* It returns an object indicating whether the initialization was successful or not, along with the configuration value or an error message.
40+
*/
4241
export function initAppConfig(): AppConfigResult {
4342
const raw = typeof window !== 'undefined' ? window.__APP_CONFIG__ : undefined
4443

src/i18n.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ i18next.on('languageChanged', (lng) => setHtmlLangAndDir(lng))
4444
* 2. Browser language (if supported)
4545
* 3. Default language from app config
4646
*/
47-
4847
function defineLanguage(): string {
4948
const storedLang = localStorage.getItem(LANGUAGE_LOCAL_STORAGE_KEY)
5049
const supportedLangs = appConfig.languages.map((l) => l.code.toLowerCase())
@@ -78,7 +77,7 @@ function setHtmlLangAndDir(lng: string | undefined) {
7877

7978
html.setAttribute('lang', baseLang)
8079

81-
// This could be the first step into supporting RTL languages, but there is still a lot to do in the UI.
80+
// This is the first step into supporting RTL languages, but there is still a lot to do in the UI.
8281
const rtlLangs = new Set(['ar', 'fa', 'he', 'iw', 'kd', 'pk', 'ps', 'ug', 'ur', 'yi'])
8382
html.setAttribute('dir', rtlLangs.has(baseLang) ? 'rtl' : 'ltr')
8483
}

src/sections/dataset/dataset-action-buttons/DatasetToolsOptions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const ToolOption = ({
8686
externalToolsRepository,
8787
persistentId,
8888
toolId,
89-
{ preview: false, locale: i18n.language }
89+
{ preview: false, locale: i18n.languages[0] }
9090
)
9191

9292
// Change the location of the new window to the tool URL

src/sections/file/file-action-buttons/access-file-menu/FileToolOptions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ const ToolOption = ({
110110
externalToolsRepository,
111111
fileId,
112112
toolId,
113-
{ preview: false, locale: i18n.language }
113+
{ preview: false, locale: i18n.languages[0] }
114114
)
115115
// Change the location of the new window to the tool URL
116116
newWindow.location.href = fileExternalTool.toolUrlResolved

src/sections/file/file-embedded-external-tool/FileEmbeddedExternalTool.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const FileEmbeddedExternalTool = ({
6161
externalToolsRepository,
6262
file.id,
6363
toolIdSelected,
64-
{ preview: true, locale: i18n.language }
64+
{ preview: true, locale: i18n.languages[0] }
6565
)
6666

6767
setFileExternalToolResolved(fileExternalTool)
@@ -78,7 +78,7 @@ export const FileEmbeddedExternalTool = ({
7878
}
7979

8080
void fetchFileExternalToolResolved()
81-
}, [isInView, toolIdSelected, externalToolsRepository, file.id, t, i18n.language])
81+
}, [isInView, toolIdSelected, externalToolsRepository, file.id, t, i18n.languages])
8282

8383
return (
8484
<section>

0 commit comments

Comments
 (0)