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

File diff suppressed because one or more lines are too long

View File

@@ -426,7 +426,7 @@ msgid "← Back"
msgstr "← Back"
#: src/pages/Dump.tsx:326
#: src/pages/Dump.tsx:566
#: src/pages/Dump.tsx:568
#: src/pages/DumpEdit.tsx:231
msgid "← Back to all dumps"
msgstr "← Back to all dumps"
@@ -497,7 +497,7 @@ msgstr "1 new message"
msgid "a comment"
msgstr "a comment"
#: src/components/form/SlugField.tsx:83
#: src/components/form/SlugField.tsx:82
msgid "A link is required"
msgstr "A link is required"
@@ -518,7 +518,7 @@ msgstr "Add a comment…"
msgid "Add category"
msgstr "Add category"
#: src/components/profile/ProfileHeader.tsx:155
#: src/components/profile/ProfileHeader.tsx:154
msgid "Add email…"
msgstr "Add email…"
@@ -585,7 +585,7 @@ msgstr "Can't connect to the live updates server. Upvotes and notifications may
#: src/components/category/CategoryManager.tsx:225
#: src/components/category/CategoryManager.tsx:226
#: src/components/chat/ChatEditBox.tsx:88
#: src/components/chat/ChatEditBox.tsx:92
#: src/components/comment/CommentForm.tsx:127
#: src/components/dump/create/DumpCreateModal.tsx:752
#: src/components/form/FormActions.tsx:42
@@ -593,7 +593,7 @@ msgstr "Can't connect to the live updates server. Upvotes and notifications may
#: src/components/profile/DescriptionEditor.tsx:97
#: src/components/profile/EmailEditor.tsx:83
#: src/components/shared/ConfirmModal.tsx:63
#: src/pages/Dump.tsx:444
#: src/pages/Dump.tsx:445
#: src/pages/DumpEdit.tsx:570
msgid "Cancel"
msgstr "Cancel"
@@ -716,7 +716,7 @@ msgstr "Could not connect to the server. Check your connection and try again."
msgid "Could not delete"
msgstr "Could not delete"
#: src/components/profile/UsernameField.tsx:81
#: src/components/profile/UsernameField.tsx:76
msgid "Could not rename"
msgstr "Could not rename"
@@ -893,7 +893,7 @@ msgstr "Earlier"
#: src/components/chat/PendingItem.tsx:93
#: src/components/comment/CommentNode.tsx:256
#: src/components/playlist/PlaylistHeader.tsx:59
#: src/pages/Dump.tsx:562
#: src/pages/Dump.tsx:564
msgid "Edit"
msgstr "Edit"
@@ -906,12 +906,12 @@ msgstr "Edit {0}"
msgid "Edit description"
msgstr "Edit description"
#: src/components/profile/ProfileHeader.tsx:153
#: src/components/profile/ProfileHeader.tsx:152
msgid "Edit email"
msgstr "Edit email"
#: src/components/dump/create/TitleField.tsx:69
#: src/pages/Dump.tsx:460
#: src/pages/Dump.tsx:462
msgid "Edit title"
msgstr "Edit title"
@@ -925,7 +925,7 @@ msgstr "edited"
#: src/components/chat/ChatMessageItem.tsx:129
#: src/components/comment/CommentNode.tsx:205
#: src/components/playlist/PlaylistHeader.tsx:94
#: src/pages/Dump.tsx:503
#: src/pages/Dump.tsx:505
msgid "edited {0}"
msgstr "edited {0}"
@@ -935,7 +935,7 @@ msgstr "edited {0}"
#: src/components/chat/ChatMessageItem.tsx:125
#: src/components/comment/CommentNode.tsx:203
#: src/components/playlist/PlaylistHeader.tsx:92
#: src/pages/Dump.tsx:501
#: src/pages/Dump.tsx:503
msgid "Edited {0}"
msgstr "Edited {0}"
@@ -1012,7 +1012,7 @@ msgstr "Failed to save category"
msgid "Failed to save edit"
msgstr "Failed to save edit"
#: src/components/profile/ProfileHeader.tsx:164
#: src/components/profile/ProfileHeader.tsx:163
msgid "Failed to update avatar"
msgstr "Failed to update avatar"
@@ -1102,7 +1102,7 @@ msgstr "If that address is registered you'll receive a reset link shortly."
msgid "image"
msgstr "image"
#: src/pages/Dump.tsx:582
#: src/pages/Dump.tsx:584
msgid "In collections"
msgstr "In collections"
@@ -1125,7 +1125,7 @@ msgstr "Invalid link"
msgid "Invite link"
msgstr "Invite link"
#: src/components/profile/ProfileHeader.tsx:118
#: src/components/profile/ProfileHeader.tsx:117
msgid "invited by"
msgstr "invited by"
@@ -1143,7 +1143,7 @@ msgstr "Journal"
msgid "Keep editing"
msgstr "Keep editing"
#: src/components/profile/UsernameField.tsx:63
#: src/components/profile/UsernameField.tsx:59
msgid "Letters, numbers and underscores only"
msgstr "Letters, numbers and underscores only"
@@ -1156,7 +1156,7 @@ msgid "Like"
msgstr "Like"
#: src/components/dump/create/DumpCreateModal.tsx:569
#: src/components/form/SlugField.tsx:70
#: src/components/form/SlugField.tsx:69
msgid "Link"
msgstr "Link"
@@ -1164,10 +1164,6 @@ msgstr "Link"
msgid "Link or file"
msgstr "Link or file"
#: src/components/form/SlugField.tsx:100
msgid "Links to the old address keep working."
msgstr "Links to the old address keep working."
#: src/contexts/ws/WSProvider.tsx:760
msgid "Live updates are temporarily disconnected. Trying to reconnect…"
msgstr "Live updates are temporarily disconnected. Trying to reconnect…"
@@ -1230,7 +1226,7 @@ msgstr "Log in to like"
msgid "Log in to vote"
msgstr "Log in to vote"
#: src/components/profile/ProfileHeader.tsx:189
#: src/components/profile/ProfileHeader.tsx:188
#: src/pages/UserPublicProfile.tsx:131
msgid "Log out"
msgstr "Log out"
@@ -1243,12 +1239,12 @@ msgstr "Logging in…"
msgid "Login failed"
msgstr "Login failed"
#: src/components/form/SlugField.tsx:86
#: src/components/form/SlugField.tsx:85
msgid "Lowercase letters, numbers and single hyphens only"
msgstr "Lowercase letters, numbers and single hyphens only"
#: src/components/layout/UserMenu.tsx:98
#: src/components/profile/ProfileHeader.tsx:181
#: src/components/profile/ProfileHeader.tsx:180
#: src/pages/Manage.tsx:23
#: src/pages/Manage.tsx:30
#: src/pages/UserPublicProfile.tsx:164
@@ -1496,7 +1492,7 @@ msgstr "Previous track"
#: src/components/playlist/PlaylistCard.tsx:104
#: src/components/playlist/PlaylistHeader.tsx:76
#: src/components/playlist/PlaylistMembershipPanel.tsx:81
#: src/pages/Dump.tsx:509
#: src/pages/Dump.tsx:511
msgid "private"
msgstr "private"
@@ -1539,7 +1535,7 @@ msgstr "Registering…"
msgid "Registration failed"
msgstr "Registration failed"
#: src/pages/Dump.tsx:573
#: src/pages/Dump.tsx:575
msgid "Related"
msgstr "Related"
@@ -1559,11 +1555,11 @@ msgstr "Remove like"
msgid "Remove vote"
msgstr "Remove vote"
#: src/components/profile/UsernameField.tsx:72
#: src/components/profile/UsernameField.tsx:68
msgid "Rename"
msgstr "Rename"
#: src/components/profile/UsernameField.tsx:69
#: src/components/profile/UsernameField.tsx:65
msgid "Renaming…"
msgstr "Renaming…"
@@ -1619,7 +1615,7 @@ msgstr "Role"
#: src/components/playlist/PlaylistEditForm.tsx:225
#: src/components/profile/DescriptionEditor.tsx:89
#: src/components/profile/EmailEditor.tsx:75
#: src/pages/Dump.tsx:436
#: src/pages/Dump.tsx:437
#: src/pages/DumpEdit.tsx:573
msgid "Save"
msgstr "Save"
@@ -1629,7 +1625,7 @@ msgstr "Save"
#: src/components/profile/ChangePasswordModal.tsx:119
#: src/components/profile/DescriptionEditor.tsx:86
#: src/components/profile/EmailEditor.tsx:72
#: src/pages/Dump.tsx:435
#: src/pages/Dump.tsx:436
#: src/pages/ResetPassword.tsx:139
msgid "Saving…"
msgstr "Saving…"
@@ -1687,7 +1683,7 @@ msgid "Set new password"
msgstr "Set new password"
#: src/components/layout/UserMenu.tsx:89
#: src/components/profile/ProfileHeader.tsx:177
#: src/components/profile/ProfileHeader.tsx:176
#: src/pages/Settings.tsx:69
#: src/pages/Settings.tsx:83
msgid "Settings"
@@ -1752,10 +1748,6 @@ msgstr "The image couldn't be uploaded."
msgid "The new order couldn't be saved. Try again."
msgstr "The new order couldn't be saved. Try again."
#: src/components/profile/ProfileManageTab.tsx:67
msgid "Their old name keeps leading to them, and nobody else can take it."
msgstr "Their old name keeps leading to them, and nobody else can take it."
#: src/components/comment/CommentNode.tsx:282
msgid "This comment couldn't be deleted. Try again."
msgstr "This comment couldn't be deleted. Try again."
@@ -1912,7 +1904,7 @@ msgid "User menu"
msgstr "User menu"
#: src/components/profile/ProfileManageTab.tsx:61
#: src/components/profile/UsernameField.tsx:55
#: src/components/profile/UsernameField.tsx:51
#: src/pages/Settings.tsx:88
#: src/pages/UserLogin.tsx:75
#: src/pages/UserRegister.tsx:137

File diff suppressed because one or more lines are too long

View File

@@ -426,7 +426,7 @@ msgid "← Back"
msgstr "← Retour"
#: src/pages/Dump.tsx:326
#: src/pages/Dump.tsx:566
#: src/pages/Dump.tsx:568
#: src/pages/DumpEdit.tsx:231
msgid "← Back to all dumps"
msgstr "← Retour à toutes les recos"
@@ -497,7 +497,7 @@ msgstr "1 nouveau message"
msgid "a comment"
msgstr "un commentaire"
#: src/components/form/SlugField.tsx:83
#: src/components/form/SlugField.tsx:82
msgid "A link is required"
msgstr "Il faut un lien"
@@ -518,7 +518,7 @@ msgstr "Ajouter un commentaire…"
msgid "Add category"
msgstr "Ajouter une catégorie"
#: src/components/profile/ProfileHeader.tsx:155
#: src/components/profile/ProfileHeader.tsx:154
msgid "Add email…"
msgstr "Ajouter un e-mail…"
@@ -585,7 +585,7 @@ msgstr "Impossible de se connecter au serveur de mises à jour en direct. Les vo
#: src/components/category/CategoryManager.tsx:225
#: src/components/category/CategoryManager.tsx:226
#: src/components/chat/ChatEditBox.tsx:88
#: src/components/chat/ChatEditBox.tsx:92
#: src/components/comment/CommentForm.tsx:127
#: src/components/dump/create/DumpCreateModal.tsx:752
#: src/components/form/FormActions.tsx:42
@@ -593,7 +593,7 @@ msgstr "Impossible de se connecter au serveur de mises à jour en direct. Les vo
#: src/components/profile/DescriptionEditor.tsx:97
#: src/components/profile/EmailEditor.tsx:83
#: src/components/shared/ConfirmModal.tsx:63
#: src/pages/Dump.tsx:444
#: src/pages/Dump.tsx:445
#: src/pages/DumpEdit.tsx:570
msgid "Cancel"
msgstr "Annuler"
@@ -716,7 +716,7 @@ msgstr "Impossible de joindre le serveur. Vérifiez votre connexion et réessaye
msgid "Could not delete"
msgstr "Suppression impossible"
#: src/components/profile/UsernameField.tsx:81
#: src/components/profile/UsernameField.tsx:76
msgid "Could not rename"
msgstr "Renommage impossible"
@@ -893,7 +893,7 @@ msgstr "Plus tôt"
#: src/components/chat/PendingItem.tsx:93
#: src/components/comment/CommentNode.tsx:256
#: src/components/playlist/PlaylistHeader.tsx:59
#: src/pages/Dump.tsx:562
#: src/pages/Dump.tsx:564
msgid "Edit"
msgstr "Modifier"
@@ -906,12 +906,12 @@ msgstr "Modifier {0}"
msgid "Edit description"
msgstr "Modifier la description"
#: src/components/profile/ProfileHeader.tsx:153
#: src/components/profile/ProfileHeader.tsx:152
msgid "Edit email"
msgstr "Modifier l'e-mail"
#: src/components/dump/create/TitleField.tsx:69
#: src/pages/Dump.tsx:460
#: src/pages/Dump.tsx:462
msgid "Edit title"
msgstr "Modifier le titre"
@@ -925,7 +925,7 @@ msgstr "modifié"
#: src/components/chat/ChatMessageItem.tsx:129
#: src/components/comment/CommentNode.tsx:205
#: src/components/playlist/PlaylistHeader.tsx:94
#: src/pages/Dump.tsx:503
#: src/pages/Dump.tsx:505
msgid "edited {0}"
msgstr "modifié {0}"
@@ -935,7 +935,7 @@ msgstr "modifié {0}"
#: src/components/chat/ChatMessageItem.tsx:125
#: src/components/comment/CommentNode.tsx:203
#: src/components/playlist/PlaylistHeader.tsx:92
#: src/pages/Dump.tsx:501
#: src/pages/Dump.tsx:503
msgid "Edited {0}"
msgstr "Modifié le {0}"
@@ -1012,7 +1012,7 @@ msgstr "Échec de l’enregistrement de la catégorie"
msgid "Failed to save edit"
msgstr "Impossible d'enregistrer la modification"
#: src/components/profile/ProfileHeader.tsx:164
#: src/components/profile/ProfileHeader.tsx:163
msgid "Failed to update avatar"
msgstr "Impossible de mettre à jour l'avatar"
@@ -1102,7 +1102,7 @@ msgstr "Si cette adresse est enregistrée, vous recevrez un lien de réinitialis
msgid "image"
msgstr "image"
#: src/pages/Dump.tsx:582
#: src/pages/Dump.tsx:584
msgid "In collections"
msgstr "Dans les collections"
@@ -1125,7 +1125,7 @@ msgstr "Lien invalide"
msgid "Invite link"
msgstr "Lien d'invitation"
#: src/components/profile/ProfileHeader.tsx:118
#: src/components/profile/ProfileHeader.tsx:117
msgid "invited by"
msgstr "invité par"
@@ -1143,7 +1143,7 @@ msgstr "Journal"
msgid "Keep editing"
msgstr "Continuer l'édition"
#: src/components/profile/UsernameField.tsx:63
#: src/components/profile/UsernameField.tsx:59
msgid "Letters, numbers and underscores only"
msgstr "Lettres, chiffres et tirets bas seulement"
@@ -1156,7 +1156,7 @@ msgid "Like"
msgstr "Aimer"
#: src/components/dump/create/DumpCreateModal.tsx:569
#: src/components/form/SlugField.tsx:70
#: src/components/form/SlugField.tsx:69
msgid "Link"
msgstr "Lien"
@@ -1164,10 +1164,6 @@ msgstr "Lien"
msgid "Link or file"
msgstr "Lien ou fichier"
#: src/components/form/SlugField.tsx:100
msgid "Links to the old address keep working."
msgstr "Les liens vers l’ancienne adresse marchent toujours."
#: src/contexts/ws/WSProvider.tsx:760
msgid "Live updates are temporarily disconnected. Trying to reconnect…"
msgstr "Les mises à jour en direct sont temporairement interrompues. Tentative de reconnexion…"
@@ -1230,7 +1226,7 @@ msgstr "Se connecter pour aimer"
msgid "Log in to vote"
msgstr "Se connecter pour voter"
#: src/components/profile/ProfileHeader.tsx:189
#: src/components/profile/ProfileHeader.tsx:188
#: src/pages/UserPublicProfile.tsx:131
msgid "Log out"
msgstr "Se déconnecter"
@@ -1243,12 +1239,12 @@ msgstr "Connexion…"
msgid "Login failed"
msgstr "Connexion échouée"
#: src/components/form/SlugField.tsx:86
#: src/components/form/SlugField.tsx:85
msgid "Lowercase letters, numbers and single hyphens only"
msgstr "Minuscules, chiffres et tirets simples seulement"
#: src/components/layout/UserMenu.tsx:98
#: src/components/profile/ProfileHeader.tsx:181
#: src/components/profile/ProfileHeader.tsx:180
#: src/pages/Manage.tsx:23
#: src/pages/Manage.tsx:30
#: src/pages/UserPublicProfile.tsx:164
@@ -1496,7 +1492,7 @@ msgstr "Piste précédente"
#: src/components/playlist/PlaylistCard.tsx:104
#: src/components/playlist/PlaylistHeader.tsx:76
#: src/components/playlist/PlaylistMembershipPanel.tsx:81
#: src/pages/Dump.tsx:509
#: src/pages/Dump.tsx:511
msgid "private"
msgstr "privé"
@@ -1539,7 +1535,7 @@ msgstr "Inscription…"
msgid "Registration failed"
msgstr "Inscription échouée"
#: src/pages/Dump.tsx:573
#: src/pages/Dump.tsx:575
msgid "Related"
msgstr "Connexe"
@@ -1559,11 +1555,11 @@ msgstr "Retirer le j'aime"
msgid "Remove vote"
msgstr "Retirer le vote"
#: src/components/profile/UsernameField.tsx:72
#: src/components/profile/UsernameField.tsx:68
msgid "Rename"
msgstr "Renommer"
#: src/components/profile/UsernameField.tsx:69
#: src/components/profile/UsernameField.tsx:65
msgid "Renaming…"
msgstr "Renommage…"
@@ -1619,7 +1615,7 @@ msgstr "Rôle"
#: src/components/playlist/PlaylistEditForm.tsx:225
#: src/components/profile/DescriptionEditor.tsx:89
#: src/components/profile/EmailEditor.tsx:75
#: src/pages/Dump.tsx:436
#: src/pages/Dump.tsx:437
#: src/pages/DumpEdit.tsx:573
msgid "Save"
msgstr "Enregistrer"
@@ -1629,7 +1625,7 @@ msgstr "Enregistrer"
#: src/components/profile/ChangePasswordModal.tsx:119
#: src/components/profile/DescriptionEditor.tsx:86
#: src/components/profile/EmailEditor.tsx:72
#: src/pages/Dump.tsx:435
#: src/pages/Dump.tsx:436
#: src/pages/ResetPassword.tsx:139
msgid "Saving…"
msgstr "Enregistrement…"
@@ -1687,7 +1683,7 @@ msgid "Set new password"
msgstr "Définir un nouveau mot de passe"
#: src/components/layout/UserMenu.tsx:89
#: src/components/profile/ProfileHeader.tsx:177
#: src/components/profile/ProfileHeader.tsx:176
#: src/pages/Settings.tsx:69
#: src/pages/Settings.tsx:83
msgid "Settings"
@@ -1752,10 +1748,6 @@ msgstr "L'image n'a pas pu être envoyée."
msgid "The new order couldn't be saved. Try again."
msgstr "Le nouvel ordre n'a pas pu être enregistré. Réessayez."
#: src/components/profile/ProfileManageTab.tsx:67
msgid "Their old name keeps leading to them, and nobody else can take it."
msgstr "Son ancien nom mène toujours à son profil, et personne d’autre ne peut le prendre."
#: src/components/comment/CommentNode.tsx:282
msgid "This comment couldn't be deleted. Try again."
msgstr "Ce commentaire n'a pas pu être supprimé. Réessayez."
@@ -1912,7 +1904,7 @@ msgid "User menu"
msgstr "Menu utilisateur"
#: src/components/profile/ProfileManageTab.tsx:61
#: src/components/profile/UsernameField.tsx:55
#: src/components/profile/UsernameField.tsx:51
#: src/pages/Settings.tsx:88
#: src/pages/UserLogin.tsx:75
#: src/pages/UserRegister.tsx:137

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>