Show Matrix specs supported by the homeserver

Change-Id: I01c110fb4b3de4de49b34f290c91c8bf424521fe
This commit is contained in:
Manuel Stahl 2024-04-17 11:25:17 +02:00
parent 25020c2d5b
commit c9cb9aa9e0
4 changed files with 39 additions and 12 deletions

View file

@ -27,6 +27,7 @@ import { styled } from "@mui/material/styles";
import LockIcon from "@mui/icons-material/Lock"; import LockIcon from "@mui/icons-material/Lock";
import { import {
getServerVersion, getServerVersion,
getSupportedFeatures,
getSupportedLoginFlows, getSupportedLoginFlows,
getWellKnownUrl, getWellKnownUrl,
isValidBaseUrl, isValidBaseUrl,
@ -36,7 +37,7 @@ import {
const FormBox = styled(Box)(({ theme }) => ({ const FormBox = styled(Box)(({ theme }) => ({
display: "flex", display: "flex",
flexDirection: "column", flexDirection: "column",
minHeight: "calc(100vh - 1em)", minHeight: "calc(100vh - 1rem)",
alignItems: "center", alignItems: "center",
justifyContent: "flex-start", justifyContent: "flex-start",
background: "url(./images/floating-cogs.svg)", background: "url(./images/floating-cogs.svg)",
@ -45,12 +46,12 @@ const FormBox = styled(Box)(({ theme }) => ({
backgroundSize: "cover", backgroundSize: "cover",
[`& .card`]: { [`& .card`]: {
minWidth: "30em", width: "30rem",
marginTop: "6em", marginTop: "6rem",
marginBottom: "6em", marginBottom: "6rem",
}, },
[`& .avatar`]: { [`& .avatar`]: {
margin: "1em", margin: "1rem",
display: "flex", display: "flex",
justifyContent: "center", justifyContent: "center",
}, },
@ -59,24 +60,31 @@ const FormBox = styled(Box)(({ theme }) => ({
}, },
[`& .hint`]: { [`& .hint`]: {
marginTop: "1em", marginTop: "1em",
marginBottom: "1em",
display: "flex", display: "flex",
justifyContent: "center", justifyContent: "center",
color: theme.palette.grey[600], color: theme.palette.grey[600],
}, },
[`& .form`]: { [`& .form`]: {
padding: "0 1em 1em 1em", padding: "0 1rem 1rem 1rem",
}, },
[`& .input`]: { [`& .select`]: {
marginTop: "1em", marginBottom: "2rem",
}, },
[`& .actions`]: { [`& .actions`]: {
padding: "0 1em 1em 1em", padding: "0 1rem 1rem 1rem",
}, },
[`& .serverVersion`]: { [`& .serverVersion`]: {
color: theme.palette.grey[500], color: theme.palette.grey[500],
fontFamily: "Roboto, Helvetica, Arial, sans-serif", fontFamily: "Roboto, Helvetica, Arial, sans-serif",
marginBottom: "1em", marginLeft: "0.5rem",
marginLeft: "0.5em", },
[`& .matrixVersions`]: {
color: theme.palette.grey[500],
fontFamily: "Roboto, Helvetica, Arial, sans-serif",
fontSize: "0.8rem",
marginBottom: "1rem",
marginLeft: "0.5rem",
}, },
})); }));
@ -164,6 +172,7 @@ const LoginPage = () => {
const UserData = ({ formData }) => { const UserData = ({ formData }) => {
const form = useFormContext(); const form = useFormContext();
const [serverVersion, setServerVersion] = useState(""); const [serverVersion, setServerVersion] = useState("");
const [matrixVersions, setMatrixVersions] = useState("");
const handleUsernameChange = _ => { const handleUsernameChange = _ => {
if (formData.base_url || cfg_base_url) return; if (formData.base_url || cfg_base_url) return;
@ -185,6 +194,14 @@ const LoginPage = () => {
) )
.catch(() => setServerVersion("")); .catch(() => setServerVersion(""));
getSupportedFeatures(formData.base_url)
.then(features =>
setMatrixVersions(
`${translate("synapseadmin.auth.supports_specs")} ${features.versions.join(", ")}`
)
)
.catch(() => setMatrixVersions(""));
// Set SSO Url // Set SSO Url
getSupportedLoginFlows(formData.base_url) getSupportedLoginFlows(formData.base_url)
.then(loginFlows => { .then(loginFlows => {
@ -237,6 +254,7 @@ const LoginPage = () => {
/> />
</Box> </Box>
<Typography className="serverVersion">{serverVersion}</Typography> <Typography className="serverVersion">{serverVersion}</Typography>
<Typography className="matrixVersions">{matrixVersions}</Typography>
</> </>
); );
}; };
@ -267,7 +285,7 @@ const LoginPage = () => {
}} }}
fullWidth fullWidth
disabled={loading} disabled={loading}
className="input" className="select"
> >
<MenuItem value="de">Deutsch</MenuItem> <MenuItem value="de">Deutsch</MenuItem>
<MenuItem value="en">English</MenuItem> <MenuItem value="en">English</MenuItem>

View file

@ -7,6 +7,7 @@ const de = {
base_url: "Heimserver URL", base_url: "Heimserver URL",
welcome: "Willkommen bei Synapse-admin", welcome: "Willkommen bei Synapse-admin",
server_version: "Synapse Version", server_version: "Synapse Version",
supports_specs: "unterstützt Matrix-Specs",
username_error: "Bitte vollständigen Nutzernamen angeben: '@user:domain'", username_error: "Bitte vollständigen Nutzernamen angeben: '@user:domain'",
protocol_error: "Die URL muss mit 'http://' oder 'https://' beginnen", protocol_error: "Die URL muss mit 'http://' oder 'https://' beginnen",
url_error: "Keine gültige Matrix Server URL", url_error: "Keine gültige Matrix Server URL",

View file

@ -7,6 +7,7 @@ const en = {
base_url: "Homeserver URL", base_url: "Homeserver URL",
welcome: "Welcome to Synapse-admin", welcome: "Welcome to Synapse-admin",
server_version: "Synapse version", server_version: "Synapse version",
supports_specs: "supports Matrix specs",
username_error: "Please enter fully qualified user ID: '@user:domain'", username_error: "Please enter fully qualified user ID: '@user:domain'",
protocol_error: "URL has to start with 'http://' or 'https://'", protocol_error: "URL has to start with 'http://' or 'https://'",
url_error: "Not a valid Matrix server URL", url_error: "Not a valid Matrix server URL",

View file

@ -36,6 +36,13 @@ export const getServerVersion = async baseUrl => {
return response.json.server_version; return response.json.server_version;
}; };
/** Get supported Matrix features */
export const getSupportedFeatures = async baseUrl => {
const versionUrl = `${baseUrl}/_matrix/client/versions`;
const response = await fetchUtils.fetchJson(versionUrl, { method: "GET" });
return response.json;
};
/** /**
* Get supported login flows * Get supported login flows
* @param baseUrl the base URL of the homeserver * @param baseUrl the base URL of the homeserver