Update SdkConfig usage to use new translation layer + update config.md docs (#21429)

* Update SdkConfig usage to use new translation layer

* Appease the linter

* WIP refactor of config documentation

* Finish re-writing config.md

* Update surrounding documentation

* Apply suggestions from code review

Co-authored-by: Germain <germains@element.io>

* Textual updates

Co-authored-by: Germain <germains@element.io>
This commit is contained in:
Travis Ralston 2022-03-18 10:12:44 -06:00 committed by GitHub
parent 071a5410b8
commit 1384783a77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 526 additions and 249 deletions

View file

@ -20,17 +20,13 @@ import SdkConfig from 'matrix-react-sdk/src/SdkConfig';
import { _t } from 'matrix-react-sdk/src/languageHandler';
const VectorAuthFooter = () => {
const brandingConfig = SdkConfig.get().branding;
let links = [
const brandingConfig = SdkConfig.getObject("branding");
const links = brandingConfig?.get("auth_footer_links") ?? [
{ "text": "Blog", "url": "https://element.io/blog" },
{ "text": "Twitter", "url": "https://twitter.com/element_hq" },
{ "text": "GitHub", "url": "https://github.com/vector-im/element-web" },
];
if (brandingConfig && brandingConfig.authFooterLinks) {
links = brandingConfig.authFooterLinks;
}
const authFooterLinks = [];
for (const linkEntry of links) {
authFooterLinks.push(

View file

@ -22,11 +22,8 @@ export default class VectorAuthHeaderLogo extends React.PureComponent {
static replaces = 'AuthHeaderLogo';
render() {
const brandingConfig = SdkConfig.get().branding;
let logoUrl = "themes/element/img/logos/element-logo.svg";
if (brandingConfig && brandingConfig.authHeaderLogoUrl) {
logoUrl = brandingConfig.authHeaderLogoUrl;
}
const brandingConfig = SdkConfig.getObject("branding");
const logoUrl = brandingConfig?.get("auth_header_logo_url") ?? "themes/element/img/logos/element-logo.svg";
return (
<div className="mx_AuthHeaderLogo">

View file

@ -27,14 +27,16 @@ export default class VectorAuthPage extends React.PureComponent {
static getWelcomeBackgroundUrl() {
if (VectorAuthPage.welcomeBackgroundUrl) return VectorAuthPage.welcomeBackgroundUrl;
const brandingConfig = SdkConfig.get().branding;
const brandingConfig = SdkConfig.getObject("branding");
VectorAuthPage.welcomeBackgroundUrl = "themes/element/img/backgrounds/lake.jpg";
if (brandingConfig && brandingConfig.welcomeBackgroundUrl) {
if (Array.isArray(brandingConfig.welcomeBackgroundUrl)) {
const index = Math.floor(Math.random() * brandingConfig.welcomeBackgroundUrl.length);
VectorAuthPage.welcomeBackgroundUrl = brandingConfig.welcomeBackgroundUrl[index];
const configuredUrl = brandingConfig?.get("welcome_background_url");
if (configuredUrl) {
if (Array.isArray(configuredUrl)) {
const index = Math.floor(Math.random() * configuredUrl.length);
VectorAuthPage.welcomeBackgroundUrl = configuredUrl[index];
} else {
VectorAuthPage.welcomeBackgroundUrl = brandingConfig.welcomeBackgroundUrl;
VectorAuthPage.welcomeBackgroundUrl = configuredUrl;
}
}