mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-02 21:02:25 -06:00
[frontend] Better autocapitalize/spellcheck settings on forms (#3077)
This commit is contained in:
parent
5769722c58
commit
bbbf6ebe37
20 changed files with 205 additions and 38 deletions
|
|
@ -22,9 +22,33 @@ import { TextInput } from "../../../../components/form/inputs";
|
|||
import MutationButton from "../../../../components/form/mutation-button";
|
||||
import { useTextInput } from "../../../../lib/form";
|
||||
import { useInstanceKeysExpireMutation } from "../../../../lib/query/admin/actions";
|
||||
import isValidDomain from "is-valid-domain";
|
||||
|
||||
export default function ExpireRemote({}) {
|
||||
const domainField = useTextInput("domain");
|
||||
const domainField = useTextInput("domain", {
|
||||
validator: (v: string) => {
|
||||
if (v.length === 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (v[v.length-1] === ".") {
|
||||
return "invalid domain";
|
||||
}
|
||||
|
||||
const valid = isValidDomain(v, {
|
||||
subdomain: true,
|
||||
wildcard: false,
|
||||
allowUnicode: true,
|
||||
topLevel: false,
|
||||
});
|
||||
|
||||
if (valid) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return "invalid domain";
|
||||
}
|
||||
});
|
||||
|
||||
const [expire, expireResult] = useInstanceKeysExpireMutation();
|
||||
|
||||
|
|
@ -52,11 +76,13 @@ export default function ExpireRemote({}) {
|
|||
<TextInput
|
||||
field={domainField}
|
||||
label="Domain"
|
||||
type="string"
|
||||
type="text"
|
||||
autoCapitalize="none"
|
||||
spellCheck="false"
|
||||
placeholder="example.org"
|
||||
/>
|
||||
<MutationButton
|
||||
disabled={!domainField.value}
|
||||
disabled={!domainField.value || !domainField.valid}
|
||||
label="Expire keys"
|
||||
result={expireResult}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -53,6 +53,9 @@ export default function ApURL() {
|
|||
<TextInput
|
||||
field={urlField}
|
||||
label="URL"
|
||||
type="url"
|
||||
pattern="(http|https):\/\/.+"
|
||||
placeholder="https://example.org/users/someone"
|
||||
/>
|
||||
<MutationButton
|
||||
disabled={!urlField.value}
|
||||
|
|
|
|||
|
|
@ -126,6 +126,8 @@ export function CategorySelect({ field, children }: PropsWithChildren<CategorySe
|
|||
items={categoryItems}
|
||||
label="Category"
|
||||
placeholder="e.g., reactions"
|
||||
autoCapitalize="none"
|
||||
spellCheck="false"
|
||||
>
|
||||
{children}
|
||||
</ComboBox>
|
||||
|
|
|
|||
|
|
@ -117,6 +117,8 @@ export default function NewEmojiForm() {
|
|||
<TextInput
|
||||
field={form.shortcode}
|
||||
label="Shortcode, must be unique among the instance's local emoji"
|
||||
autoCapitalize="none"
|
||||
spellCheck="false"
|
||||
{...{pattern: "^\\w{2,30}$"}}
|
||||
/>
|
||||
|
||||
|
|
|
|||
|
|
@ -116,6 +116,8 @@ function EmojiList({ emoji }: EmojiListParams) {
|
|||
field={filterField}
|
||||
name="emoji-shortcode"
|
||||
placeholder="Search"
|
||||
autoCapitalize="none"
|
||||
spellCheck="false"
|
||||
/>
|
||||
</div>
|
||||
<div className="entries scrolling">
|
||||
|
|
|
|||
|
|
@ -52,9 +52,10 @@ export default function StealThisLook({ emojiCodes }) {
|
|||
</label>
|
||||
<div className="row">
|
||||
<input
|
||||
type="text"
|
||||
id="url"
|
||||
name="url"
|
||||
type="url"
|
||||
pattern="(http|https):\/\/.+"
|
||||
onChange={urlField.onChange}
|
||||
value={urlField.value}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ export default function HeaderPermCreateForm({ permType }: { permType: PermType
|
|||
field={form.header}
|
||||
label={
|
||||
<>
|
||||
HTTP Header Name
|
||||
Header Name
|
||||
<a
|
||||
href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers"
|
||||
target="_blank"
|
||||
|
|
@ -112,12 +112,15 @@ export default function HeaderPermCreateForm({ permType }: { permType: PermType
|
|||
</>
|
||||
}
|
||||
placeholder={"User-Agent"}
|
||||
autoCapitalize="none"
|
||||
spellCheck="false"
|
||||
{...{className: "monospace"}}
|
||||
/>
|
||||
<TextInput
|
||||
field={form.regex}
|
||||
label={
|
||||
<>
|
||||
HTTP Header Value RE2 Regex
|
||||
Value Regex
|
||||
<a
|
||||
href="https://github.com/google/re2/wiki/Syntax"
|
||||
target="_blank"
|
||||
|
|
@ -129,6 +132,8 @@ export default function HeaderPermCreateForm({ permType }: { permType: PermType
|
|||
</>
|
||||
}
|
||||
placeholder={"^.*Some-User-Agent.*$"}
|
||||
autoCapitalize="none"
|
||||
spellCheck="false"
|
||||
{...{className: "monospace"}}
|
||||
/>
|
||||
<MutationButton
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ function PermDeets({
|
|||
<dl className="info-list">
|
||||
<div className="info-list-entry">
|
||||
<dt>ID</dt>
|
||||
<dd>{perm.id}</dd>
|
||||
<dd className="monospace">{perm.id}</dd>
|
||||
</div>
|
||||
<div className="info-list-entry">
|
||||
<dt>Created</dt>
|
||||
|
|
@ -176,10 +176,10 @@ function PermDeets({
|
|||
</div>
|
||||
<div className="info-list-entry">
|
||||
<dt>Header Name</dt>
|
||||
<dd>{perm.header}</dd>
|
||||
<dd className="monospace">{perm.header}</dd>
|
||||
</div>
|
||||
<div className="info-list-entry">
|
||||
<dt>Header Value Regex</dt>
|
||||
<dt>Value Regex</dt>
|
||||
<dd className="monospace">{perm.regex}</dd>
|
||||
</div>
|
||||
<div className="info-list-entry">
|
||||
|
|
|
|||
|
|
@ -79,7 +79,10 @@ function InstanceSettingsForm({ data: instance }: InstanceSettingsFormProps) {
|
|||
const [submitForm, result] = useFormSubmit(form, useUpdateInstanceMutation());
|
||||
|
||||
return (
|
||||
<form onSubmit={submitForm}>
|
||||
<form
|
||||
onSubmit={submitForm}
|
||||
autoComplete="none"
|
||||
>
|
||||
<h1>Instance Settings</h1>
|
||||
|
||||
<div className="form-section-docs">
|
||||
|
|
@ -97,7 +100,8 @@ function InstanceSettingsForm({ data: instance }: InstanceSettingsFormProps) {
|
|||
<TextInput
|
||||
field={form.title}
|
||||
label={`Instance title (max ${titleLimit} characters)`}
|
||||
placeholder="My GoToSocial instance"
|
||||
autoCapitalize="words"
|
||||
placeholder="My GoToSocial Instance"
|
||||
/>
|
||||
|
||||
<div className="file-upload" aria-labelledby="avatar">
|
||||
|
|
@ -117,6 +121,7 @@ function InstanceSettingsForm({ data: instance }: InstanceSettingsFormProps) {
|
|||
field={form.thumbnailDesc}
|
||||
label="Avatar image description"
|
||||
placeholder="A cute drawing of a smiling sloth."
|
||||
autoCapitalize="sentences"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -139,6 +144,7 @@ function InstanceSettingsForm({ data: instance }: InstanceSettingsFormProps) {
|
|||
field={form.shortDesc}
|
||||
label={`Short description (markdown accepted, max ${shortDescLimit} characters)`}
|
||||
placeholder="A small testing instance for the GoToSocial alpha software."
|
||||
autoCapitalize="sentences"
|
||||
rows={6}
|
||||
/>
|
||||
|
||||
|
|
@ -146,6 +152,7 @@ function InstanceSettingsForm({ data: instance }: InstanceSettingsFormProps) {
|
|||
field={form.description}
|
||||
label={`Full description (markdown accepted, max ${descLimit} characters)`}
|
||||
placeholder="A small testing instance for the GoToSocial alpha software. Just trying it out, my main instance is https://example.com"
|
||||
autoCapitalize="sentences"
|
||||
rows={6}
|
||||
/>
|
||||
|
||||
|
|
@ -153,6 +160,7 @@ function InstanceSettingsForm({ data: instance }: InstanceSettingsFormProps) {
|
|||
field={form.terms}
|
||||
label={`Terms & Conditions (markdown accepted, max ${termsLimit} characters)`}
|
||||
placeholder="Terms and conditions of using this instance, data policy, imprint, GDPR stuff, yadda yadda."
|
||||
autoCapitalize="sentences"
|
||||
rows={6}
|
||||
/>
|
||||
|
||||
|
|
@ -172,12 +180,15 @@ function InstanceSettingsForm({ data: instance }: InstanceSettingsFormProps) {
|
|||
field={form.contactUser}
|
||||
label="Contact user (local account username)"
|
||||
placeholder="admin"
|
||||
autoCapitalize="none"
|
||||
spellCheck="false"
|
||||
/>
|
||||
|
||||
<TextInput
|
||||
field={form.contactEmail}
|
||||
label="Contact email"
|
||||
placeholder="admin@example.com"
|
||||
type="email"
|
||||
/>
|
||||
|
||||
<MutationButton label="Save" result={result} disabled={false} />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue