Browse Source

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
pull/1886/head
Meisam 4 years ago committed by GitHub
parent
commit
7a1f9dcd9a
  1. 3
      web/components/config/form-textfield-with-submit.tsx
  2. 1
      web/components/config/form-textfield.tsx
  3. 2
      web/utils/config-constants.tsx

3
web/components/config/form-textfield-with-submit.tsx

@ -42,6 +42,7 @@ export default function TextFieldWithSubmit(props: TextFieldWithSubmitProps) { @@ -42,6 +42,7 @@ export default function TextFieldWithSubmit(props: TextFieldWithSubmitProps) {
configPath = '',
initialValue,
useTrim,
useTrimLead,
...textFieldProps // rest of props
} = props;
@ -73,7 +74,7 @@ export default function TextFieldWithSubmit(props: TextFieldWithSubmitProps) { @@ -73,7 +74,7 @@ export default function TextFieldWithSubmit(props: TextFieldWithSubmitProps) {
if (onChange) {
onChange({
fieldName: changedFieldName,
value: useTrim ? changedValue.trim() : changedValue,
value: useTrim ? changedValue.trim() : useTrimLead ? changedValue.replace(/^\s+/g,'') : changedValue,
});
}
};

1
web/components/config/form-textfield.tsx

@ -29,6 +29,7 @@ export interface TextFieldProps { @@ -29,6 +29,7 @@ export interface TextFieldProps {
tip?: string;
type?: string;
useTrim?: boolean;
useTrimLead?: boolean;
value?: string | number;
onBlur?: FieldUpdaterFunc;
onChange?: FieldUpdaterFunc;

2
web/utils/config-constants.tsx

@ -56,6 +56,8 @@ export const TEXTFIELD_PROPS_SERVER_NAME = { @@ -56,6 +56,8 @@ export const TEXTFIELD_PROPS_SERVER_NAME = {
placeholder: 'Owncast site name', // like "gothland"
label: 'Name',
tip: 'The name of your Owncast server',
required: true,
useTrimLead: true,
};
export const TEXTFIELD_PROPS_STREAM_TITLE = {
apiPath: API_STREAM_TITLE,

Loading…
Cancel
Save