|
@@ -1,4 +1,4 @@
|
|
|
-import React, { useContext } from 'react';
|
|
|
+import React, { useContext, useState, useEffect } from 'react';
|
|
|
import Select from 'components/common/Select/Select';
|
|
|
import Logo from 'components/common/Logo/Logo';
|
|
|
import Version from 'components/Version/Version';
|
|
@@ -11,6 +11,7 @@ import { ThemeModeContext } from 'components/contexts/ThemeModeContext';
|
|
|
|
|
|
import UserInfo from './UserInfo/UserInfo';
|
|
|
import * as S from './NavBar.styled';
|
|
|
+import { preferencesClient as api } from 'lib/api';
|
|
|
|
|
|
interface Props {
|
|
|
onBurgerClick: () => void;
|
|
@@ -50,6 +51,31 @@ const options = [
|
|
|
|
|
|
const NavBar: React.FC<Props> = ({ onBurgerClick }) => {
|
|
|
const { themeMode, setThemeMode } = useContext(ThemeModeContext);
|
|
|
+ const [appName, setAppName] = useState<string>("");
|
|
|
+ const [showGitHubLink, setShowGitHubLink] = useState<boolean>(true);
|
|
|
+ const [showDiscordLink, setShowDiscordLink] = useState<boolean>(true);
|
|
|
+ const [showVersion, setShowVersion] = useState<boolean>(true);
|
|
|
+ const [logoBase64, setLogoBase64] = useState<string>("");
|
|
|
+
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ const fetchPreferences = async () => {
|
|
|
+ try {
|
|
|
+ const preferencesData = await api.getPreferences();
|
|
|
+ setAppName(preferencesData.appName);
|
|
|
+ setShowGitHubLink(preferencesData.removeGitLink);
|
|
|
+ setShowDiscordLink(preferencesData.removeDiscordLink);
|
|
|
+ setShowVersion(preferencesData.version);
|
|
|
+ if (preferencesData.logo) {
|
|
|
+ setLogoBase64(preferencesData.logo);
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('Error fetching preferences:', error);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ fetchPreferences();
|
|
|
+ }, []);
|
|
|
|
|
|
return (
|
|
|
<S.Navbar role="navigation" aria-label="Page Header">
|
|
@@ -68,13 +94,22 @@ const NavBar: React.FC<Props> = ({ onBurgerClick }) => {
|
|
|
</S.NavbarBurger>
|
|
|
|
|
|
<S.Hyperlink to="/">
|
|
|
- <Logo />
|
|
|
- UI for Apache Kafka
|
|
|
+ {logoBase64 ? (
|
|
|
+ <img src={logoBase64} alt="Logo" />
|
|
|
+ ) : (
|
|
|
+ <Logo />
|
|
|
+ )}
|
|
|
+ {appName ? (
|
|
|
+ <span>{appName}</span>
|
|
|
+ ) : (
|
|
|
+ "UI for Apache Kafka"
|
|
|
+ )}
|
|
|
</S.Hyperlink>
|
|
|
-
|
|
|
+ {showVersion && (
|
|
|
<S.NavbarItem>
|
|
|
<Version />
|
|
|
</S.NavbarItem>
|
|
|
+ )}
|
|
|
</S.NavbarBrand>
|
|
|
</S.NavbarBrand>
|
|
|
<S.NavbarSocial>
|
|
@@ -84,18 +119,22 @@ const NavBar: React.FC<Props> = ({ onBurgerClick }) => {
|
|
|
onChange={setThemeMode}
|
|
|
isThemeMode
|
|
|
/>
|
|
|
- <S.SocialLink
|
|
|
- href="https://github.com/provectus/kafka-ui"
|
|
|
- target="_blank"
|
|
|
- >
|
|
|
- <GitIcon />
|
|
|
- </S.SocialLink>
|
|
|
+ {showGitHubLink && (
|
|
|
+ <S.SocialLink
|
|
|
+ href="https://github.com/provectus/kafka-ui"
|
|
|
+ target="_blank"
|
|
|
+ >
|
|
|
+ <GitIcon />
|
|
|
+ </S.SocialLink>
|
|
|
+ )}
|
|
|
+ {showDiscordLink && (
|
|
|
<S.SocialLink
|
|
|
href="https://discord.com/invite/4DWzD7pGE5"
|
|
|
target="_blank"
|
|
|
>
|
|
|
<DiscordIcon />
|
|
|
</S.SocialLink>
|
|
|
+ )}
|
|
|
<UserInfo />
|
|
|
</S.NavbarSocial>
|
|
|
</S.Navbar>
|