Skip to content

Commit

Permalink
webui: adding PRETTY_NAME to use in title instead of anaconda generic…
Browse files Browse the repository at this point in the history
… title
  • Loading branch information
acruzgon committed Jun 12, 2023
1 parent c34a4fb commit 5b4d670
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
9 changes: 7 additions & 2 deletions ui/webui/src/components/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { StorageClient } from "../apis/storage.js";
import { PayloadsClient } from "../apis/payloads";

import { readBuildstamp, getIsFinal } from "../helpers/betanag.js";
import { readConf } from "../helpers/conf.js";
import { readConf, readPrettyName } from "../helpers/conf.js";

const _ = cockpit.gettext;

Expand All @@ -46,6 +46,7 @@ export const Application = () => {
const [notifications, setNotifications] = useState({});
const [isHelpExpanded, setIsHelpExpanded] = useState(false);
const [helpContent, setHelpContent] = useState("");
const [prettyName, setIsPrettyName] = useState("");

useEffect(() => {
cockpit.file("/run/anaconda/bus.address").watch(address => {
Expand All @@ -69,6 +70,10 @@ export const Application = () => {
buildstamp => setBeta(!getIsFinal(buildstamp)),
ex => console.error("Failed to parse anaconda buildstamp file")
);

readPrettyName().then(
setIsPrettyName,
);
}, []);

const onAddNotification = (notificationProps) => {
Expand All @@ -95,7 +100,7 @@ export const Application = () => {
}
console.info("conf: ", conf);

const title = _("Anaconda installer");
const title = _(prettyName) + _(" installation");

const page = (
<Page
Expand Down
13 changes: 11 additions & 2 deletions ui/webui/src/components/localization/InstallationLanguage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with This program; If not, see <http://www.gnu.org/licenses/>.
*/

import React from "react";
import React, { useEffect, useState } from "react";
import cockpit from "cockpit";

import {
Expand Down Expand Up @@ -56,6 +56,8 @@ import { AnacondaPage } from "../AnacondaPage.jsx";

import "./InstallationLanguage.scss";

import { readPrettyName } from "../../helpers/conf.js";

const _ = cockpit.gettext;

const getLanguageEnglishName = lang => lang["english-name"].v;
Expand Down Expand Up @@ -317,9 +319,16 @@ LanguageSelector.contextType = AddressContext;
export const InstallationLanguage = ({ idPrefix, setIsFormValid, onAddErrorNotification }) => {
const [nativeName, setNativeName] = React.useState(false);
const { setLanguage } = React.useContext(LanguageContext);
const [prettyName, setIsPrettyName] = useState("");

useEffect(() => {
readPrettyName().then(
setIsPrettyName,
);
}, []);

return (
<AnacondaPage title={_("Welcome to the Anaconda installer")}>
<AnacondaPage title={_("Welcome to ") + _(prettyName)}>
<Title
headingLevel="h3"
>
Expand Down
11 changes: 11 additions & 0 deletions ui/webui/src/helpers/conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,14 @@ export const readConf = () => {
.then(parseIni)
.finally(confFile.close);
};

export const readPrettyName = () => {
const confFile = cockpit?.file("/etc/os-release");
return (
confFile
.read()
.then((content) => content.split(/\r?\n/)?.find((item) => item?.includes("PRETTY_NAME"))
.split("=")[1].replace(/['"]+/g, ""))
.finally(confFile.close)
);
};

0 comments on commit 5b4d670

Please sign in to comment.