1
0
Fork 0

run limter

This commit is contained in:
ChaotiCryptidz 2022-01-22 13:11:54 +00:00
parent 634292cb8b
commit e116cbf81b
31 changed files with 109 additions and 161 deletions

View file

@ -1,17 +1,10 @@
import { JSX, RefObject } from "preact";
import { InputProps } from "./InputProps"; import { InputProps } from "./InputProps";
import { JSX, RefObject } from "preact";
type CheckboxProps = InputProps & { type CheckboxProps = InputProps & {
checkboxRef?: RefObject<HTMLInputElement>; checkboxRef?: RefObject<HTMLInputElement>;
} };
export function Checkbox(props: CheckboxProps): JSX.Element { export function Checkbox(props: CheckboxProps): JSX.Element {
return ( return <input class="uk-checkbox" type="checkbox" ref={props.checkboxRef} {...props} />;
<input
class="uk-checkbox"
type="checkbox"
ref={props.checkboxRef}
{...props}
/>
)
} }

View file

@ -5,5 +5,4 @@ export type InputProps = {
onChange?: () => void; onChange?: () => void;
required?: boolean; required?: boolean;
checked?: boolean; checked?: boolean;
extraProps?: {}; };
}

View file

@ -1,17 +1,12 @@
import { JSX, RefObject } from "preact";
import { InputProps } from "./InputProps"; import { InputProps } from "./InputProps";
import { JSX, RefObject } from "preact";
type NumberInputProps = InputProps & { type NumberInputProps = InputProps & {
inputRef?: RefObject<HTMLInputElement>; inputRef?: RefObject<HTMLInputElement>;
} };
export function NumberInput(props: NumberInputProps): JSX.Element { export function NumberInput(props: NumberInputProps): JSX.Element {
return ( return (
<input <input class="uk-input uk-form-width-medium" type="number" ref={props.inputRef} {...props} />
class="uk-input uk-form-width-medium" );
type="number"
ref={props.inputRef}
{...props}
/>
)
} }

View file

@ -1,17 +1,12 @@
import { JSX, RefObject } from "preact";
import { InputProps } from "./InputProps"; import { InputProps } from "./InputProps";
import { JSX, RefObject } from "preact";
type PasswordInputProps = InputProps & { type PasswordInputProps = InputProps & {
inputRef?: RefObject<HTMLInputElement>; inputRef?: RefObject<HTMLInputElement>;
} };
export function PasswordInput(props: PasswordInputProps): JSX.Element { export function PasswordInput(props: PasswordInputProps): JSX.Element {
return ( return (
<input <input class="uk-input uk-form-width-medium" type="password" ref={props.inputRef} {...props} />
class="uk-input uk-form-width-medium" );
type="password"
ref={props.inputRef}
{...props}
/>
)
} }

View file

@ -1,33 +1,29 @@
import { JSX, RefObject } from "preact";
import { InputProps } from "./InputProps"; import { InputProps } from "./InputProps";
import { JSX, RefObject } from "preact";
type SelectProps = InputProps & { type SelectProps = InputProps & {
selectRef?: RefObject<HTMLSelectElement>; selectRef?: RefObject<HTMLSelectElement>;
children?: JSX.Element | JSX.Element[]; children?: JSX.Element | JSX.Element[];
} };
export function Select(props: SelectProps): JSX.Element { export function Select(props: SelectProps): JSX.Element {
return ( return (
<select <select class="uk-select uk-form-width-medium" ref={props.selectRef} {...props}>
class="uk-select uk-form-width-medium"
ref={props.selectRef}
{...props}
>
{props.children} {props.children}
</select> </select>
) );
} }
type SelectOptionProps = { type SelectOptionProps = {
name: string; name: string;
value: string; value: string;
selected?: boolean; selected?: boolean;
} };
export function SelectOption(props: SelectOptionProps): JSX.Element { export function SelectOption(props: SelectOptionProps): JSX.Element {
return ( return (
<option label={props.name} value={props.value} selected={props.selected}> <option label={props.name} value={props.value} selected={props.selected}>
{props.name} {props.name}
</option> </option>
) );
} }

View file

@ -1,16 +1,12 @@
import { JSX, RefObject } from "preact";
import { InputProps } from "./InputProps"; import { InputProps } from "./InputProps";
import { JSX, RefObject } from "preact";
type TextInputProps = InputProps & { type TextInputProps = InputProps & {
textAreaRef?: RefObject<HTMLInputElement>; textAreaRef?: RefObject<HTMLInputElement>;
} };
export function TextArea(props: TextInputProps): JSX.Element { export function TextArea(props: TextInputProps): JSX.Element {
return ( return (
<textarea <textarea class="uk-textarea uk-form-width-medium" textAreaRef={props.textAreaRef} {...props} />
class="uk-textarea uk-form-width-medium" );
textAreaRef={props.textAreaRef}
{...props}
/>
)
} }

View file

@ -1,17 +1,12 @@
import { JSX, RefObject } from "preact";
import { InputProps } from "./InputProps"; import { InputProps } from "./InputProps";
import { JSX, RefObject } from "preact";
type TextInputProps = InputProps & { type TextInputProps = InputProps & {
inputRef?: RefObject<HTMLInputElement>; inputRef?: RefObject<HTMLInputElement>;
} };
export function TextInput(props: TextInputProps): JSX.Element { export function TextInput(props: TextInputProps): JSX.Element {
return ( return (
<input <input class="uk-input uk-form-width-medium" type="text" ref={props.inputRef} {...props} />
class="uk-input uk-form-width-medium" );
type="text"
ref={props.inputRef}
{...props}
/>
)
} }

View file

@ -1,4 +1,5 @@
import { Button } from "../../../../elements/Button"; import { Button } from "../../../../elements/Button";
import { Checkbox } from "../../../../elements/forms/Checkbox";
import { Component, createRef } from "preact"; import { Component, createRef } from "preact";
import { DefaultPageProps } from "../../../../../types/DefaultPageProps"; import { DefaultPageProps } from "../../../../../types/DefaultPageProps";
import { ErrorMessage, sendErrorNotification } from "../../../../elements/ErrorMessage"; import { ErrorMessage, sendErrorNotification } from "../../../../elements/ErrorMessage";
@ -6,16 +7,15 @@ import { Form } from "../../../../elements/forms/Form";
import { InputWithTitle } from "../../../../elements/InputWithTitle"; import { InputWithTitle } from "../../../../elements/InputWithTitle";
import { Margin } from "../../../../elements/Margin"; import { Margin } from "../../../../elements/Margin";
import { MarginInline } from "../../../../elements/MarginInline"; import { MarginInline } from "../../../../elements/MarginInline";
import { NumberInput } from "../../../../elements/forms/NumberInput";
import { PageTitle } from "../../../../elements/PageTitle"; import { PageTitle } from "../../../../elements/PageTitle";
import { PasswordInput } from "../../../../elements/forms/PasswordInput";
import { TextInput } from "../../../../elements/forms/TextInput";
import { UserType } from "../../../../../api/types/user"; import { UserType } from "../../../../../api/types/user";
import { route } from "preact-router"; import { route } from "preact-router";
import { toStr } from "../../../../../utils"; import { toStr } from "../../../../../utils";
import { userPassUserViewURL } from "../../../pageLinks"; import { userPassUserViewURL } from "../../../pageLinks";
import i18next from "i18next"; import i18next from "i18next";
import { PasswordInput } from "../../../../elements/forms/PasswordInput";
import { TextInput } from "../../../../elements/forms/TextInput";
import { NumberInput } from "../../../../elements/forms/NumberInput";
import { Checkbox } from "../../../../elements/forms/Checkbox";
const removeEmptyStrings = (arr: string[]) => arr.filter((e) => e.length > 0); const removeEmptyStrings = (arr: string[]) => arr.filter((e) => e.length > 0);

View file

@ -3,16 +3,16 @@ import { Component, createRef } from "preact";
import { DefaultPageProps } from "../../../../../types/DefaultPageProps"; import { DefaultPageProps } from "../../../../../types/DefaultPageProps";
import { ErrorMessage } from "../../../../elements/ErrorMessage"; import { ErrorMessage } from "../../../../elements/ErrorMessage";
import { Form } from "../../../../elements/forms/Form"; import { Form } from "../../../../elements/forms/Form";
import { InputWithTitle } from "../../../../elements/InputWithTitle";
import { Margin } from "../../../../elements/Margin"; import { Margin } from "../../../../elements/Margin";
import { MarginInline } from "../../../../elements/MarginInline"; import { MarginInline } from "../../../../elements/MarginInline";
import { PageTitle } from "../../../../elements/PageTitle"; import { PageTitle } from "../../../../elements/PageTitle";
import { PasswordInput } from "../../../../elements/forms/PasswordInput";
import { TextInput } from "../../../../elements/forms/TextInput";
import { UserType } from "../../../../../api/types/user"; import { UserType } from "../../../../../api/types/user";
import { route } from "preact-router"; import { route } from "preact-router";
import { userPassUserViewURL } from "../../../pageLinks"; import { userPassUserViewURL } from "../../../pageLinks";
import i18next from "i18next"; import i18next from "i18next";
import { TextInput } from "../../../../elements/forms/TextInput";
import { InputWithTitle } from "../../../../elements/InputWithTitle";
import { PasswordInput } from "../../../../elements/forms/PasswordInput";
export class UserPassUserNew extends Component<DefaultPageProps> { export class UserPassUserNew extends Component<DefaultPageProps> {
errorMessageRef = createRef<ErrorMessage>(); errorMessageRef = createRef<ErrorMessage>();

View file

@ -3,12 +3,12 @@ import { Component, JSX, createRef } from "preact";
import { DefaultPageProps } from "../../types/DefaultPageProps"; import { DefaultPageProps } from "../../types/DefaultPageProps";
import { ErrorMessage } from "../elements/ErrorMessage"; import { ErrorMessage } from "../elements/ErrorMessage";
import { Form } from "../elements/forms/Form"; import { Form } from "../elements/forms/Form";
import { InputWithTitle } from "../elements/InputWithTitle";
import { Margin } from "../elements/Margin"; import { Margin } from "../elements/Margin";
import { MarginInline } from "../elements/MarginInline"; import { MarginInline } from "../elements/MarginInline";
import { PasswordInput } from "../elements/forms/PasswordInput";
import { route } from "preact-router"; import { route } from "preact-router";
import i18next from "i18next"; import i18next from "i18next";
import { PasswordInput } from "../elements/forms/PasswordInput";
import { InputWithTitle } from "../elements/InputWithTitle";
export class TokenLoginForm extends Component<DefaultPageProps> { export class TokenLoginForm extends Component<DefaultPageProps> {
errorMessageRef = createRef<ErrorMessage>(); errorMessageRef = createRef<ErrorMessage>();

View file

@ -3,13 +3,13 @@ import { Component, JSX, createRef } from "preact";
import { DefaultPageProps } from "../../types/DefaultPageProps"; import { DefaultPageProps } from "../../types/DefaultPageProps";
import { ErrorMessage } from "../elements/ErrorMessage"; import { ErrorMessage } from "../elements/ErrorMessage";
import { Form } from "../elements/forms/Form"; import { Form } from "../elements/forms/Form";
import { InputWithTitle } from "../elements/InputWithTitle";
import { Margin } from "../elements/Margin"; import { Margin } from "../elements/Margin";
import { MarginInline } from "../elements/MarginInline"; import { MarginInline } from "../elements/MarginInline";
import { PasswordInput } from "../elements/forms/PasswordInput";
import { TextInput } from "../elements/forms/TextInput";
import { route } from "preact-router"; import { route } from "preact-router";
import i18next from "i18next"; import i18next from "i18next";
import { TextInput } from "../elements/forms/TextInput";
import { PasswordInput } from "../elements/forms/PasswordInput";
import { InputWithTitle } from "../elements/InputWithTitle";
export class UsernameLoginForm extends Component<DefaultPageProps> { export class UsernameLoginForm extends Component<DefaultPageProps> {
errorMessageRef = createRef<ErrorMessage>(); errorMessageRef = createRef<ErrorMessage>();

View file

@ -3,13 +3,13 @@ import { Component, createRef } from "preact";
import { DefaultPageProps } from "../../../types/DefaultPageProps"; import { DefaultPageProps } from "../../../types/DefaultPageProps";
import { ErrorMessage } from "../../elements/ErrorMessage"; import { ErrorMessage } from "../../elements/ErrorMessage";
import { Form } from "../../elements/forms/Form"; import { Form } from "../../elements/forms/Form";
import { InputWithTitle } from "../../elements/InputWithTitle";
import { Margin } from "../../elements/Margin"; import { Margin } from "../../elements/Margin";
import { PageTitle } from "../../elements/PageTitle"; import { PageTitle } from "../../elements/PageTitle";
import { TextInput } from "../../elements/forms/TextInput";
import { policyViewURL } from "../pageLinks"; import { policyViewURL } from "../pageLinks";
import { route } from "preact-router"; import { route } from "preact-router";
import i18next from "i18next"; import i18next from "i18next";
import { TextInput } from "../../elements/forms/TextInput";
import { InputWithTitle } from "../../elements/InputWithTitle";
export class PolicyNew extends Component<DefaultPageProps> { export class PolicyNew extends Component<DefaultPageProps> {
errorMessageRef = createRef<ErrorMessage>(); errorMessageRef = createRef<ErrorMessage>();

View file

@ -5,8 +5,8 @@ import { DefaultPageProps } from "../../types/DefaultPageProps";
import { Form } from "../elements/forms/Form"; import { Form } from "../elements/forms/Form";
import { Margin } from "../elements/Margin"; import { Margin } from "../elements/Margin";
import { PageTitle } from "../elements/PageTitle"; import { PageTitle } from "../elements/PageTitle";
import i18next from "i18next";
import { Select, SelectOption } from "../elements/forms/Select"; import { Select, SelectOption } from "../elements/forms/Select";
import i18next from "i18next";
const passwordLengthMin = 1; const passwordLengthMin = 1;
const passwordLengthMax = 64; const passwordLengthMax = 64;

View file

@ -6,6 +6,7 @@ import { ErrorMessage, sendErrorNotification } from "../../../elements/ErrorMess
import { InputWithTitle } from "../../../elements/InputWithTitle"; import { InputWithTitle } from "../../../elements/InputWithTitle";
import { Margin } from "../../../elements/Margin"; import { Margin } from "../../../elements/Margin";
import { SecretTitleElement } from "../SecretTitleElement"; import { SecretTitleElement } from "../SecretTitleElement";
import { Select, SelectOption } from "../../../elements/forms/Select";
import { import {
SupportedLanguages, SupportedLanguages,
dumpData, dumpData,
@ -14,7 +15,6 @@ import {
} from "../../../../utils/dataInterchange"; } from "../../../../utils/dataInterchange";
import { sortedObjectMap } from "../../../../utils"; import { sortedObjectMap } from "../../../../utils";
import i18next from "i18next"; import i18next from "i18next";
import { Select, SelectOption } from "../../../elements/forms/Select";
export type KVEditProps = DefaultPageProps & { export type KVEditProps = DefaultPageProps & {
baseMount: string; baseMount: string;

View file

@ -2,13 +2,13 @@ import { Button } from "../../../elements/Button";
import { Component, JSX, createRef } from "preact"; import { Component, JSX, createRef } from "preact";
import { DefaultPageProps } from "../../../../types/DefaultPageProps"; import { DefaultPageProps } from "../../../../types/DefaultPageProps";
import { DoesNotExistError } from "../../../../types/internalErrors"; import { DoesNotExistError } from "../../../../types/internalErrors";
import { Margin } from "../../../elements/Margin";
import { SecretTitleElement } from "../SecretTitleElement"; import { SecretTitleElement } from "../SecretTitleElement";
import { TextInput } from "../../../elements/forms/TextInput";
import { delSecretsEngineURL, kvListURL, kvNewURL, kvViewURL } from "../../pageLinks"; import { delSecretsEngineURL, kvListURL, kvNewURL, kvViewURL } from "../../pageLinks";
import { route } from "preact-router"; import { route } from "preact-router";
import { sendErrorNotification } from "../../../elements/ErrorMessage"; import { sendErrorNotification } from "../../../elements/ErrorMessage";
import i18next from "i18next"; import i18next from "i18next";
import { TextInput } from "../../../elements/forms/TextInput";
import { Margin } from "../../../elements/Margin";
export type KVKeysListProps = DefaultPageProps & { export type KVKeysListProps = DefaultPageProps & {
baseMount: string; baseMount: string;

View file

@ -3,13 +3,13 @@ import { Component, createRef } from "preact";
import { DefaultPageProps } from "../../../../types/DefaultPageProps"; import { DefaultPageProps } from "../../../../types/DefaultPageProps";
import { ErrorMessage } from "../../../elements/ErrorMessage"; import { ErrorMessage } from "../../../elements/ErrorMessage";
import { Form } from "../../../elements/forms/Form"; import { Form } from "../../../elements/forms/Form";
import { InputWithTitle } from "../../../elements/InputWithTitle";
import { Margin } from "../../../elements/Margin"; import { Margin } from "../../../elements/Margin";
import { SecretTitleElement } from "../SecretTitleElement"; import { SecretTitleElement } from "../SecretTitleElement";
import { TextInput } from "../../../elements/forms/TextInput";
import { kvViewURL } from "../../pageLinks"; import { kvViewURL } from "../../pageLinks";
import { route } from "preact-router"; import { route } from "preact-router";
import i18next from "i18next"; import i18next from "i18next";
import { TextInput } from "../../../elements/forms/TextInput";
import { InputWithTitle } from "../../../elements/InputWithTitle";
export class KeyValueNew extends Component<DefaultPageProps> { export class KeyValueNew extends Component<DefaultPageProps> {
errorMessageRef = createRef<ErrorMessage>(); errorMessageRef = createRef<ErrorMessage>();

View file

@ -7,12 +7,12 @@ import { DoesNotExistError } from "../../../../types/internalErrors";
import { Grid, GridSizes } from "../../../elements/Grid"; import { Grid, GridSizes } from "../../../elements/Grid";
import { InputWithTitle } from "../../../elements/InputWithTitle"; import { InputWithTitle } from "../../../elements/InputWithTitle";
import { SecretTitleElement } from "../SecretTitleElement"; import { SecretTitleElement } from "../SecretTitleElement";
import { Select, SelectOption } from "../../../elements/forms/Select";
import { SupportedLanguages, dumpData, toPrismCode } from "../../../../utils/dataInterchange"; import { SupportedLanguages, dumpData, toPrismCode } from "../../../../utils/dataInterchange";
import { kvDeleteURL, kvEditURL, kvVersionsURL } from "../../pageLinks"; import { kvDeleteURL, kvEditURL, kvVersionsURL } from "../../pageLinks";
import { sendErrorNotification } from "../../../elements/ErrorMessage"; import { sendErrorNotification } from "../../../elements/ErrorMessage";
import { sortedObjectMap } from "../../../../utils"; import { sortedObjectMap } from "../../../../utils";
import i18next from "i18next"; import i18next from "i18next";
import { Select, SelectOption } from "../../../elements/forms/Select";
type KVSecretViewDataProps = DefaultPageProps & { data: Map<string, unknown> }; type KVSecretViewDataProps = DefaultPageProps & { data: Map<string, unknown> };

View file

@ -6,11 +6,11 @@ import { Form } from "../../../elements/forms/Form";
import { Margin } from "../../../elements/Margin"; import { Margin } from "../../../elements/Margin";
import { MarginInline } from "../../../elements/MarginInline"; import { MarginInline } from "../../../elements/MarginInline";
import { PageTitle } from "../../../elements/PageTitle"; import { PageTitle } from "../../../elements/PageTitle";
import { Select, SelectOption } from "../../../elements/forms/Select";
import { TextInput } from "../../../elements/forms/TextInput";
import { kvListURL } from "../../pageLinks"; import { kvListURL } from "../../pageLinks";
import { route } from "preact-router"; import { route } from "preact-router";
import i18next from "i18next"; import i18next from "i18next";
import { Select, SelectOption } from "../../../elements/forms/Select";
import { TextInput } from "../../../elements/forms/TextInput";
export class NewKVEngine extends Component<DefaultPageProps> { export class NewKVEngine extends Component<DefaultPageProps> {
errorMessageRef = createRef<ErrorMessage>(); errorMessageRef = createRef<ErrorMessage>();
@ -21,11 +21,7 @@ export class NewKVEngine extends Component<DefaultPageProps> {
<PageTitle title={i18next.t("new_kv_engine_title")} /> <PageTitle title={i18next.t("new_kv_engine_title")} />
<Form onSubmit={(data) => this.submit(data)}> <Form onSubmit={(data) => this.submit(data)}>
<Margin> <Margin>
<TextInput <TextInput name="name" placeholder={i18next.t("common_name")} required />
name="name"
placeholder={i18next.t("common_name")}
required
/>
</Margin> </Margin>
<Margin> <Margin>
<Select name="version"> <Select name="version">

View file

@ -6,10 +6,10 @@ import { Form } from "../../../elements/forms/Form";
import { Margin } from "../../../elements/Margin"; import { Margin } from "../../../elements/Margin";
import { MarginInline } from "../../../elements/MarginInline"; import { MarginInline } from "../../../elements/MarginInline";
import { PageTitle } from "../../../elements/PageTitle"; import { PageTitle } from "../../../elements/PageTitle";
import { TextInput } from "../../../elements/forms/TextInput";
import { route } from "preact-router"; import { route } from "preact-router";
import { totpListURL } from "../../pageLinks"; import { totpListURL } from "../../pageLinks";
import i18next from "i18next"; import i18next from "i18next";
import { TextInput } from "../../../elements/forms/TextInput";
export class NewTOTPEngine extends Component<DefaultPageProps> { export class NewTOTPEngine extends Component<DefaultPageProps> {
errorMessageRef = createRef<ErrorMessage>(); errorMessageRef = createRef<ErrorMessage>();
@ -20,11 +20,7 @@ export class NewTOTPEngine extends Component<DefaultPageProps> {
<PageTitle title={i18next.t("new_totp_engine_title")} /> <PageTitle title={i18next.t("new_totp_engine_title")} />
<Form onSubmit={(data) => this.submit(data)}> <Form onSubmit={(data) => this.submit(data)}>
<Margin> <Margin>
<TextInput <TextInput name="name" placeholder={i18next.t("common_name")} required />
name="name"
placeholder={i18next.t("common_name")}
required
/>
</Margin> </Margin>
<Margin> <Margin>

View file

@ -6,9 +6,9 @@ import { Form } from "../../../elements/forms/Form";
import { Margin } from "../../../elements/Margin"; import { Margin } from "../../../elements/Margin";
import { MarginInline } from "../../../elements/MarginInline"; import { MarginInline } from "../../../elements/MarginInline";
import { PageTitle } from "../../../elements/PageTitle"; import { PageTitle } from "../../../elements/PageTitle";
import { TextInput } from "../../../elements/forms/TextInput";
import { route } from "preact-router"; import { route } from "preact-router";
import i18next from "i18next"; import i18next from "i18next";
import { TextInput } from "../../../elements/forms/TextInput";
export class NewTransitEngine extends Component<DefaultPageProps> { export class NewTransitEngine extends Component<DefaultPageProps> {
errorMessageRef = createRef<ErrorMessage>(); errorMessageRef = createRef<ErrorMessage>();
@ -19,11 +19,7 @@ export class NewTransitEngine extends Component<DefaultPageProps> {
<PageTitle title={i18next.t("new_transit_engine_title")} /> <PageTitle title={i18next.t("new_transit_engine_title")} />
<Form onSubmit={(data) => this.submit(data)}> <Form onSubmit={(data) => this.submit(data)}>
<Margin> <Margin>
<TextInput <TextInput name="name" placeholder={i18next.t("common_name")} required />
name="name"
placeholder={i18next.t("common_name")}
required
/>
</Margin> </Margin>
<Margin> <Margin>

View file

@ -7,9 +7,9 @@ import { Margin } from "../../../elements/Margin";
import { MarginInline } from "../../../elements/MarginInline"; import { MarginInline } from "../../../elements/MarginInline";
import { QRScanner } from "../../../elements/QRScanner"; import { QRScanner } from "../../../elements/QRScanner";
import { SecretTitleElement } from "../SecretTitleElement"; import { SecretTitleElement } from "../SecretTitleElement";
import { TextInput } from "../../../elements/forms/TextInput";
import { route } from "preact-router"; import { route } from "preact-router";
import i18next from "i18next"; import i18next from "i18next";
import { TextInput } from "../../../elements/forms/TextInput";
function replaceAll(str: string, replace: string, replaceWith: string): string { function replaceAll(str: string, replace: string, replaceWith: string): string {
return str.replace(new RegExp(replace, "g"), replaceWith); return str.replace(new RegExp(replace, "g"), replaceWith);
@ -69,30 +69,23 @@ export class TOTPNewForm extends Component<
{!this.state.qrMode && ( {!this.state.qrMode && (
<> <>
<Margin> <Margin>
<TextInput <TextInput name="key" placeholder={i18next.t("totp_new_key_input")} />
name="key"
placeholder={i18next.t("totp_new_key_input")}
/>
</Margin> </Margin>
<Margin> <Margin>
<TextInput <TextInput name="uri" placeholder={i18next.t("totp_new_uri_input")} />
name="uri"
placeholder={i18next.t("totp_new_uri_input")}
/>
</Margin> </Margin>
</> </>
)} )}
{this.state.qrMode && ( {this.state.qrMode && (
<QRScanner <QRScanner
onScan={(uri) => { onScan={async (uri) => {
let formData = new FormData(); const formData = new FormData();
formData.set("key", ""); formData.set("key", "");
formData.set("name", this.nameInputRef.current.value) formData.set("name", this.nameInputRef.current.value);
formData.set("uri", uri); formData.set("uri", uri);
this.onSubmit(formData); await this.onSubmit(formData);
this.setState({ qrMode: !this.state.qrMode });
}} }}
/> />
)} )}

View file

@ -1,4 +1,5 @@
import { Button } from "../../../elements/Button"; import { Button } from "../../../elements/Button";
import { Checkbox } from "../../../elements/forms/Checkbox";
import { Component, JSX, createRef } from "preact"; import { Component, JSX, createRef } from "preact";
import { CopyableInputBox } from "../../../elements/CopyableInputBox"; import { CopyableInputBox } from "../../../elements/CopyableInputBox";
import { DefaultPageProps } from "../../../../types/DefaultPageProps"; import { DefaultPageProps } from "../../../../types/DefaultPageProps";
@ -8,14 +9,13 @@ import { InputWithTitle } from "../../../elements/InputWithTitle";
import { Margin } from "../../../elements/Margin"; import { Margin } from "../../../elements/Margin";
import { MarginInline } from "../../../elements/MarginInline"; import { MarginInline } from "../../../elements/MarginInline";
import { NewTOTPResp } from "../../../../api/types/totp"; import { NewTOTPResp } from "../../../../api/types/totp";
import { NumberInput } from "../../../elements/forms/NumberInput";
import { SecretTitleElement } from "../SecretTitleElement"; import { SecretTitleElement } from "../SecretTitleElement";
import { Select, SelectOption } from "../../../elements/forms/Select";
import { TextInput } from "../../../elements/forms/TextInput";
import { route } from "preact-router"; import { route } from "preact-router";
import { totpListURL } from "../../pageLinks"; import { totpListURL } from "../../pageLinks";
import i18next from "i18next"; import i18next from "i18next";
import { NumberInput } from "../../../elements/forms/NumberInput";
import { TextInput } from "../../../elements/forms/TextInput";
import { Checkbox } from "../../../elements/forms/Checkbox";
import { Select, SelectOption, } from "../../../elements/forms/Select";
export class TOTPNewGeneratedForm extends Component< export class TOTPNewGeneratedForm extends Component<
{ baseMount: string } & DefaultPageProps, { baseMount: string } & DefaultPageProps,
@ -30,11 +30,7 @@ export class TOTPNewGeneratedForm extends Component<
<Form onSubmit={(data) => this.onSubmit(data)}> <Form onSubmit={(data) => this.onSubmit(data)}>
<Margin> <Margin>
<InputWithTitle title={i18next.t("common_name")}> <InputWithTitle title={i18next.t("common_name")}>
<TextInput <TextInput name="name" placeholder={i18next.t("common_name")} required />
name="name"
placeholder={i18next.t("common_name")}
required
/>
</InputWithTitle> </InputWithTitle>
</Margin> </Margin>

View file

@ -1,4 +1,5 @@
import { Button } from "../../../elements/Button"; import { Button } from "../../../elements/Button";
import { Checkbox } from "../../../elements/forms/Checkbox";
import { Component, createRef } from "preact"; import { Component, createRef } from "preact";
import { CopyableBox } from "../../../elements/CopyableBox"; import { CopyableBox } from "../../../elements/CopyableBox";
import { DefaultPageProps } from "../../../../types/DefaultPageProps"; import { DefaultPageProps } from "../../../../types/DefaultPageProps";
@ -8,10 +9,9 @@ import { Form } from "../../../elements/forms/Form";
import { InputWithTitle } from "../../../elements/InputWithTitle"; import { InputWithTitle } from "../../../elements/InputWithTitle";
import { Margin } from "../../../elements/Margin"; import { Margin } from "../../../elements/Margin";
import { SecretTitleElement } from "../SecretTitleElement"; import { SecretTitleElement } from "../SecretTitleElement";
import { TextArea } from "../../../elements/forms/TextArea";
import { fileToBase64 } from "../../../../utils/fileToBase64"; import { fileToBase64 } from "../../../../utils/fileToBase64";
import i18next from "i18next"; import i18next from "i18next";
import { Checkbox } from "../../../elements/forms/Checkbox";
import { TextArea } from "../../../elements/forms/TextArea";
export class TransitDecrypt extends Component<DefaultPageProps, { plaintext: string }> { export class TransitDecrypt extends Component<DefaultPageProps, { plaintext: string }> {
errorMessageRef = createRef<ErrorMessage>(); errorMessageRef = createRef<ErrorMessage>();

View file

@ -1,4 +1,5 @@
import { Button } from "../../../elements/Button"; import { Button } from "../../../elements/Button";
import { Checkbox } from "../../../elements/forms/Checkbox";
import { Component, createRef } from "preact"; import { Component, createRef } from "preact";
import { CopyableBox } from "../../../elements/CopyableBox"; import { CopyableBox } from "../../../elements/CopyableBox";
import { DefaultPageProps } from "../../../../types/DefaultPageProps"; import { DefaultPageProps } from "../../../../types/DefaultPageProps";
@ -8,10 +9,9 @@ import { Form } from "../../../elements/forms/Form";
import { InputWithTitle } from "../../../elements/InputWithTitle"; import { InputWithTitle } from "../../../elements/InputWithTitle";
import { Margin } from "../../../elements/Margin"; import { Margin } from "../../../elements/Margin";
import { SecretTitleElement } from "../SecretTitleElement"; import { SecretTitleElement } from "../SecretTitleElement";
import { TextArea } from "../../../elements/forms/TextArea";
import { fileToBase64 } from "../../../../utils/fileToBase64"; import { fileToBase64 } from "../../../../utils/fileToBase64";
import i18next from "i18next"; import i18next from "i18next";
import { Checkbox } from "../../../elements/forms/Checkbox";
import { TextArea } from "../../../elements/forms/TextArea";
export class TransitEncrypt extends Component<DefaultPageProps, { ciphertext: string }> { export class TransitEncrypt extends Component<DefaultPageProps, { ciphertext: string }> {
errorMessageRef = createRef<ErrorMessage>(); errorMessageRef = createRef<ErrorMessage>();

View file

@ -3,15 +3,15 @@ import { Component, createRef } from "preact";
import { DefaultPageProps } from "../../../../types/DefaultPageProps"; import { DefaultPageProps } from "../../../../types/DefaultPageProps";
import { ErrorMessage } from "../../../elements/ErrorMessage"; import { ErrorMessage } from "../../../elements/ErrorMessage";
import { Form } from "../../../elements/forms/Form"; import { Form } from "../../../elements/forms/Form";
import { InputWithTitle } from "../../../elements/InputWithTitle";
import { Margin } from "../../../elements/Margin"; import { Margin } from "../../../elements/Margin";
import { MarginInline } from "../../../elements/MarginInline"; import { MarginInline } from "../../../elements/MarginInline";
import { SecretTitleElement } from "../SecretTitleElement"; import { SecretTitleElement } from "../SecretTitleElement";
import { Select, SelectOption } from "../../../elements/forms/Select";
import { TextInput } from "../../../elements/forms/TextInput";
import { route } from "preact-router"; import { route } from "preact-router";
import { transitViewSecretURL } from "../../pageLinks"; import { transitViewSecretURL } from "../../pageLinks";
import i18next from "i18next"; import i18next from "i18next";
import { TextInput } from "../../../elements/forms/TextInput";
import { InputWithTitle } from "../../../elements/InputWithTitle";
import { Select, SelectOption } from "../../../elements/forms/Select";
export class TransitNew extends Component<DefaultPageProps> { export class TransitNew extends Component<DefaultPageProps> {
errorMessageRef = createRef<ErrorMessage>(); errorMessageRef = createRef<ErrorMessage>();

View file

@ -6,11 +6,11 @@ import { ErrorMessage, sendErrorNotification } from "../../../elements/ErrorMess
import { Form } from "../../../elements/forms/Form"; import { Form } from "../../../elements/forms/Form";
import { Margin } from "../../../elements/Margin"; import { Margin } from "../../../elements/Margin";
import { SecretTitleElement } from "../SecretTitleElement"; import { SecretTitleElement } from "../SecretTitleElement";
import { Select, SelectOption } from "../../../elements/forms/Select";
import { TextArea } from "../../../elements/forms/TextArea";
import { TransitKeyType } from "../../../../api/types/transit"; import { TransitKeyType } from "../../../../api/types/transit";
import { objectToMap } from "../../../../utils"; import { objectToMap } from "../../../../utils";
import i18next from "i18next"; import i18next from "i18next";
import { Select, SelectOption } from "../../../elements/forms/Select";
import { TextArea } from "../../../elements/forms/TextArea";
type versionOption = { version: string; label: string }; type versionOption = { version: string; label: string };

View file

@ -9,10 +9,10 @@ import { Form } from "../elements/forms/Form";
import { Margin } from "../elements/Margin"; import { Margin } from "../elements/Margin";
import { MarginInline } from "../elements/MarginInline"; import { MarginInline } from "../elements/MarginInline";
import { PageTitle } from "../elements/PageTitle"; import { PageTitle } from "../elements/PageTitle";
import { Select, SelectOption } from "../elements/forms/Select";
import { getTranslationCompletePercentage } from "../../utils/translationUtils"; import { getTranslationCompletePercentage } from "../../utils/translationUtils";
import { route } from "preact-router"; import { route } from "preact-router";
import i18next from "i18next"; import i18next from "i18next";
import { Select, SelectOption } from "../elements/forms/Select.js";
export class SetLanguage extends Component<DefaultPageProps> { export class SetLanguage extends Component<DefaultPageProps> {
render() { render() {
@ -23,9 +23,9 @@ export class SetLanguage extends Component<DefaultPageProps> {
<Margin> <Margin>
<Select name="language"> <Select name="language">
{Object.getOwnPropertyNames(translations).map((languageID) => { {Object.getOwnPropertyNames(translations).map((languageID) => {
let languageName = i18next.getFixedT(languageID, null)("language_name"); const languageName = i18next.getFixedT(languageID, null)("language_name");
let languageCompletionPercent = getTranslationCompletePercentage(languageID); const languageCompletionPercent = getTranslationCompletePercentage(languageID);
let name = `${languageName} (${languageCompletionPercent})` const name = `${languageName} (${languageCompletionPercent})`;
return ( return (
<SelectOption <SelectOption
name={name} name={name}

View file

@ -2,12 +2,12 @@ import { Button } from "../elements/Button";
import { Component } from "preact"; import { Component } from "preact";
import { DefaultPageProps } from "../../types/DefaultPageProps"; import { DefaultPageProps } from "../../types/DefaultPageProps";
import { Form } from "../elements/forms/Form"; import { Form } from "../elements/forms/Form";
import { InputWithTitle } from "../elements/InputWithTitle";
import { Margin } from "../elements/Margin"; import { Margin } from "../elements/Margin";
import { PageTitle } from "../elements/PageTitle"; import { PageTitle } from "../elements/PageTitle";
import { TextInput } from "../elements/forms/TextInput";
import { route } from "preact-router"; import { route } from "preact-router";
import i18next from "i18next"; import i18next from "i18next";
import { TextInput } from "../elements/forms/TextInput";
import { InputWithTitle } from "../elements/InputWithTitle";
export class SetVaultURL extends Component<DefaultPageProps> { export class SetVaultURL extends Component<DefaultPageProps> {
render() { render() {

View file

@ -4,11 +4,11 @@ import { InputWithTitle } from "../../elements/InputWithTitle";
import i18next from "i18next"; import i18next from "i18next";
// @ts-ignore // @ts-ignore
import { Select, SelectOption } from "../../elements/forms/Select";
import { TextInput } from "../../elements/forms/TextInput";
import { getTranslationCompletePercentage } from "../../../utils/translationUtils"; import { getTranslationCompletePercentage } from "../../../utils/translationUtils";
import { settingsSavedNotification } from "./Settings"; import { settingsSavedNotification } from "./Settings";
import translations from "../../../translations/index.mjs"; import translations from "../../../translations/index.mjs";
import { Select, SelectOption } from "../../elements/forms/Select";
import { TextInput } from "../../elements/forms/TextInput";
const Themes = [ const Themes = [
{ name: "dark", readable: "Dark" }, { name: "dark", readable: "Dark" },
@ -72,9 +72,9 @@ export class GeneralSettings extends Component<DefaultPageProps> {
}} }}
> >
{Object.getOwnPropertyNames(translations).map((languageID) => { {Object.getOwnPropertyNames(translations).map((languageID) => {
let languageName = i18next.getFixedT(languageID, null)("language_name"); const languageName = i18next.getFixedT(languageID, null)("language_name");
let languageCompletionPercent = getTranslationCompletePercentage(languageID); const languageCompletionPercent = getTranslationCompletePercentage(languageID);
let name = `${languageName} (${languageCompletionPercent})` const name = `${languageName} (${languageCompletionPercent})`;
return ( return (
<SelectOption <SelectOption
name={name} name={name}

View file

@ -1,13 +1,13 @@
import { Checkbox } from "../../elements/forms/Checkbox";
import { Component, createRef } from "preact"; import { Component, createRef } from "preact";
import { DefaultPageProps } from "../../../types/DefaultPageProps"; import { DefaultPageProps } from "../../../types/DefaultPageProps";
import { InputWithTitle } from "../../elements/InputWithTitle"; import { InputWithTitle } from "../../elements/InputWithTitle";
import { NumberInput } from "../../elements/forms/NumberInput";
import { Select, SelectOption } from "../../elements/forms/Select";
import { SupportedLanguages } from "../../../utils/dataInterchange"; import { SupportedLanguages } from "../../../utils/dataInterchange";
import { TextInput } from "../../elements/forms/TextInput";
import { settingsSavedNotification } from "./Settings"; import { settingsSavedNotification } from "./Settings";
import i18next from "i18next"; import i18next from "i18next";
import { Select, SelectOption } from "../../elements/forms/Select";
import { NumberInput } from "../../elements/forms/NumberInput";
import { Checkbox } from "../../elements/forms/Checkbox";
import { TextInput } from "../../elements/forms/TextInput";
export class KeyValueViewSettings extends Component<DefaultPageProps> { export class KeyValueViewSettings extends Component<DefaultPageProps> {
viewSyntaxSelectRef = createRef<HTMLSelectElement>(); viewSyntaxSelectRef = createRef<HTMLSelectElement>();

View file

@ -1,10 +1,10 @@
import { Button } from "../elements/Button"; import { Button } from "../elements/Button";
import { Form } from "../elements/forms/Form"; import { Form } from "../elements/forms/Form";
import { InputWithTitle } from "../elements/InputWithTitle";
import { JSX } from "preact/jsx-runtime"; import { JSX } from "preact/jsx-runtime";
import { MarginInline } from "../elements/MarginInline"; import { MarginInline } from "../elements/MarginInline";
import i18next from "i18next";
import { PasswordInput } from "../elements/forms/PasswordInput"; import { PasswordInput } from "../elements/forms/PasswordInput";
import { InputWithTitle } from "../elements/InputWithTitle"; import i18next from "i18next";
type FormUnsealProps = { type FormUnsealProps = {
onKeySubmit: (key: string) => void; onKeySubmit: (key: string) => void;
@ -12,9 +12,11 @@ type FormUnsealProps = {
export function UnsealForm(props: FormUnsealProps): JSX.Element { export function UnsealForm(props: FormUnsealProps): JSX.Element {
return ( return (
<Form onSubmit={(data: FormData) => { <Form
onSubmit={(data: FormData) => {
props.onKeySubmit(data.get("unsealKey") as string); props.onKeySubmit(data.get("unsealKey") as string);
}}> }}
>
<MarginInline> <MarginInline>
<InputWithTitle title={i18next.t("unseal_key_input_placeholder")}> <InputWithTitle title={i18next.t("unseal_key_input_placeholder")}>
<PasswordInput <PasswordInput