feat(frontend): unlisted toggle on member editor

This commit is contained in:
sam 2024-11-25 21:25:18 +01:00
parent c237aa8827
commit 004111feb6
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
4 changed files with 186 additions and 137 deletions

View file

@ -1,136 +1,138 @@
{ {
"hello": "Hello, {{name}}!", "hello": "Hello, {{name}}!",
"nav": { "nav": {
"log-in": "Log in or sign up", "log-in": "Log in or sign up",
"settings": "Settings" "settings": "Settings"
}, },
"avatar-tooltip": "Avatar for {{name}}", "avatar-tooltip": "Avatar for {{name}}",
"profile": { "profile": {
"edit-member-profile-notice": "You are currently viewing the public profile of {{memberName}}.", "edit-member-profile-notice": "You are currently viewing the public profile of {{memberName}}.",
"edit-user-profile-notice": "You are currently viewing your public profile.", "edit-user-profile-notice": "You are currently viewing your public profile.",
"edit-profile-link": "Edit profile", "edit-profile-link": "Edit profile",
"names-header": "Names", "names-header": "Names",
"pronouns-header": "Pronouns", "pronouns-header": "Pronouns",
"default-members-header": "Members", "default-members-header": "Members",
"create-member-button": "Create member", "create-member-button": "Create member",
"back-to-user": "Back to {{name}}" "back-to-user": "Back to {{name}}"
}, },
"title": { "title": {
"log-in": "Log in", "log-in": "Log in",
"welcome": "Welcome", "welcome": "Welcome",
"settings": "Settings" "settings": "Settings"
}, },
"auth": { "auth": {
"log-in-form-title": "Log in with email", "log-in-form-title": "Log in with email",
"log-in-form-email-label": "Email address", "log-in-form-email-label": "Email address",
"log-in-form-password-label": "Password", "log-in-form-password-label": "Password",
"register-with-email-button": "Register with email", "register-with-email-button": "Register with email",
"log-in-button": "Log in", "log-in-button": "Log in",
"log-in-3rd-party-header": "Log in with another service", "log-in-3rd-party-header": "Log in with another service",
"log-in-3rd-party-desc": "If you prefer, you can also log in with one of these services:", "log-in-3rd-party-desc": "If you prefer, you can also log in with one of these services:",
"log-in-with-discord": "Log in with Discord", "log-in-with-discord": "Log in with Discord",
"log-in-with-google": "Log in with Google", "log-in-with-google": "Log in with Google",
"log-in-with-tumblr": "Log in with Tumblr", "log-in-with-tumblr": "Log in with Tumblr",
"log-in-with-the-fediverse": "Log in with the Fediverse", "log-in-with-the-fediverse": "Log in with the Fediverse",
"remote-fediverse-account-label": "Your Fediverse account", "remote-fediverse-account-label": "Your Fediverse account",
"register-username-label": "Username", "register-username-label": "Username",
"register-button": "Register account", "register-button": "Register account",
"register-with-mastodon": "Register with a Fediverse account", "register-with-mastodon": "Register with a Fediverse account",
"log-in-with-fediverse-error-blurb": "Is your instance returning an error?", "log-in-with-fediverse-error-blurb": "Is your instance returning an error?",
"log-in-with-fediverse-force-refresh-button": "Force a refresh on our end" "log-in-with-fediverse-force-refresh-button": "Force a refresh on our end"
}, },
"error": { "error": {
"bad-request-header": "Something was wrong with your input", "bad-request-header": "Something was wrong with your input",
"generic-header": "Something went wrong", "generic-header": "Something went wrong",
"raw-header": "Raw error", "raw-header": "Raw error",
"authentication-error": "Something went wrong when logging you in.", "authentication-error": "Something went wrong when logging you in.",
"bad-request": "Your input was rejected by the server, please check for any mistakes and try again.", "bad-request": "Your input was rejected by the server, please check for any mistakes and try again.",
"forbidden": "You are not allowed to perform that action.", "forbidden": "You are not allowed to perform that action.",
"internal-server-error": "Server experienced an internal error, please try again later.", "internal-server-error": "Server experienced an internal error, please try again later.",
"authentication-required": "You need to log in first.", "authentication-required": "You need to log in first.",
"missing-scopes": "The current token is missing a required scope. Did you manually edit your cookies?", "missing-scopes": "The current token is missing a required scope. Did you manually edit your cookies?",
"generic-error": "An unknown error occurred.", "generic-error": "An unknown error occurred.",
"user-not-found": "User not found, please check your spelling and try again. Remember that usernames are case sensitive.", "user-not-found": "User not found, please check your spelling and try again. Remember that usernames are case sensitive.",
"member-not-found": "Member not found, please check your spelling and try again.", "member-not-found": "Member not found, please check your spelling and try again.",
"account-already-linked": "This account is already linked with a pronouns.cc account.", "account-already-linked": "This account is already linked with a pronouns.cc account.",
"last-auth-method": "You cannot remove your last authentication method.", "last-auth-method": "You cannot remove your last authentication method.",
"validation-max-length-error": "Value is too long, maximum length is {{max}}, current length is {{actual}}.", "validation-max-length-error": "Value is too long, maximum length is {{max}}, current length is {{actual}}.",
"validation-min-length-error": "Value is too long, minimum length is {{min}}, current length is {{actual}}.", "validation-min-length-error": "Value is too long, minimum length is {{min}}, current length is {{actual}}.",
"validation-disallowed-value-1": "The following value is not allowed here", "validation-disallowed-value-1": "The following value is not allowed here",
"validation-disallowed-value-2": "Allowed values are", "validation-disallowed-value-2": "Allowed values are",
"validation-reason": "Reason", "validation-reason": "Reason",
"validation-generic": "The value you entered is not allowed here. Reason", "validation-generic": "The value you entered is not allowed here. Reason",
"extra-info-header": "Extra error information", "extra-info-header": "Extra error information",
"noscript-title": "This page requires JavaScript", "noscript-title": "This page requires JavaScript",
"noscript-info": "This page requires JavaScript to function correctly. Some buttons may not work, or the page may not work at all.", "noscript-info": "This page requires JavaScript to function correctly. Some buttons may not work, or the page may not work at all.",
"noscript-short": "Requires JavaScript" "noscript-short": "Requires JavaScript"
}, },
"settings": { "settings": {
"general-information-tab": "General information", "general-information-tab": "General information",
"your-profile-tab": "Your profile", "your-profile-tab": "Your profile",
"members-tab": "Members", "members-tab": "Members",
"authentication-tab": "Authentication", "authentication-tab": "Authentication",
"export-tab": "Export your data", "export-tab": "Export your data",
"change-username-button": "Change username", "change-username-button": "Change username",
"username-change-hint": "Changing your username will make any existing links to your or your members' profiles invalid.\nYour username must be unique, be at most 40 characters long, and only contain letters from the basic English alphabet, dashes, underscores, and periods. Your username is used as part of your profile link, you can set a separate display name.", "username-change-hint": "Changing your username will make any existing links to your or your members' profiles invalid.\nYour username must be unique, be at most 40 characters long, and only contain letters from the basic English alphabet, dashes, underscores, and periods. Your username is used as part of your profile link, you can set a separate display name.",
"username-update-error": "Could not update your username as the new username is invalid:\n{{message}}", "username-update-error": "Could not update your username as the new username is invalid:\n{{message}}",
"change-avatar-link": "Change your avatar here", "change-avatar-link": "Change your avatar here",
"new-username": "New username", "new-username": "New username",
"table-role": "Role", "table-role": "Role",
"table-custom-preferences": "Custom preferences", "table-custom-preferences": "Custom preferences",
"table-member-list-hidden": "Member list hidden?", "table-member-list-hidden": "Member list hidden?",
"table-member-count": "Member count", "table-member-count": "Member count",
"table-created-at": "Account created at", "table-created-at": "Account created at",
"table-id": "Your ID", "table-id": "Your ID",
"table-title": "Account information", "table-title": "Account information",
"force-log-out-title": "Log out everywhere", "force-log-out-title": "Log out everywhere",
"force-log-out-button": "Force log out", "force-log-out-button": "Force log out",
"force-log-out-hint": "If you think one of your tokens might have been compromised, you can log out on all devices by clicking this button.", "force-log-out-hint": "If you think one of your tokens might have been compromised, you can log out on all devices by clicking this button.",
"log-out-title": "Log out", "log-out-title": "Log out",
"log-out-hint": "Use this button to log out on this device only.", "log-out-hint": "Use this button to log out on this device only.",
"log-out-button": "Log out", "log-out-button": "Log out",
"avatar": "Avatar", "avatar": "Avatar",
"username-update-success": "Successfully changed your username!", "username-update-success": "Successfully changed your username!",
"create-member-title": "Create a new member", "create-member-title": "Create a new member",
"create-member-name-label": "Member name" "create-member-name-label": "Member name"
}, },
"yes": "Yes", "yes": "Yes",
"no": "No", "no": "No",
"edit-profile": { "edit-profile": {
"user-header": "Editing your profile", "user-header": "Editing your profile",
"general-tab": "General", "general-tab": "General",
"names-pronouns-tab": "Names & pronouns", "names-pronouns-tab": "Names & pronouns",
"file-too-large": "This file is too large, please resize it (maximum is {{max}}, the file you're trying to upload is {{current}})", "file-too-large": "This file is too large, please resize it (maximum is {{max}}, the file you're trying to upload is {{current}})",
"sid-current": "Current short ID:", "sid-current": "Current short ID:",
"sid": "Short ID", "sid": "Short ID",
"sid-reroll": "Reroll short ID", "sid-reroll": "Reroll short ID",
"sid-hint": "This ID is used in prns.cc links. You can reroll one short ID every hour (shared between your main profile and all members) by pressing the button above.", "sid-hint": "This ID is used in prns.cc links. You can reroll one short ID every hour (shared between your main profile and all members) by pressing the button above.",
"sid-copy": "Copy short link", "sid-copy": "Copy short link",
"update-avatar": "Update avatar", "update-avatar": "Update avatar",
"avatar-updated": "Avatar updated! It might take a moment to be reflected on your profile.", "avatar-updated": "Avatar updated! It might take a moment to be reflected on your profile.",
"member-header-label": "\"Members\" header text", "member-header-label": "\"Members\" header text",
"member-header-info": "This is the text used for the \"Members\" heading. If you leave it blank, the default text will be used.", "member-header-info": "This is the text used for the \"Members\" heading. If you leave it blank, the default text will be used.",
"hide-member-list-label": "Hide member list", "hide-member-list-label": "Hide member list",
"timezone-label": "Timezone", "timezone-label": "Timezone",
"timezone-preview": "This will show up on your profile like this:", "timezone-preview": "This will show up on your profile like this:",
"timezone-info": "This is optional. Your timezone is never shared directly, only the difference between UTC and your current timezone is.", "timezone-info": "This is optional. Your timezone is never shared directly, only the difference between UTC and your current timezone is.",
"hide-member-list-info": "This only hides your member list. Individual members will still be visible to anyone with a direct link to their pages.", "hide-member-list-info": "This only hides your member list. Individual members will still be visible to anyone with a direct link to their pages.",
"profile-options-header": "Profile options", "profile-options-header": "Profile options",
"bio-tab": "Bio", "bio-tab": "Bio",
"saved-changes": "Successfully saved changes!", "saved-changes": "Successfully saved changes!",
"bio-length-hint": "Using {{length}}/{{maxLength}} characters", "bio-length-hint": "Using {{length}}/{{maxLength}} characters",
"preview": "Preview", "preview": "Preview",
"fields-tab": "Fields", "fields-tab": "Fields",
"flags-links-tab": "Flags & links", "flags-links-tab": "Flags & links",
"back-to-settings-tab": "Back to settings", "back-to-settings-tab": "Back to settings",
"member-header": "Editing member {{name}}", "member-header": "Editing member {{name}}",
"username": "Username", "username": "Username",
"change-username-info": "As changing your username will also change all of your members' links, you can only change it in your account settings.", "change-username-info": "As changing your username will also change all of your members' links, you can only change it in your account settings.",
"change-username-link": "Go to settings", "change-username-link": "Go to settings",
"member-name": "Name", "member-name": "Name",
"change-member-name": "Change name", "change-member-name": "Change name",
"display-name": "Display name" "display-name": "Display name",
}, "unlisted-label": "Hide from member list",
"save-changes": "Save changes", "unlisted-note": "This only hides this member from your public member list. They will still be visible to anyone at this link:"
"change": "Change" },
"save-changes": "Save changes",
"change": "Change"
} }

