v4: the slug and rename fields lose their hints about old links — "Links to the old address keep working." under the dump and playlist link field, and "Their old name keeps leading to them…" under the moderator's rename field, described a server guarantee nobody filling the form needs to read. Only the fields' errors show under them now; UsernameField loses its hint prop. 670 frontend tests pass, tsc and i18n:compile --strict are clean.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
khannurien
2026-10-08 21:28:01 +00:00
parent 437eea0df3
commit 45e004b465
7 changed files with 66 additions and 100 deletions

View File

@@ -1,8 +1,8 @@
/**
* Renders the slug of a dump or a playlist, the last segment of its page's
* path, in their edit forms. A slug changes only from here: a new title
* proposes one, which saving applies, and the old one keeps leading to the
* page.
* proposes one, which saving applies, and the old one stays an alias of the
* item on the server.
*
* @module
*/
@@ -37,8 +37,7 @@ export interface SlugFieldProps<T extends FieldValues> {
}
/**
* Renders the slug's input after its path, its error, and a hint that old
* links keep working. Until the user types in it, it follows the title,
* Renders the slug's input after its path, and its error. Until the user types in it, it follows the title,
* proposing `slugify(title)`, or the saved slug when the title slugifies as
* the saved one does. It must sit under a react-hook-form `FormProvider`.
*/
@@ -89,17 +88,11 @@ export function SlugField<T extends FieldValues>(
})}
/>
</div>
{error?.message
? (
<span className="form-hint form-hint--error">
{String(error.message)}
</span>
)
: (
<span className="form-hint">
<Trans>Links to the old address keep working.</Trans>
</span>
)}
{error?.message && (
<span className="form-hint form-hint--error">
{String(error.message)}
</span>
)}
</div>
);
}

View File

@@ -63,12 +63,6 @@ export function ProfileManageTab(
key={user.username}
username={user.username}
save={rename}
hint={
<Trans>
Their old name keeps leading to them, and nobody else can take
it.
</Trans>
}
/>
</SettingRow>
</div>

View File

@@ -5,7 +5,6 @@
* @module
*/
import type { ReactNode } from "react";
import { t } from "@lingui/core/macro";
import { Trans } from "@lingui/react/macro";
import { FormProvider } from "react-hook-form";
@@ -23,17 +22,14 @@ export interface UsernameFieldProps {
* field shows.
*/
save: (username: string) => Promise<string>;
/** Shown under the field, such as what becomes of the old name. */
hint?: ReactNode;
}
/**
* Renders the name in a text input with a "Rename" button, which is enabled
* once the name differs. The old name keeps leading to the user, as the hint
* should say.
* once the name differs.
*/
export function UsernameField(
{ username, save, hint }: UsernameFieldProps,
{ username, save }: UsernameFieldProps,
): React.JSX.Element {
const form = useApiForm<{ username: string }>({
defaultValues: { username },
@@ -77,7 +73,6 @@ export function UsernameField(
{String(error.message)}
</span>
)}
{hint && <p className="form-hint">{hint}</p>}
<FormError title={t`Could not rename`} />
</form>
</FormProvider>