Disable "Publish this room" option in invite only rooms (#7441)
This commit is contained in:
parent
fdd0a2ada3
commit
c03cb67aef
2 changed files with 30 additions and 21 deletions
|
@ -68,9 +68,12 @@ export default class RoomPublishSetting extends React.PureComponent<IProps, ISta
|
||||||
render() {
|
render() {
|
||||||
const client = MatrixClientPeg.get();
|
const client = MatrixClientPeg.get();
|
||||||
|
|
||||||
|
const room = client.getRoom(this.props.roomId);
|
||||||
|
const isRoomPublishable = room.getJoinRule() !== "invite";
|
||||||
|
|
||||||
const enabled = (
|
const enabled = (
|
||||||
DirectoryCustomisations.requireCanonicalAliasAccessToPublish?.() === false ||
|
(DirectoryCustomisations.requireCanonicalAliasAccessToPublish?.() === false ||
|
||||||
this.props.canSetCanonicalAlias
|
this.props.canSetCanonicalAlias) && (isRoomPublishable || this.state.isRoomPublished)
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -48,6 +48,7 @@ export async function checkSettingsToggle(session: ElementSession,
|
||||||
|
|
||||||
interface Tabs {
|
interface Tabs {
|
||||||
securityTabButton: ElementHandle;
|
securityTabButton: ElementHandle;
|
||||||
|
generalTabButton: ElementHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function findTabs(session: ElementSession): Promise<Tabs> {
|
async function findTabs(session: ElementSession): Promise<Tabs> {
|
||||||
|
@ -64,8 +65,9 @@ async function findTabs(session: ElementSession): Promise<Tabs> {
|
||||||
const tabButtons = await session.queryAll(".mx_RoomSettingsDialog .mx_TabbedView_tabLabel");
|
const tabButtons = await session.queryAll(".mx_RoomSettingsDialog .mx_TabbedView_tabLabel");
|
||||||
const tabLabels = await Promise.all(tabButtons.map(t => session.innerText(t)));
|
const tabLabels = await Promise.all(tabButtons.map(t => session.innerText(t)));
|
||||||
const securityTabButton = tabButtons[tabLabels.findIndex(l => l.toLowerCase().includes("security"))];
|
const securityTabButton = tabButtons[tabLabels.findIndex(l => l.toLowerCase().includes("security"))];
|
||||||
|
const generalTabButton = tabButtons[tabLabels.findIndex(l => l.toLowerCase().includes("general"))];
|
||||||
|
|
||||||
return { securityTabButton };
|
return { securityTabButton, generalTabButton };
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Settings {
|
interface Settings {
|
||||||
|
@ -140,24 +142,7 @@ export async function checkRoomSettings(session: ElementSession, expectedSetting
|
||||||
export async function changeRoomSettings(session, settings) {
|
export async function changeRoomSettings(session, settings) {
|
||||||
session.log.startGroup(`changes the room settings`);
|
session.log.startGroup(`changes the room settings`);
|
||||||
|
|
||||||
const { securityTabButton } = await findTabs(session);
|
const { securityTabButton, generalTabButton } = await findTabs(session);
|
||||||
const generalSwitches = await session.queryAll(".mx_RoomSettingsDialog .mx_ToggleSwitch");
|
|
||||||
const isDirectory = generalSwitches[0];
|
|
||||||
|
|
||||||
if (typeof settings.directory === "boolean") {
|
|
||||||
session.log.step(`sets directory listing to ${settings.directory}`);
|
|
||||||
await setSettingsToggle(session, isDirectory, settings.directory);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (settings.alias) {
|
|
||||||
session.log.step(`sets alias to ${settings.alias}`);
|
|
||||||
const aliasField = await session.query(".mx_RoomSettingsDialog .mx_AliasSettings details input[type=text]");
|
|
||||||
await session.replaceInputText(aliasField, settings.alias.substring(1, settings.alias.lastIndexOf(":")));
|
|
||||||
const addButton = await session.query(".mx_RoomSettingsDialog .mx_AliasSettings details .mx_AccessibleButton");
|
|
||||||
await addButton.click();
|
|
||||||
await session.delay(10); // delay to give time for the validator to run and check the alias
|
|
||||||
session.log.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
securityTabButton.click();
|
securityTabButton.click();
|
||||||
await session.delay(500);
|
await session.delay(500);
|
||||||
|
@ -186,6 +171,27 @@ export async function changeRoomSettings(session, settings) {
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`unrecognized room visibility setting: ${settings.visibility}`);
|
throw new Error(`unrecognized room visibility setting: ${settings.visibility}`);
|
||||||
}
|
}
|
||||||
|
await session.delay(100);
|
||||||
|
session.log.done();
|
||||||
|
}
|
||||||
|
|
||||||
|
generalTabButton.click();
|
||||||
|
await session.delay(500);
|
||||||
|
const generalSwitches = await session.queryAll(".mx_RoomSettingsDialog .mx_ToggleSwitch");
|
||||||
|
const isDirectory = generalSwitches[0];
|
||||||
|
|
||||||
|
if (typeof settings.directory === "boolean") {
|
||||||
|
session.log.step(`sets directory listing to ${settings.directory}`);
|
||||||
|
await setSettingsToggle(session, isDirectory, settings.directory);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.alias) {
|
||||||
|
session.log.step(`sets alias to ${settings.alias}`);
|
||||||
|
const aliasField = await session.query(".mx_RoomSettingsDialog .mx_AliasSettings details input[type=text]");
|
||||||
|
await session.replaceInputText(aliasField, settings.alias.substring(1, settings.alias.lastIndexOf(":")));
|
||||||
|
const addButton = await session.query(".mx_RoomSettingsDialog .mx_AliasSettings details .mx_AccessibleButton");
|
||||||
|
await addButton.click();
|
||||||
|
await session.delay(10); // delay to give time for the validator to run and check the alias
|
||||||
session.log.done();
|
session.log.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue