diff --git a/server/server.go b/server/server.go index 26bb8cf4..f8c3655c 100644 --- a/server/server.go +++ b/server/server.go @@ -49,10 +49,7 @@ import ( - "mute" setting - figure out what settings are "web" or "phone" UI: - - Translations - - aria-labels - Home UI sign-in/login to top right - - rate limiting: - login/account endpoints Tests: diff --git a/web/public/static/langs/en.json b/web/public/static/langs/en.json index 523aea30..f6908243 100644 --- a/web/public/static/langs/en.json +++ b/web/public/static/langs/en.json @@ -1,4 +1,17 @@ { + "signup_title": "Create a ntfy account", + "signup_form_username": "Username", + "signup_form_password": "Password", + "signup_form_confirm_password": "Confirm password", + "signup_form_button_submit": "Sign up", + "signup_already_have_account": "Already have an account? Sign in!", + "signup_disabled": "Signup is disabled", + "signup_error_username_taken": "Username {{username}} is already taken", + "signup_error_creation_limit_reached": "Account creation limit reached", + "signup_error_unknown": "Unknown error. Check logs for details.", + "login_title": "Sign in to your ntfy account", + "login_form_button_submit": "Sign in", + "login_link_signup": "Sign up", "action_bar_show_menu": "Show menu", "action_bar_logo_alt": "ntfy logo", "action_bar_settings": "Settings", diff --git a/web/src/components/Account.js b/web/src/components/Account.js index 304272ad..f7d22606 100644 --- a/web/src/components/Account.js +++ b/web/src/components/Account.js @@ -21,6 +21,7 @@ import IconButton from "@mui/material/IconButton"; import {useOutletContext} from "react-router-dom"; import {formatBytes} from "../app/utils"; import accountApi, {UnauthorizedError} from "../app/AccountApi"; +import {Pref, PrefGroup} from "./Pref"; const Account = () => { if (!session.exists()) { @@ -56,9 +57,11 @@ const Basics = () => { const Username = () => { const { t } = useTranslation(); const { account } = useOutletContext(); + const labelId = "prefUsername"; + return ( - -
+ +
{session.username()} {account?.role === "admin" ? <>{" "}👑 @@ -72,6 +75,7 @@ const ChangePassword = () => { const { t } = useTranslation(); const [dialogKey, setDialogKey] = useState(0); const [dialogOpen, setDialogOpen] = useState(false); + const labelId = "prefChangePassword"; const handleDialogOpen = () => { setDialogKey(prev => prev+1); @@ -97,8 +101,8 @@ const ChangePassword = () => { }; return ( - -
+ +
⬤⬤⬤⬤⬤⬤⬤⬤⬤⬤ @@ -302,55 +306,4 @@ const DeleteAccountDialog = (props) => { ); }; - -// FIXME duplicate code - -const PrefGroup = (props) => { - return ( -
- {props.children} -
- ) -}; - -const Pref = (props) => { - return ( -
-
-
{props.title}{props.subtitle && ({props.subtitle})}
- {props.description &&
{props.description}
} -
-
- {props.children} -
-
- ); -}; - export default Account; diff --git a/web/src/components/Login.js b/web/src/components/Login.js index fe3fc949..dd6456b9 100644 --- a/web/src/components/Login.js +++ b/web/src/components/Login.js @@ -46,7 +46,7 @@ const Login = () => { return ( - {t("Sign in to your ntfy account")} + {t("login_title")} { required fullWidth id="username" - label={t("Username")} + label={t("signup_form_username")} name="username" value={username} onChange={ev => setUsername(ev.target.value.trim())} @@ -65,7 +65,7 @@ const Login = () => { required fullWidth name="password" - label={t("Password")} + label={t("signup_form_password")} type="password" id="password" value={password} @@ -79,7 +79,7 @@ const Login = () => { disabled={username === "" || password === ""} sx={{mt: 2, mb: 2}} > - {t("Sign in")} + {t("login_form_button_submit")} {error && { } {config.enableResetPassword &&
{t("Reset password")}
} - {config.enableSignup &&
{t("Sign up")}
} + {config.enableSignup &&
{t("login_link_signup")}
}
diff --git a/web/src/components/Pref.js b/web/src/components/Pref.js new file mode 100644 index 00000000..0a065ac9 --- /dev/null +++ b/web/src/components/Pref.js @@ -0,0 +1,50 @@ +import * as React from "react"; + +export const PrefGroup = (props) => { + return ( +
+ {props.children} +
+ ) +}; + +export const Pref = (props) => { + return ( +
+
+
{props.title}{props.subtitle && ({props.subtitle})}
+ {props.description &&
{props.description}
} +
+
+ {props.children} +
+
+ ); +}; diff --git a/web/src/components/Preferences.js b/web/src/components/Preferences.js index b1dcc26e..5397aafa 100644 --- a/web/src/components/Preferences.js +++ b/web/src/components/Preferences.js @@ -37,6 +37,7 @@ import {useTranslation} from "react-i18next"; import session from "../app/Session"; import routes from "./routes"; import accountApi, {UnauthorizedError} from "../app/AccountApi"; +import {Pref, PrefGroup} from "./Pref"; const Preferences = () => { return ( @@ -191,55 +192,6 @@ const DeleteAfter = () => { ) }; -const PrefGroup = (props) => { - return ( -
- {props.children} -
- ) -}; - -const Pref = (props) => { - return ( -
-
-
{props.title}
- {props.description &&
{props.description}
} -
-
- {props.children} -
-
- ); -}; - const Users = () => { const { t } = useTranslation(); const [dialogKey, setDialogKey] = useState(0); diff --git a/web/src/components/Signup.js b/web/src/components/Signup.js index e01c4d2d..82b806e6 100644 --- a/web/src/components/Signup.js +++ b/web/src/components/Signup.js @@ -30,27 +30,27 @@ const Signup = () => { } catch (e) { console.log(`[Signup] Signup for user ${user.username} failed`, e); if ((e instanceof UsernameTakenError)) { - setError(t("Username {{username}} is already taken", { username: e.username })); + setError(t("signup_error_username_taken", { username: e.username })); } else if ((e instanceof AccountCreateLimitReachedError)) { - setError(t("Account creation limit reached")); + setError(t("signup_error_creation_limit_reached")); } else if (e.message) { setError(e.message); } else { - setError(t("Unknown error. Check logs for details.")) + setError(t("signup_error_unknown")) } } }; if (!config.enableSignup) { return ( - {t("Signup is disabled")} + {t("signup_disabled")} ); } return ( - {t("Create a ntfy account")} + {t("signup_title")} { required fullWidth id="username" - label="Username" + label={t("signup_form_username")} name="username" value={username} onChange={ev => setUsername(ev.target.value.trim())} @@ -69,7 +69,7 @@ const Signup = () => { required fullWidth name="password" - label="Password" + label={t("signup_form_password")} type="password" id="password" autoComplete="current-password" @@ -81,7 +81,7 @@ const Signup = () => { required fullWidth name="confirm-password" - label="Confirm password" + label={t("signup_form_confirm_password")} type="password" id="confirm-password" value={confirm} @@ -95,7 +95,7 @@ const Signup = () => { disabled={username === "" || password === "" || password !== confirm} sx={{mt: 2, mb: 2}} > - {t("Sign up")} + {t("signup_form_button_submit")} {error && { {config.enableLogin && - {t("Already have an account? Sign in!")} + {t("signup_already_have_account")} }