View file

@ -25,7 +25,7 @@
<OwnProfileNotice editLink="/settings/profile" /> <OwnProfileNotice editLink="/settings/profile" />
{/if} {/if}
<ProfileHeader name="@{data.user.username}" profile={data.user}/> <ProfileHeader name="@{data.user.username}" profile={data.user} />
<ProfileFields profile={data.user} {allPreferences} /> <ProfileFields profile={data.user} {allPreferences} />
{#if data.members.length > 0} {#if data.members.length > 0}

View file

@ -79,4 +79,21 @@ export const actions = {
throw e; throw e;
} }
}, },
options: async ({ params, request, fetch, cookies }) => {
const body = await request.formData();
let unlisted = !!body.get("unlisted");
try {
await fastRequest("PATCH", `/users/@me/members/${params.id}`, {
body: { unlisted },
fetch,
cookies,
});
return { error: null, ok: true };
} catch (e) {
if (e instanceof ApiError) return { error: e.obj, ok: false };
log.error("Error patching member %s:", params.id, e);
throw e;
}
},
}; };

View file

@ -5,7 +5,7 @@
import { apiRequest, fastRequest } from "$api"; import { apiRequest, fastRequest } from "$api";
import ApiError from "$api/error"; import ApiError from "$api/error";
import log from "$lib/log"; import log from "$lib/log";
import { InputGroup } from "@sveltestrap/sveltestrap"; import { Icon, InputGroup } from "@sveltestrap/sveltestrap";
import { t } from "$lib/i18n"; import { t } from "$lib/i18n";
import AvatarEditor from "$components/editor/AvatarEditor.svelte"; import AvatarEditor from "$components/editor/AvatarEditor.svelte";
import ErrorAlert from "$components/ErrorAlert.svelte"; import ErrorAlert from "$components/ErrorAlert.svelte";
@ -13,6 +13,7 @@
import FormStatusMarker from "$components/editor/FormStatusMarker.svelte"; import FormStatusMarker from "$components/editor/FormStatusMarker.svelte";
import SidEditor from "$components/editor/SidEditor.svelte"; import SidEditor from "$components/editor/SidEditor.svelte";
import BioEditor from "$components/editor/BioEditor.svelte"; import BioEditor from "$components/editor/BioEditor.svelte";
import { PUBLIC_BASE_URL } from "$env/static/public";
type Props = { data: PageData; form: ActionData }; type Props = { data: PageData; form: ActionData };
let { data, form }: Props = $props(); let { data, form }: Props = $props();
@ -106,7 +107,36 @@
<h4>{$t("edit-profile.sid")}</h4> <h4>{$t("edit-profile.sid")}</h4>
<SidEditor {rerollSid} {sid} {canRerollSid} /> <SidEditor {rerollSid} {sid} {canRerollSid} />
</div> </div>
<div class="row"> <div class="row mb-3">
<h4>{$t("edit-profile.profile-options-header")}</h4>
<form method="POST" action="?/options">
<div class="form-check">
<input
class="form-check-input"
type="checkbox"
checked={data.member.unlisted}
value="true"
name="unlisted"
id="unlisted"
/>
<label class="form-check-label" for="unlisted">
{$t("edit-profile.unlisted-label")}
</label>
</div>
<p class="text-muted mt-1">
<Icon name="info-circle-fill" aria-hidden />
{$t("edit-profile.unlisted-note")}
<code>
{PUBLIC_BASE_URL.substring("https://".length)}/@{data.member.user.username}/{data.member
.name}
</code>
</p>
<div class="mt-2">
<button type="submit" class="btn btn-primary">{$t("save-changes")}</button>
</div>
</form>
</div>
<div class="row mb-3">
<h4>{$t("edit-profile.bio-tab")}</h4> <h4>{$t("edit-profile.bio-tab")}</h4>
<form method="POST" action="?/bio"> <form method="POST" action="?/bio">
<BioEditor bind:value={bio} maxLength={data.meta.limits.bio_length} /> <BioEditor bind:value={bio} maxLength={data.meta.limits.bio_length} />