Skip to content

Commit

Permalink
Pass in external urls to nav from env
Browse files Browse the repository at this point in the history
  • Loading branch information
czmj committed Sep 5, 2022
1 parent e08c00a commit 5503ab9
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 8 deletions.
7 changes: 6 additions & 1 deletion .env.example.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"hpcAuthUrl": "http://api.hid.vm",
"hpcAuthClientId": "cdm-local",
"hpcApiUrl": "http://service.hpc.vm"
"hpcApiUrl": "http://service.hpc.vm",
"ftsAdminBaseUrl": "http://fts.hpc.vm",
"rpmBaseUrl": "http://rpm.hpc.vm",
"prismBaseUrl": "http://props.hpc.vm/",
"ftsWebsiteBaseUrl": "https://demo.fts-unocha-org.ahconu.org/",
"helpUrl": "https://docs.google.com/document/d/1rA-juc8eKMgXQm28ygF-SajimVh4JV5041WTSgHlGfw/edit#"
}
37 changes: 37 additions & 0 deletions apps/hpc-ftsadmin/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,43 @@ export const App = () => {
},
]}
className={CLASSES.CONTAINER.FLUID}
externalLinks={[
...(env.externalUrls?.rpmBaseUrl
? [
{
label: t.t(lang, (s) => s.navigation.rpm),
url: env.externalUrls.rpmBaseUrl,
},
]
: []),
...(env.externalUrls?.prismBaseUrl
? [
{
label: t.t(lang, (s) => s.navigation.prism),
url: env.externalUrls.prismBaseUrl,
},
]
: []),
...(env.externalUrls?.ftsWebsiteBaseUrl
? [
{
label: t.t(
lang,
(s) => s.navigation.ftsWebsite
),
url: env.externalUrls.ftsWebsiteBaseUrl,
},
]
: []),
...(env.externalUrls?.helpUrl
? [
{
label: t.t(lang, (s) => s.navigation.help),
url: env.externalUrls.helpUrl,
},
]
: []),
]}
/>
<Switch>
<Route path={paths.home()} exact>
Expand Down
9 changes: 9 additions & 0 deletions apps/hpc-ftsadmin/src/environments/config-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ export const initializeLiveEnvironment = async (config: config.Config) => {
return t.t(lang, (s) => s.common.devEnvironmentWarnings.dev);
}
},
get externalUrls() {
return {
ftsAdminBaseUrl: config.ftsAdminBaseUrl,
rpmBaseUrl: config.rpmBaseUrl,
prismBaseUrl: config.prismBaseUrl,
ftsWebsiteBaseUrl: config.ftsWebsiteBaseUrl,
helpUrl: config.helpUrl,
};
},
get model() {
return live.model;
},
Expand Down
7 changes: 7 additions & 0 deletions apps/hpc-ftsadmin/src/environments/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ export interface Environment {
* the environment, to avoid users accidentally using a non-prod env
*/
getDevHeaderWarning: (lang: LanguageKey) => string | undefined;
externalUrls?: {
ftsAdminBaseUrl: string | undefined;
rpmBaseUrl: string | undefined;
prismBaseUrl: string | undefined;
ftsWebsiteBaseUrl: string | undefined;
helpUrl: string | undefined;
};
session: Session;
model: Model;
}
7 changes: 6 additions & 1 deletion apps/hpc-ftsadmin/src/i18n/langs/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@
}
},
"navigation": {
"flows": "Search Funding Flows"
"flows": "Flows",
"pendingFlows": "Pending Flows",
"rpm": "Response Planning Module",
"prism": "Online Projects System",
"ftsWebsite": "FTS Website",
"help": "Help"
},
"routes": {
"operations": {
Expand Down
7 changes: 6 additions & 1 deletion apps/hpc-ftsadmin/src/i18n/langs/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@
}
},
"navigation": {
"flows": "Rechercher des flux de financement"
"flows": "Flux",
"pendingFlows": "Flux en attente",
"rpm": "Module de planification des interventions",
"prism": "Système de projets en ligne",
"ftsWebsite": "Site web FTS",
"help": "Aide"
},
"routes": {
"operations": {
Expand Down
20 changes: 15 additions & 5 deletions libs/hpc-core/src/lib/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import * as t from 'io-ts';

export const CONFIG = t.type({
hpcAuthUrl: t.string,
hpcAuthClientId: t.string,
hpcApiUrl: t.string,
});
export const CONFIG = t.intersection([
t.type({
hpcAuthUrl: t.string,
hpcAuthClientId: t.string,
hpcApiUrl: t.string,
}),
// These are optional so that no changes are required to CDM for now
t.partial({
ftsAdminBaseUrl: t.string,
rpmBaseUrl: t.string,
prismBaseUrl: t.string,
ftsWebsiteBaseUrl: t.string,
helpUrl: t.string,
}),
]);

export type Config = t.TypeOf<typeof CONFIG>;

Expand Down

0 comments on commit 5503ab9

Please sign in to comment.