* Migrate credits translations to IDs * Discard changes to src/i18n/strings/da.json * Discard changes to src/i18n/strings/bg.json * Discard changes to src/i18n/strings/ar.json * Discard changes to src/i18n/strings/az.json * Discard changes to src/i18n/strings/be.json * Discard changes to src/i18n/strings/ca.json * Discard changes to src/i18n/strings/el.json * Discard changes to src/i18n/strings/en_US.json * Discard changes to src/i18n/strings/eo.json * Discard changes to src/i18n/strings/eo.json * Discard changes to src/i18n/strings/eu.json * Discard changes to src/i18n/strings/fa.json * Discard changes to src/i18n/strings/ga.json * Discard changes to src/i18n/strings/gl.json * Discard changes to src/i18n/strings/he.json * Discard changes to src/i18n/strings/hi.json * Discard changes to src/i18n/strings/hr.json * Discard changes to src/i18n/strings/is.json * Discard changes to src/i18n/strings/ja.json * Discard changes to src/i18n/strings/jbo.json * Discard changes to src/i18n/strings/kab.json * Discard changes to src/i18n/strings/ko.json * Discard changes to src/i18n/strings/lt.json * Discard changes to src/i18n/strings/zh_Hans.json * Discard changes to src/i18n/strings/tzm.json * Discard changes to src/i18n/strings/tr.json * Discard changes to src/i18n/strings/th.json * Discard changes to src/i18n/strings/te.json * Discard changes to src/i18n/strings/ta.json * Discard changes to src/i18n/strings/sr.json * Discard changes to src/i18n/strings/ru.json * Discard changes to src/i18n/strings/ro.json * Discard changes to src/i18n/strings/pt_BR.json * Discard changes to src/i18n/strings/pt.json * Discard changes to src/i18n/strings/oc.json * Discard changes to src/i18n/strings/nn.json * Discard changes to src/i18n/strings/nl.json * Discard changes to src/i18n/strings/nb_NO.json * Discard changes to src/i18n/strings/ml.json * Discard changes to src/i18n/strings/lv.json * Discard changes to src/i18n/strings/lo.json
378 lines
16 KiB
TypeScript
378 lines
16 KiB
TypeScript
/*
|
|
Copyright 2019 - 2023 The Matrix.org Foundation C.I.C.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
import React, { ReactNode } from "react";
|
|
import { logger } from "matrix-js-sdk/src/logger";
|
|
|
|
import AccessibleButton from "../../../elements/AccessibleButton";
|
|
import { _t, getCurrentLanguage } from "../../../../../languageHandler";
|
|
import SdkConfig from "../../../../../SdkConfig";
|
|
import createRoom from "../../../../../createRoom";
|
|
import Modal from "../../../../../Modal";
|
|
import PlatformPeg from "../../../../../PlatformPeg";
|
|
import UpdateCheckButton from "../../UpdateCheckButton";
|
|
import BugReportDialog from "../../../dialogs/BugReportDialog";
|
|
import CopyableText from "../../../elements/CopyableText";
|
|
import SettingsTab from "../SettingsTab";
|
|
import { SettingsSection } from "../../shared/SettingsSection";
|
|
import SettingsSubsection, { SettingsSubsectionText } from "../../shared/SettingsSubsection";
|
|
import ExternalLink from "../../../elements/ExternalLink";
|
|
import MatrixClientContext from "../../../../../contexts/MatrixClientContext";
|
|
|
|
interface IProps {
|
|
closeSettingsFn: () => void;
|
|
}
|
|
|
|
interface IState {
|
|
appVersion: string | null;
|
|
canUpdate: boolean;
|
|
}
|
|
|
|
export default class HelpUserSettingsTab extends React.Component<IProps, IState> {
|
|
public static contextType = MatrixClientContext;
|
|
public context!: React.ContextType<typeof MatrixClientContext>;
|
|
|
|
public constructor(props: IProps) {
|
|
super(props);
|
|
|
|
this.state = {
|
|
appVersion: null,
|
|
canUpdate: false,
|
|
};
|
|
}
|
|
|
|
public componentDidMount(): void {
|
|
PlatformPeg.get()
|
|
?.getAppVersion()
|
|
.then((ver) => this.setState({ appVersion: ver }))
|
|
.catch((e) => {
|
|
logger.error("Error getting vector version: ", e);
|
|
});
|
|
PlatformPeg.get()
|
|
?.canSelfUpdate()
|
|
.then((v) => this.setState({ canUpdate: v }))
|
|
.catch((e) => {
|
|
logger.error("Error getting self updatability: ", e);
|
|
});
|
|
}
|
|
|
|
private getVersionInfo(): { appVersion: string; olmVersion: string } {
|
|
const brand = SdkConfig.get().brand;
|
|
const appVersion = this.state.appVersion || "unknown";
|
|
const olmVersionTuple = this.context.olmVersion;
|
|
const olmVersion = olmVersionTuple
|
|
? `${olmVersionTuple[0]}.${olmVersionTuple[1]}.${olmVersionTuple[2]}`
|
|
: "<not-enabled>";
|
|
|
|
return {
|
|
appVersion: `${_t("%(brand)s version:", { brand })} ${appVersion}`,
|
|
olmVersion: `${_t("Olm version:")} ${olmVersion}`,
|
|
};
|
|
}
|
|
|
|
private onClearCacheAndReload = (): void => {
|
|
if (!PlatformPeg.get()) return;
|
|
|
|
// Dev note: please keep this log line, it's useful when troubleshooting a MatrixClient suddenly
|
|
// stopping in the middle of the logs.
|
|
logger.log("Clear cache & reload clicked");
|
|
this.context.stopClient();
|
|
this.context.store.deleteAllData().then(() => {
|
|
PlatformPeg.get()?.reload();
|
|
});
|
|
};
|
|
|
|
private onBugReport = (): void => {
|
|
Modal.createDialog(BugReportDialog, {});
|
|
};
|
|
|
|
private onStartBotChat = (): void => {
|
|
this.props.closeSettingsFn();
|
|
createRoom(this.context, {
|
|
dmUserId: SdkConfig.get("welcome_user_id"),
|
|
andView: true,
|
|
});
|
|
};
|
|
|
|
private renderLegal(): ReactNode {
|
|
const tocLinks = SdkConfig.get().terms_and_conditions_links;
|
|
if (!tocLinks) return null;
|
|
|
|
const legalLinks: JSX.Element[] = [];
|
|
for (const tocEntry of tocLinks) {
|
|
legalLinks.push(
|
|
<div key={tocEntry.url}>
|
|
<ExternalLink href={tocEntry.url}>{tocEntry.text}</ExternalLink>
|
|
</div>,
|
|
);
|
|
}
|
|
|
|
return (
|
|
<SettingsSubsection heading={_t("Legal")}>
|
|
<SettingsSubsectionText>{legalLinks}</SettingsSubsectionText>
|
|
</SettingsSubsection>
|
|
);
|
|
}
|
|
|
|
private renderCredits(): JSX.Element {
|
|
// Note: This is not translated because it is legal text.
|
|
// Also, is ugly but necessary.
|
|
return (
|
|
<SettingsSubsection heading={_t("Credits")}>
|
|
<SettingsSubsectionText>
|
|
<ul>
|
|
<li>
|
|
{_t(
|
|
"credits|default_cover_photo",
|
|
{},
|
|
{
|
|
photo: (sub) => (
|
|
<ExternalLink
|
|
href="themes/element/img/backgrounds/lake.jpg"
|
|
rel="noreferrer noopener"
|
|
target="_blank"
|
|
>
|
|
{sub}
|
|
</ExternalLink>
|
|
),
|
|
author: (sub) => (
|
|
<ExternalLink href="https://www.flickr.com/golan">{sub}</ExternalLink>
|
|
),
|
|
terms: (sub) => (
|
|
<ExternalLink
|
|
href="https://creativecommons.org/licenses/by-sa/4.0/"
|
|
rel="noreferrer noopener"
|
|
target="_blank"
|
|
>
|
|
{sub}
|
|
</ExternalLink>
|
|
),
|
|
},
|
|
)}
|
|
</li>
|
|
<li>
|
|
{_t(
|
|
"credits|twemoji_colr",
|
|
{},
|
|
{
|
|
colr: (sub) => (
|
|
<ExternalLink
|
|
href="https://github.com/matrix-org/twemoji-colr"
|
|
rel="noreferrer noopener"
|
|
target="_blank"
|
|
>
|
|
{sub}
|
|
</ExternalLink>
|
|
),
|
|
author: (sub) => <ExternalLink href="https://mozilla.org">{sub}</ExternalLink>,
|
|
terms: (sub) => (
|
|
<ExternalLink
|
|
href="https://www.apache.org/licenses/LICENSE-2.0"
|
|
rel="noreferrer noopener"
|
|
target="_blank"
|
|
>
|
|
{sub}
|
|
</ExternalLink>
|
|
),
|
|
},
|
|
)}
|
|
</li>
|
|
<li>
|
|
{_t(
|
|
"credits|twemoji",
|
|
{},
|
|
{
|
|
twemoji: (sub) => (
|
|
<ExternalLink href="https://twemoji.twitter.com/">{sub}</ExternalLink>
|
|
),
|
|
author: (sub) => (
|
|
<ExternalLink href="https://twemoji.twitter.com/">{sub}</ExternalLink>
|
|
),
|
|
terms: (sub) => (
|
|
<ExternalLink
|
|
href="https://creativecommons.org/licenses/by/4.0/"
|
|
rel="noreferrer noopener"
|
|
target="_blank"
|
|
>
|
|
{sub}
|
|
</ExternalLink>
|
|
),
|
|
},
|
|
)}
|
|
</li>
|
|
</ul>
|
|
</SettingsSubsectionText>
|
|
</SettingsSubsection>
|
|
);
|
|
}
|
|
|
|
private getVersionTextToCopy = (): string => {
|
|
const { appVersion, olmVersion } = this.getVersionInfo();
|
|
return `${appVersion}\n${olmVersion}`;
|
|
};
|
|
|
|
public render(): React.ReactNode {
|
|
const brand = SdkConfig.get().brand;
|
|
|
|
let faqText = _t(
|
|
"For help with using %(brand)s, click <a>here</a>.",
|
|
{
|
|
brand,
|
|
},
|
|
{
|
|
a: (sub) => <ExternalLink href={SdkConfig.get("help_url")}>{sub}</ExternalLink>,
|
|
},
|
|
);
|
|
if (SdkConfig.get("welcome_user_id") && getCurrentLanguage().startsWith("en")) {
|
|
faqText = (
|
|
<div>
|
|
{_t(
|
|
"For help with using %(brand)s, click <a>here</a> or start a chat with our bot using the button below.",
|
|
{
|
|
brand,
|
|
},
|
|
{
|
|
a: (sub) => (
|
|
<ExternalLink
|
|
href={SdkConfig.get("help_url")}
|
|
rel="noreferrer noopener"
|
|
target="_blank"
|
|
>
|
|
{sub}
|
|
</ExternalLink>
|
|
),
|
|
},
|
|
)}
|
|
<div>
|
|
<AccessibleButton onClick={this.onStartBotChat} kind="primary">
|
|
{_t("Chat with %(brand)s Bot", { brand })}
|
|
</AccessibleButton>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
let updateButton: JSX.Element | undefined;
|
|
if (this.state.canUpdate) {
|
|
updateButton = <UpdateCheckButton />;
|
|
}
|
|
|
|
let bugReportingSection;
|
|
if (SdkConfig.get().bug_report_endpoint_url) {
|
|
bugReportingSection = (
|
|
<SettingsSubsection
|
|
heading={_t("Bug reporting")}
|
|
description={
|
|
<>
|
|
<SettingsSubsectionText>
|
|
{_t(
|
|
"If you've submitted a bug via GitHub, debug logs can help us track down the problem. ",
|
|
)}
|
|
</SettingsSubsectionText>
|
|
{_t(
|
|
"Debug logs contain application usage data including your username, the IDs or aliases of the rooms you have visited, which UI elements you last interacted with, and the usernames of other users. They do not contain messages.",
|
|
)}
|
|
</>
|
|
}
|
|
>
|
|
<AccessibleButton onClick={this.onBugReport} kind="primary">
|
|
{_t("Submit debug logs")}
|
|
</AccessibleButton>
|
|
<SettingsSubsectionText>
|
|
{_t(
|
|
"To report a Matrix-related security issue, please read the Matrix.org <a>Security Disclosure Policy</a>.",
|
|
{},
|
|
{
|
|
a: (sub) => (
|
|
<ExternalLink href="https://matrix.org/security-disclosure-policy/">
|
|
{sub}
|
|
</ExternalLink>
|
|
),
|
|
},
|
|
)}
|
|
</SettingsSubsectionText>
|
|
</SettingsSubsection>
|
|
);
|
|
}
|
|
|
|
const { appVersion, olmVersion } = this.getVersionInfo();
|
|
|
|
return (
|
|
<SettingsTab>
|
|
<SettingsSection heading={_t("Help & About")}>
|
|
{bugReportingSection}
|
|
<SettingsSubsection heading={_t("FAQ")} description={faqText} />
|
|
<SettingsSubsection heading={_t("Versions")}>
|
|
<SettingsSubsectionText>
|
|
<CopyableText getTextToCopy={this.getVersionTextToCopy}>
|
|
{appVersion}
|
|
<br />
|
|
{olmVersion}
|
|
<br />
|
|
</CopyableText>
|
|
{updateButton}
|
|
</SettingsSubsectionText>
|
|
</SettingsSubsection>
|
|
{this.renderLegal()}
|
|
{this.renderCredits()}
|
|
<SettingsSubsection heading={_t("Advanced")}>
|
|
<SettingsSubsectionText>
|
|
{_t(
|
|
"Homeserver is <code>%(homeserverUrl)s</code>",
|
|
{
|
|
homeserverUrl: this.context.getHomeserverUrl(),
|
|
},
|
|
{
|
|
code: (sub) => <code>{sub}</code>,
|
|
},
|
|
)}
|
|
</SettingsSubsectionText>
|
|
{this.context.getIdentityServerUrl() && (
|
|
<SettingsSubsectionText>
|
|
{_t(
|
|
"Identity server is <code>%(identityServerUrl)s</code>",
|
|
{
|
|
identityServerUrl: this.context.getIdentityServerUrl(),
|
|
},
|
|
{
|
|
code: (sub) => <code>{sub}</code>,
|
|
},
|
|
)}
|
|
</SettingsSubsectionText>
|
|
)}
|
|
<SettingsSubsectionText>
|
|
<details>
|
|
<summary>{_t("Access Token")}</summary>
|
|
<b>
|
|
{_t(
|
|
"Your access token gives full access to your account. Do not share it with anyone.",
|
|
)}
|
|
</b>
|
|
<CopyableText getTextToCopy={() => this.context.getAccessToken()}>
|
|
{this.context.getAccessToken()}
|
|
</CopyableText>
|
|
</details>
|
|
</SettingsSubsectionText>
|
|
<AccessibleButton onClick={this.onClearCacheAndReload} kind="danger">
|
|
{_t("Clear cache and reload")}
|
|
</AccessibleButton>
|
|
</SettingsSubsection>
|
|
</SettingsSection>
|
|
</SettingsTab>
|
|
);
|
|
}
|
|
}
|