Add directory publish customisation point

This will help certain environments, such as P2P, where directory publishing can
be allowed freely.
This commit is contained in:
J. Ryan Stinnett 2021-07-09 17:51:18 +01:00
parent 8177dbfb56
commit ff7f3f47be
2 changed files with 38 additions and 1 deletions

View file

@ -20,6 +20,7 @@ import LabelledToggleSwitch from "../elements/LabelledToggleSwitch";
import { _t } from "../../../languageHandler";
import { MatrixClientPeg } from "../../../MatrixClientPeg";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import DirectoryCustomisations from '../../../customisations/Directory';
interface IProps {
roomId: string;
@ -66,10 +67,15 @@ export default class RoomPublishSetting extends React.PureComponent<IProps, ISta
render() {
const client = MatrixClientPeg.get();
const enabled = (
DirectoryCustomisations.requireCanonicalAliasAccessToPublish?.() === false ||
this.props.canSetCanonicalAlias
);
return (
<LabelledToggleSwitch value={this.state.isRoomPublished}
onChange={this.onRoomPublishChange}
disabled={!this.props.canSetCanonicalAlias}
disabled={!enabled}
label={_t("Publish this room to the public in %(domain)s's room directory?", {
domain: client.getDomain(),
})}