Don't allow people to set their instance name to an empty string (or only whitespace) (#240)
* make server name required * prevent space-only instance name * add useTrimLead to TextFieldProps
This commit is contained in:
@@ -42,6 +42,7 @@ export default function TextFieldWithSubmit(props: TextFieldWithSubmitProps) {
|
|||||||
configPath = '',
|
configPath = '',
|
||||||
initialValue,
|
initialValue,
|
||||||
useTrim,
|
useTrim,
|
||||||
|
useTrimLead,
|
||||||
...textFieldProps // rest of props
|
...textFieldProps // rest of props
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
@@ -73,7 +74,7 @@ export default function TextFieldWithSubmit(props: TextFieldWithSubmitProps) {
|
|||||||
if (onChange) {
|
if (onChange) {
|
||||||
onChange({
|
onChange({
|
||||||
fieldName: changedFieldName,
|
fieldName: changedFieldName,
|
||||||
value: useTrim ? changedValue.trim() : changedValue,
|
value: useTrim ? changedValue.trim() : useTrimLead ? changedValue.replace(/^\s+/g,'') : changedValue,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export interface TextFieldProps {
|
|||||||
tip?: string;
|
tip?: string;
|
||||||
type?: string;
|
type?: string;
|
||||||
useTrim?: boolean;
|
useTrim?: boolean;
|
||||||
|
useTrimLead?: boolean;
|
||||||
value?: string | number;
|
value?: string | number;
|
||||||
onBlur?: FieldUpdaterFunc;
|
onBlur?: FieldUpdaterFunc;
|
||||||
onChange?: FieldUpdaterFunc;
|
onChange?: FieldUpdaterFunc;
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ export const TEXTFIELD_PROPS_SERVER_NAME = {
|
|||||||
placeholder: 'Owncast site name', // like "gothland"
|
placeholder: 'Owncast site name', // like "gothland"
|
||||||
label: 'Name',
|
label: 'Name',
|
||||||
tip: 'The name of your Owncast server',
|
tip: 'The name of your Owncast server',
|
||||||
|
required: true,
|
||||||
|
useTrimLead: true,
|
||||||
};
|
};
|
||||||
export const TEXTFIELD_PROPS_STREAM_TITLE = {
|
export const TEXTFIELD_PROPS_STREAM_TITLE = {
|
||||||
apiPath: API_STREAM_TITLE,
|
apiPath: API_STREAM_TITLE,
|
||||||
|
|||||||
Reference in New Issue
Block a user