Skip to content

Commit a88e3c1

Browse files
author
Francesco Pagnamenta
committed
side bar link props externalized
1 parent dc7808f commit a88e3c1

File tree

4 files changed

+41
-11
lines changed

4 files changed

+41
-11
lines changed

app/configs/base.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const base = {
1919
companyName: getEnvVariable(env, 'COMPANY_NAME', false, 'CSCS'),
2020
serviceName: getEnvVariable(env, 'SERVICE_NAME', false, 'firecrest-web-ui'),
2121
supportUrl: getEnvVariable(env, 'SUPPORT_URL', false),
22+
repoUrl: getEnvVariable(env, 'REPO_URL', false),
23+
docUrl: getEnvVariable(env, 'DOC_URL', false),
2224
}
2325

2426
export default base

app/layouts/AppLayout.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,22 @@ interface AppLayoutProps {
2121
environment: string
2222
appVersion: string
2323
companyName: string
24-
supportUrl: string
2524
authUser: AuthUser
2625
notificationMessages: Array<NotificationMessage>
26+
supportUrl: string | null
27+
docUrl: string | null
28+
repoUrl: string | null
2729
}
2830

2931
const AppLayout: React.FC<AppLayoutProps> = ({
3032
environment,
3133
appVersion,
3234
companyName,
33-
supportUrl,
3435
authUser,
3536
notificationMessages,
37+
supportUrl,
38+
docUrl,
39+
repoUrl,
3640
}: AppLayoutProps) => {
3741
const [sidebarOpen, setSidebarOpen] = useState<boolean>(false)
3842
return (
@@ -45,6 +49,8 @@ const AppLayout: React.FC<AppLayoutProps> = ({
4549
sidebarOpen={sidebarOpen}
4650
setSidebarOpen={setSidebarOpen}
4751
supportUrl={supportUrl}
52+
docUrl={docUrl}
53+
repoUrl={repoUrl}
4854
/>
4955
<div className='md:pl-64 flex flex-col flex-1 min-h-screen'>
5056
<Header setSidebarOpen={setSidebarOpen} authUser={authUser} />

app/layouts/Sidebar.tsx

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,17 @@ interface SidebarProps {
3838
sidebarOpen: boolean
3939
setSidebarOpen: () => void
4040
supportUrl: string | null
41+
docUrl: string | null
42+
repoUrl: string | null
4143
}
4244

43-
const Sidebar: React.FC<any> = ({ sidebarOpen, setSidebarOpen, supportUrl = null }: any) => {
45+
const Sidebar: React.FC<any> = ({
46+
sidebarOpen,
47+
setSidebarOpen,
48+
supportUrl = null,
49+
docUrl = null,
50+
repoUrl = null,
51+
}: any) => {
4452
const location = useLocation()
4553

4654
const userNavigation = [{ name: 'Dashboard', path: '/', icon: HomeIcon }]
@@ -54,18 +62,28 @@ const Sidebar: React.FC<any> = ({ sidebarOpen, setSidebarOpen, supportUrl = null
5462
},
5563
]
5664

57-
const secondaryNavigation: any = [
58-
{ name: 'Documentation', url: 'https://products.cscs.ch/firecrest/', icon: DocumentTextIcon },
59-
{
65+
const secondaryNavigation: any = []
66+
67+
if (docUrl && docUrl !== '') {
68+
secondaryNavigation.push({
69+
name: 'Documentation',
70+
url: docUrl,
71+
icon: DocumentTextIcon,
72+
})
73+
}
74+
75+
if (repoUrl && repoUrl !== '') {
76+
secondaryNavigation.push({
6077
name: 'Github repo',
61-
url: 'https://github.com/eth-cscs/firecrest',
78+
url: repoUrl,
6279
icon: CubeTransparentIcon,
63-
},
64-
]
80+
})
81+
}
82+
6583
if (supportUrl && supportUrl !== '') {
6684
secondaryNavigation.push({
6785
name: 'Get support',
68-
url: 'https://support.cscs.ch',
86+
url: supportUrl,
6987
icon: ChatBubbleLeftEllipsisIcon,
7088
})
7189
}

app/routes/_app.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ export const loader: LoaderFunction = async ({ request }: LoaderFunctionArgs) =>
3737
appVersion: base.appVersion,
3838
companyName: base.companyName,
3939
supportUrl: base.supportUrl,
40+
repoUrl: base.repoUrl,
41+
docUrl: base.docUrl,
4042
authUser: auth.user,
4143
notificationMessages: notificationMessages,
4244
},
@@ -48,14 +50,16 @@ export const loader: LoaderFunction = async ({ request }: LoaderFunctionArgs) =>
4850

4951
export default function AppLayoutRoute() {
5052
const data = useLoaderData()
51-
const { appVersion, companyName, supportUrl, environment, authUser, notificationMessages }: any =
53+
const { appVersion, companyName, supportUrl, repoUrl, docUrl, environment, authUser, notificationMessages }: any =
5254
data
5355
return (
5456
<AppLayout
5557
environment={environment}
5658
appVersion={appVersion}
5759
companyName={companyName}
5860
supportUrl={supportUrl}
61+
repoUrl={repoUrl}
62+
docUrl={docUrl}
5963
authUser={authUser}
6064
notificationMessages={notificationMessages}
6165
/>

0 commit comments

Comments
 (0)