add recommendations for alt aliases

This commit is contained in:
Bruno Windels 2020-03-09 16:31:07 +01:00
parent 38e99f3a68
commit eb539537f2
4 changed files with 15 additions and 2 deletions

View file

@ -123,7 +123,8 @@ export default class EditableItemList extends React.Component {
<form onSubmit={this._onItemAdded} autoComplete="off" <form onSubmit={this._onItemAdded} autoComplete="off"
noValidate={true} className="mx_EditableItemList_newItem"> noValidate={true} className="mx_EditableItemList_newItem">
<Field id={`mx_EditableItemList_new_${this.props.id}`} label={this.props.placeholder} type="text" <Field id={`mx_EditableItemList_new_${this.props.id}`} label={this.props.placeholder} type="text"
autoComplete="off" value={this.props.newItem || ""} onChange={this._onNewItemChanged} /> autoComplete="off" value={this.props.newItem || ""} onChange={this._onNewItemChanged}
list={this.props.suggestionsListId} />
<AccessibleButton onClick={this._onItemAdded} kind="primary"> <AccessibleButton onClick={this._onItemAdded} kind="primary">
{_t("Add")} {_t("Add")}
</AccessibleButton> </AccessibleButton>

View file

@ -32,6 +32,8 @@ export default class Field extends React.PureComponent {
element: PropTypes.oneOf(["input", "select", "textarea"]), element: PropTypes.oneOf(["input", "select", "textarea"]),
// The field's type (when used as an <input>). Defaults to "text". // The field's type (when used as an <input>). Defaults to "text".
type: PropTypes.string, type: PropTypes.string,
// id of a <datalist> element for suggestions
list: PropTypes.string,
// The field's label string. // The field's label string.
label: PropTypes.string, label: PropTypes.string,
// The field's placeholder string. Defaults to the label. // The field's placeholder string. Defaults to the label.
@ -157,7 +159,7 @@ export default class Field extends React.PureComponent {
render() { render() {
const { const {
element, prefix, postfix, className, onValidate, children, element, prefix, postfix, className, onValidate, children,
tooltipContent, flagInvalid, tooltipClassName, ...inputProps} = this.props; tooltipContent, flagInvalid, tooltipClassName, list, ...inputProps} = this.props;
const inputElement = element || "input"; const inputElement = element || "input";
@ -169,6 +171,7 @@ export default class Field extends React.PureComponent {
inputProps.onFocus = this.onFocus; inputProps.onFocus = this.onFocus;
inputProps.onChange = this.onChange; inputProps.onChange = this.onChange;
inputProps.onBlur = this.onBlur; inputProps.onBlur = this.onBlur;
inputProps.list = list;
const fieldInput = React.createElement(inputElement, inputProps, children); const fieldInput = React.createElement(inputElement, inputProps, children);

View file

@ -332,6 +332,11 @@ export default class AliasSettings extends React.Component {
<div className='mx_AliasSettings'> <div className='mx_AliasSettings'>
{canonicalAliasSection} {canonicalAliasSection}
{localAliasesList} {localAliasesList}
<datalist id="mx_AliasSettings_altRecommendations">
{this._getLocalNonAltAliases().map(alias => {
return <option value={alias} key={alias} />;
})};
</datalist>
<EditableAliasesList <EditableAliasesList
id="roomAltAliases" id="roomAltAliases"
className={"mx_RoomSettings_altAliases"} className={"mx_RoomSettings_altAliases"}
@ -342,6 +347,7 @@ export default class AliasSettings extends React.Component {
canEdit={this.props.canSetCanonicalAlias} canEdit={this.props.canSetCanonicalAlias}
onItemAdded={this.onAltAliasAdded} onItemAdded={this.onAltAliasAdded}
onItemRemoved={this.onAltAliasDeleted} onItemRemoved={this.onAltAliasDeleted}
suggestionsListId="mx_AliasSettings_altRecommendations"
itemsLabel={_t('Alternative addresses for this room:')} itemsLabel={_t('Alternative addresses for this room:')}
noItemsLabel={_t('This room has no alternative addresses')} noItemsLabel={_t('This room has no alternative addresses')}
placeholder={_t( placeholder={_t(

View file

@ -1143,6 +1143,7 @@
"Mark all as read": "Mark all as read", "Mark all as read": "Mark all as read",
"Error updating main address": "Error updating main address", "Error updating main address": "Error updating main address",
"There was an error updating the room's main address. It may not be allowed by the server or a temporary failure occurred.": "There was an error updating the room's main address. It may not be allowed by the server or a temporary failure occurred.", "There was an error updating the room's main address. It may not be allowed by the server or a temporary failure occurred.": "There was an error updating the room's main address. It may not be allowed by the server or a temporary failure occurred.",
"There was an error updating the room's alternative addresses. It may not be allowed by the server or a temporary failure occurred.": "There was an error updating the room's alternative addresses. It may not be allowed by the server or a temporary failure occurred.",
"Error creating alias": "Error creating alias", "Error creating alias": "Error creating alias",
"There was an error creating that alias. It may not be allowed by the server or a temporary failure occurred.": "There was an error creating that alias. It may not be allowed by the server or a temporary failure occurred.", "There was an error creating that alias. It may not be allowed by the server or a temporary failure occurred.": "There was an error creating that alias. It may not be allowed by the server or a temporary failure occurred.",
"Error removing alias": "Error removing alias", "Error removing alias": "Error removing alias",
@ -1152,6 +1153,8 @@
"Local addresses for this room:": "Local addresses for this room:", "Local addresses for this room:": "Local addresses for this room:",
"This room has no local addresses": "This room has no local addresses", "This room has no local addresses": "This room has no local addresses",
"New address (e.g. #foo:%(localDomain)s)": "New address (e.g. #foo:%(localDomain)s)", "New address (e.g. #foo:%(localDomain)s)": "New address (e.g. #foo:%(localDomain)s)",
"Alternative addresses for this room:": "Alternative addresses for this room:",
"This room has no alternative addresses": "This room has no alternative addresses",
"New address (e.g. #foo:domain)": "New address (e.g. #foo:domain)", "New address (e.g. #foo:domain)": "New address (e.g. #foo:domain)",
"Error updating flair": "Error updating flair", "Error updating flair": "Error updating flair",
"There was an error updating the flair for this room. The server may not allow it or a temporary error occurred.": "There was an error updating the flair for this room. The server may not allow it or a temporary error occurred.", "There was an error updating the flair for this room. The server may not allow it or a temporary error occurred.": "There was an error updating the flair for this room. The server may not allow it or a temporary error occurred.",