mirror of https://github.com/vector-im/riot-web
Improve permissions error when adding new server to room directory
parent
f74d4769ca
commit
b0f23aa65b
|
@ -49,6 +49,18 @@ const inPlaceOf = (elementRect) => ({
|
||||||
});
|
});
|
||||||
|
|
||||||
const validServer = withValidation({
|
const validServer = withValidation({
|
||||||
|
deriveData: async ({ value }) => {
|
||||||
|
try {
|
||||||
|
// check if we can successfully load this server's room directory
|
||||||
|
await MatrixClientPeg.get().publicRooms({
|
||||||
|
limit: 1,
|
||||||
|
server: value,
|
||||||
|
});
|
||||||
|
return {};
|
||||||
|
} catch (error) {
|
||||||
|
return { error };
|
||||||
|
}
|
||||||
|
},
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
key: "required",
|
key: "required",
|
||||||
|
@ -57,21 +69,11 @@ const validServer = withValidation({
|
||||||
}, {
|
}, {
|
||||||
key: "available",
|
key: "available",
|
||||||
final: true,
|
final: true,
|
||||||
test: async ({ value }) => {
|
test: async (_, { error }) => !error,
|
||||||
try {
|
|
||||||
const opts = {
|
|
||||||
limit: 1,
|
|
||||||
server: value,
|
|
||||||
};
|
|
||||||
// check if we can successfully load this server's room directory
|
|
||||||
await MatrixClientPeg.get().publicRooms(opts);
|
|
||||||
return true;
|
|
||||||
} catch (e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
valid: () => _t("Looks good"),
|
valid: () => _t("Looks good"),
|
||||||
invalid: () => _t("Can't find this server or its room list"),
|
invalid: ({ error }) => error.errcode === "M_FORBIDDEN"
|
||||||
|
? _t("You are not allowed to view this server's rooms list")
|
||||||
|
: _t("Can't find this server or its room list"),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
|
@ -2019,6 +2019,7 @@
|
||||||
"Home": "Home",
|
"Home": "Home",
|
||||||
"Enter a server name": "Enter a server name",
|
"Enter a server name": "Enter a server name",
|
||||||
"Looks good": "Looks good",
|
"Looks good": "Looks good",
|
||||||
|
"You are not allowed to view this server's rooms list": "You are not allowed to view this server's rooms list",
|
||||||
"Can't find this server or its room list": "Can't find this server or its room list",
|
"Can't find this server or its room list": "Can't find this server or its room list",
|
||||||
"Your server": "Your server",
|
"Your server": "Your server",
|
||||||
"Are you sure you want to remove <b>%(serverName)s</b>": "Are you sure you want to remove <b>%(serverName)s</b>",
|
"Are you sure you want to remove <b>%(serverName)s</b>": "Are you sure you want to remove <b>%(serverName)s</b>",
|
||||||
|
|
Loading…
Reference in New Issue