Normalize alias a little, display initial sigil
turns all whitespace into underscores, shows leading sigil if the alias is non-empty, so the user doesn't get confused about whether they have to input a # or not. Change-Id: Ic81e69cc3f0074d63a67b976c9bda32f8de025de
This commit is contained in:
parent
c1c32e3268
commit
24abcd4e4a
@ -76,6 +76,8 @@ const validateAlias = fieldval => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const removeLeadingWhitespace = fieldVal => fieldVal === undefined ? undefined : fieldVal.trimStart();
|
const removeLeadingWhitespace = fieldVal => fieldVal === undefined ? undefined : fieldVal.trimStart();
|
||||||
|
const replaceAllWhitespace = fieldVal => fieldVal === undefined ? undefined : fieldVal.replace(/\s/, "_");
|
||||||
|
const removeLeadingSigil = fieldVal => fieldVal === undefined ? undefined : fieldVal.startsWith("#") ? fieldVal.substr(1) : fieldVal;
|
||||||
|
|
||||||
const validateHasAliasIfPublic = formdata => {
|
const validateHasAliasIfPublic = formdata => {
|
||||||
let errors = {};
|
let errors = {};
|
||||||
@ -94,7 +96,8 @@ export const RoomCreate = props => (
|
|||||||
parse={removeLeadingWhitespace}
|
parse={removeLeadingWhitespace}
|
||||||
validate={validateDisplayName}/>
|
validate={validateDisplayName}/>
|
||||||
<TextInput source="alias"
|
<TextInput source="alias"
|
||||||
parse={removeLeadingWhitespace}
|
parse={fv => replaceAllWhitespace(removeLeadingSigil(fv)) }
|
||||||
|
format={fv => fv === "" ? "" : "#" + fv}
|
||||||
validate={validateAlias}/>
|
validate={validateAlias}/>
|
||||||
<BooleanInput source="public"
|
<BooleanInput source="public"
|
||||||
label="synapseadmin.rooms.make_public"/>
|
label="synapseadmin.rooms.make_public"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user