mirror of
https://github.com/zadam/trilium.git
synced 2025-10-21 07:38:53 +02:00
feat(react/settings): port protected session timeout
This commit is contained in:
parent
ccf52be431
commit
227cf5de85
@ -61,13 +61,13 @@ export default function TimeSelector({ name, label, includedTimeScales, optionVa
|
||||
|
||||
let time = parseInt(value, 10);
|
||||
const minimumSecondsOrDefault = (minimumSeconds ?? 0);
|
||||
const newTime = convertTime(time, scale).toOption();
|
||||
|
||||
if (Number.isNaN(time) || time < (minimumSecondsOrDefault)) {
|
||||
if (Number.isNaN(time) || newTime < (minimumSecondsOrDefault)) {
|
||||
toast.showError(t("time_selector.minimum_input", { minimumSeconds: minimumSecondsOrDefault }));
|
||||
time = minimumSecondsOrDefault;
|
||||
}
|
||||
|
||||
const newTime = convertTime(time, scale).toOption();
|
||||
setValue(newTime);
|
||||
}}
|
||||
/>
|
||||
|
@ -11,6 +11,8 @@ import OptionsSection from "./components/OptionsSection"
|
||||
import protected_session_holder from "../../../services/protected_session_holder"
|
||||
import { ChangePasswordResponse } from "@triliumnext/commons"
|
||||
import dialog from "../../../services/dialog"
|
||||
import TimeSelector from "./components/TimeSelector"
|
||||
import FormText from "../../react/FormText"
|
||||
|
||||
export default function PasswordSettings() {
|
||||
return (
|
||||
@ -106,9 +108,18 @@ function ChangePassword() {
|
||||
function ProtectedSessionTimeout() {
|
||||
return (
|
||||
<OptionsSection title={t("password.protected_session_timeout")}>
|
||||
{t("password.protected_session_timeout_description")}
|
||||
|
||||
<a class="tn-link" href="https://triliumnext.github.io/Docs/Wiki/protected-notes.html" className="external">{t("password.wiki")}</a> {t("password.for_more_info")}
|
||||
<FormText>
|
||||
{t("password.protected_session_timeout_description")}
|
||||
|
||||
<a class="tn-link" href="https://triliumnext.github.io/Docs/Wiki/protected-notes.html" className="external">{t("password.wiki")}</a> {t("password.for_more_info")}
|
||||
</FormText>
|
||||
|
||||
<TimeSelector
|
||||
name="protected-session-timeout"
|
||||
label={t("password.protected_session_timeout_label")}
|
||||
optionValueId="protectedSessionTimeout" optionTimeScaleId="protectedSessionTimeoutTimeScale"
|
||||
minimumSeconds={60}
|
||||
/>
|
||||
</OptionsSection>
|
||||
)
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
import TimeSelector from "../time_selector.js";
|
||||
|
||||
const TPL = /*html*/`
|
||||
<div class="options-section">
|
||||
<p class="form-text">
|
||||
|
||||
</p>
|
||||
<div id="time-selector-placeholder"></div>
|
||||
</div>`;
|
||||
|
||||
export default class ProtectedSessionTimeoutOptions extends TimeSelector {
|
||||
constructor() {
|
||||
super({
|
||||
widgetId: "protected-session-timeout",
|
||||
widgetLabelId: "password.protected_session_timeout_label",
|
||||
optionValueId: "protectedSessionTimeout",
|
||||
optionTimeScaleId: "protectedSessionTimeoutTimeScale",
|
||||
minimumSeconds: 60
|
||||
});
|
||||
super.doRender();
|
||||
}
|
||||
|
||||
doRender() {
|
||||
const $timeSelector = this.$widget;
|
||||
// inject TimeSelector widget template
|
||||
this.$widget = $(TPL);
|
||||
this.$widget.find("#time-selector-placeholder").replaceWith($timeSelector);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user