diff --git a/hyperglass/configuration/__init__.py b/hyperglass/configuration/__init__.py
index 8c537af..2137870 100644
--- a/hyperglass/configuration/__init__.py
+++ b/hyperglass/configuration/__init__.py
@@ -144,7 +144,7 @@ try:
elif not user_config:
params = _params.Params()
try:
- params.branding.text.subtitle = params.branding.text.subtitle.format(
+ params.web.text.subtitle = params.web.text.subtitle.format(
**params.dict(exclude={"branding", "features", "messages"})
)
except KeyError:
@@ -372,22 +372,20 @@ def _build_vrf_help():
content_vrf = _build_vrf_help()
content_help_params = copy.copy(content_params)
-content_help_params["title"] = params.branding.help_menu.title
+content_help_params["title"] = params.web.help_menu.title
content_help = asyncio.run(
get_markdown(
- config_path=params.branding.help_menu,
+ config_path=params.web.help_menu,
default=DEFAULT_HELP,
params=content_help_params,
)
)
content_terms_params = copy.copy(content_params)
-content_terms_params["title"] = params.branding.terms.title
+content_terms_params["title"] = params.web.terms.title
content_terms = asyncio.run(
get_markdown(
- config_path=params.branding.terms,
- default=DEFAULT_TERMS,
- params=content_terms_params,
+ config_path=params.web.terms, default=DEFAULT_TERMS, params=content_terms_params
)
)
content_credit = CREDIT
diff --git a/hyperglass/configuration/models/params.py b/hyperglass/configuration/models/params.py
index 4095a3d..4070198 100644
--- a/hyperglass/configuration/models/params.py
+++ b/hyperglass/configuration/models/params.py
@@ -18,16 +18,17 @@ from pydantic import validator
# Project Imports
from hyperglass.configuration.models._utils import HyperglassModel
-from hyperglass.configuration.models.branding import Branding
from hyperglass.configuration.models.docs import Docs
from hyperglass.configuration.models.features import Features
from hyperglass.configuration.models.messages import Messages
from hyperglass.configuration.models.opengraph import OpenGraph
+from hyperglass.configuration.models.web import Web
class Params(HyperglassModel):
"""Validation model for all configuration variables."""
+ # Top Level Params
debug: StrictBool = False
developer_mode: StrictBool = False
primary_asn: StrictStr = "65001"
@@ -50,8 +51,6 @@ class Params(HyperglassModel):
"network",
"isp",
]
- opengraph: OpenGraph = OpenGraph()
- docs: Docs = Docs()
google_analytics: StrictStr = ""
redis_host: StrictStr = "localhost"
redis_port: StrictInt = 6379
@@ -62,6 +61,13 @@ class Params(HyperglassModel):
log_file: Optional[FilePath]
cors_origins: List[StrictStr] = []
+ # Sub Level Params
+ docs: Docs = Docs()
+ features: Features = Features()
+ messages: Messages = Messages()
+ opengraph: OpenGraph = OpenGraph()
+ web: Web = Web()
+
@validator("listen_address", pre=True, always=True)
def validate_listen_address(cls, value, values):
"""Set default listen_address based on debug mode.
@@ -118,7 +124,3 @@ class Params(HyperglassModel):
f'/tmp/hyperglass_{now.strftime(r"%Y%M%d-%H%M%S")}.log' # noqa: S108
)
return value
-
- features: Features = Features()
- branding: Branding = Branding()
- messages: Messages = Messages()
diff --git a/hyperglass/configuration/models/branding.py b/hyperglass/configuration/models/web.py
similarity index 99%
rename from hyperglass/configuration/models/branding.py
rename to hyperglass/configuration/models/web.py
index 70b7e01..21b744b 100644
--- a/hyperglass/configuration/models/branding.py
+++ b/hyperglass/configuration/models/web.py
@@ -19,7 +19,7 @@ from pydantic.color import Color
from hyperglass.configuration.models._utils import HyperglassModel
-class Branding(HyperglassModel):
+class Web(HyperglassModel):
"""Validation model for params.branding."""
class Colors(HyperglassModel):
diff --git a/hyperglass/models/query.py b/hyperglass/models/query.py
index bd81a3a..ae4ec2e 100644
--- a/hyperglass/models/query.py
+++ b/hyperglass/models/query.py
@@ -48,7 +48,7 @@ class Query(BaseModel):
params.messages.invalid_field,
level="warning",
input=value,
- field=params.branding.text.query_location,
+ field=params.web.text.query_location,
)
return value
diff --git a/ui/components/Footer.js b/ui/components/Footer.js
index 3167a57..4e5397d 100644
--- a/ui/components/Footer.js
+++ b/ui/components/Footer.js
@@ -3,13 +3,15 @@ import { Flex, useColorMode, useTheme } from "@chakra-ui/core";
import { FiCode } from "react-icons/fi";
import { GoLinkExternal } from "react-icons/go";
import format from "string-format";
+import useConfig from "~/components/HyperglassProvider";
import FooterButton from "~/components/FooterButton";
import FooterContent from "~/components/FooterContent";
format.extend(String.prototype, {});
-export default ({ general, help, extLink, credit, terms, content }) => {
+const Footer = () => {
const theme = useTheme();
+ const config = useConfig();
const { colorMode } = useColorMode();
const footerBg = { light: theme.colors.blackAlpha[50], dark: theme.colors.whiteAlpha[100] };
const footerColor = { light: theme.colors.black, dark: theme.colors.white };
@@ -20,9 +22,9 @@ export default ({ general, help, extLink, credit, terms, content }) => {
const [helpVisible, showHelp] = useState(false);
const [termsVisible, showTerms] = useState(false);
const [creditVisible, showCredit] = useState(false);
- const extUrl = extLink.url.includes("{primary_asn}")
- ? extLink.url.format({ primary_asn: general.primary_asn })
- : extLink.url || "/";
+ const extUrl = config.external_link.url.includes("{primary_asn}")
+ ? config.external_link.url.format({ primary_asn: config.primary_asn })
+ : config.external_link.url || "/";
const handleCollapse = i => {
if (i === "help") {
showTerms(false);
@@ -40,31 +42,31 @@ export default ({ general, help, extLink, credit, terms, content }) => {
};
return (
<>
- {help.enable && (
+ {config.help.enable && (
)}
- {terms.enable && (
+ {config.terms.enable && (
)}
- {credit.enable && (
+ {config.credit.enable && (
{
color={footerColor[colorMode]}
justifyContent="space-between"
>
- {terms.enable && (
+ {config.terms.enable && (
handleCollapse("terms")}>
- {terms.title}
+ {config.terms.title}
)}
- {help.enable && (
+ {config.help.enable && (
handleCollapse("help")}>
- {help.title}
+ {config.help.title}
)}
{
marginRight="auto"
p={0}
/>
- {credit.enable && (
+ {config.credit.enable && (
handleCollapse("credit")}>
)}
- {extLink.enable && (
+ {config.external_link.enable && (
{
rightIcon={GoLinkExternal}
size="xs"
>
- {extLink.title}
+ {config.external_link.title}
)}
>
);
};
+
+Footer.displayName = "Footer";
+export default Footer;
diff --git a/ui/components/HyperglassForm.js b/ui/components/HyperglassForm.js
index fe562cf..3aa1827 100644
--- a/ui/components/HyperglassForm.js
+++ b/ui/components/HyperglassForm.js
@@ -21,16 +21,14 @@ const formSchema = config =>
query_location: yup
.array()
.of(yup.string())
- .required(
- config.messages.no_input.format({ field: config.branding.text.query_location })
- ),
+ .required(config.messages.no_input.format({ field: config.web.text.query_location })),
query_type: yup
.string()
- .required(config.messages.no_input.format({ field: config.branding.text.query_type })),
+ .required(config.messages.no_input.format({ field: config.web.text.query_type })),
query_vrf: yup.string(),
query_target: yup
.string()
- .required(config.messages.no_input.format({ field: config.branding.text.query_target }))
+ .required(config.messages.no_input.format({ field: config.web.text.query_target }))
});
const FormRow = ({ children, ...props }) => (
@@ -121,14 +119,14 @@ const HyperglassForm = React.forwardRef(