From a82b5a6992fda61d6eaa0bb079e284805a394777 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 3 Nov 2021 17:30:11 -0300 Subject: feedback from meeting and editing policy --- .../anastasis-webui/src/components/AsyncButton.tsx | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 packages/anastasis-webui/src/components/AsyncButton.tsx (limited to 'packages/anastasis-webui/src/components/AsyncButton.tsx') diff --git a/packages/anastasis-webui/src/components/AsyncButton.tsx b/packages/anastasis-webui/src/components/AsyncButton.tsx new file mode 100644 index 000000000..5602715e4 --- /dev/null +++ b/packages/anastasis-webui/src/components/AsyncButton.tsx @@ -0,0 +1,51 @@ +/* + This file is part of GNU Taler + (C) 2021 Taler Systems S.A. + + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see + */ + +/** +* +* @author Sebastian Javier Marchano (sebasjm) +*/ + +import { ComponentChildren, h, VNode } from "preact"; +// import { LoadingModal } from "../modal"; +import { useAsync } from "../hooks/async"; +// import { Translate } from "../../i18n"; + +type Props = { + children: ComponentChildren; + disabled: boolean; + onClick?: () => Promise; + [rest: string]: any; +}; + +export function AsyncButton({ onClick, disabled, children, ...rest }: Props): VNode { + const { isLoading, request } = useAsync(onClick); + + // if (isSlow) { + // return ; + // } + console.log(isLoading) + if (isLoading) { + + return ; + } + + return + + ; +} -- cgit v1.2.3 From ae0a35df2b2934c517954d2a73af4cc6e1734e30 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 4 Nov 2021 15:17:57 -0300 Subject: async, onInput, and some fixes --- .../anastasis-webui/src/components/AsyncButton.tsx | 4 +- .../src/components/fields/DateInput.tsx | 2 +- .../src/components/fields/EmailInput.tsx | 2 +- .../src/components/fields/NumberInput.tsx | 2 +- .../src/components/fields/TextInput.tsx | 2 +- .../src/components/picker/DatePicker.tsx | 2 +- packages/anastasis-webui/src/hooks/async.ts | 4 +- .../src/pages/home/AttributeEntryScreen.tsx | 4 +- .../src/pages/home/AuthenticationEditorScreen.tsx | 4 +- .../src/pages/home/ChallengeOverviewScreen.tsx | 1 - .../src/pages/home/ContinentSelectionScreen.tsx | 4 +- .../src/pages/home/RecoveryFinishedScreen.tsx | 3 + .../src/pages/home/SecretEditorScreen.tsx | 31 ++++++---- .../src/pages/home/SecretSelectionScreen.tsx | 71 ++++++++++++---------- .../anastasis-webui/src/pages/home/SolveScreen.tsx | 3 + packages/anastasis-webui/src/pages/home/index.tsx | 6 +- packages/anastasis-webui/src/utils/index.tsx | 8 +-- packages/taler-wallet-webextension/package.json | 4 +- pnpm-lock.yaml | 49 +++++---------- 19 files changed, 101 insertions(+), 105 deletions(-) (limited to 'packages/anastasis-webui/src/components/AsyncButton.tsx') diff --git a/packages/anastasis-webui/src/components/AsyncButton.tsx b/packages/anastasis-webui/src/components/AsyncButton.tsx index 5602715e4..af85016e8 100644 --- a/packages/anastasis-webui/src/components/AsyncButton.tsx +++ b/packages/anastasis-webui/src/components/AsyncButton.tsx @@ -37,9 +37,7 @@ export function AsyncButton({ onClick, disabled, children, ...rest }: Props): VN // if (isSlow) { // return ; // } - console.log(isLoading) - if (isLoading) { - + if (isLoading) { return ; } diff --git a/packages/anastasis-webui/src/components/fields/DateInput.tsx b/packages/anastasis-webui/src/components/fields/DateInput.tsx index c406b85d1..3148c953f 100644 --- a/packages/anastasis-webui/src/components/fields/DateInput.tsx +++ b/packages/anastasis-webui/src/components/fields/DateInput.tsx @@ -41,7 +41,7 @@ export function DateInput(props: DateInputProps): VNode { type="text" class={showError ? 'input is-danger' : 'input'} value={value} - onChange={(e) => { + onInput={(e) => { const text = e.currentTarget.value setDirty(true) props.bind[1](text); diff --git a/packages/anastasis-webui/src/components/fields/EmailInput.tsx b/packages/anastasis-webui/src/components/fields/EmailInput.tsx index e0fca0f46..e21418fea 100644 --- a/packages/anastasis-webui/src/components/fields/EmailInput.tsx +++ b/packages/anastasis-webui/src/components/fields/EmailInput.tsx @@ -34,7 +34,7 @@ export function EmailInput(props: TextInputProps): VNode { placeholder={props.placeholder} type="email" class={showError ? 'input is-danger' : 'input'} - onChange={(e) => {setDirty(true); props.bind[1]((e.target as HTMLInputElement).value)}} + onInput={(e) => {setDirty(true); props.bind[1]((e.target as HTMLInputElement).value)}} ref={inputRef} style={{ display: "block" }} /> diff --git a/packages/anastasis-webui/src/components/fields/NumberInput.tsx b/packages/anastasis-webui/src/components/fields/NumberInput.tsx index 2b6cdcd2c..2afb242b8 100644 --- a/packages/anastasis-webui/src/components/fields/NumberInput.tsx +++ b/packages/anastasis-webui/src/components/fields/NumberInput.tsx @@ -33,7 +33,7 @@ export function NumberInput(props: TextInputProps): VNode { type="number" placeholder={props.placeholder} class={showError ? 'input is-danger' : 'input'} - onChange={(e) => {setDirty(true); props.bind[1]((e.target as HTMLInputElement).value)}} + onInput={(e) => {setDirty(true); props.bind[1]((e.target as HTMLInputElement).value)}} ref={inputRef} style={{ display: "block" }} /> diff --git a/packages/anastasis-webui/src/components/fields/TextInput.tsx b/packages/anastasis-webui/src/components/fields/TextInput.tsx index 4bb785cd3..c093689c5 100644 --- a/packages/anastasis-webui/src/components/fields/TextInput.tsx +++ b/packages/anastasis-webui/src/components/fields/TextInput.tsx @@ -32,7 +32,7 @@ export function TextInput(props: TextInputProps): VNode { value={value} placeholder={props.placeholder} class={showError ? 'input is-danger' : 'input'} - onChange={(e) => {setDirty(true); props.bind[1]((e.target as HTMLInputElement).value)}} + onInput={(e) => {setDirty(true); props.bind[1]((e.target as HTMLInputElement).value)}} ref={inputRef} style={{ display: "block" }} /> diff --git a/packages/anastasis-webui/src/components/picker/DatePicker.tsx b/packages/anastasis-webui/src/components/picker/DatePicker.tsx index a94b3708e..eb5d8145d 100644 --- a/packages/anastasis-webui/src/components/picker/DatePicker.tsx +++ b/packages/anastasis-webui/src/components/picker/DatePicker.tsx @@ -214,7 +214,7 @@ export class DatePicker extends Component { // } } - constructor(props) { + constructor(props: any) { super(props); this.closeDatePicker = this.closeDatePicker.bind(this); diff --git a/packages/anastasis-webui/src/hooks/async.ts b/packages/anastasis-webui/src/hooks/async.ts index f142a5dc5..ea3ff6acf 100644 --- a/packages/anastasis-webui/src/hooks/async.ts +++ b/packages/anastasis-webui/src/hooks/async.ts @@ -43,14 +43,14 @@ export function useAsync(fn?: (...args: any) => Promise, { slowTolerance: const request = async (...args: any) => { if (!fn) return; setLoading(true); - console.log("loading true") const handler = setTimeout(() => { setSlow(true) }, tooLong) try { + console.log("calling async", args) const result = await fn(...args); - console.log(result) + console.log("async back", result) setData(result); } catch (error) { setError(error); diff --git a/packages/anastasis-webui/src/pages/home/AttributeEntryScreen.tsx b/packages/anastasis-webui/src/pages/home/AttributeEntryScreen.tsx index 52046b216..f86994c97 100644 --- a/packages/anastasis-webui/src/pages/home/AttributeEntryScreen.tsx +++ b/packages/anastasis-webui/src/pages/home/AttributeEntryScreen.tsx @@ -48,10 +48,10 @@ export function AttributeEntryScreen(): VNode { })} >
-
+
{fieldList}
-
+

This personal information will help to locate your secret.

This stays private

The information you have entered here:

diff --git a/packages/anastasis-webui/src/pages/home/AuthenticationEditorScreen.tsx b/packages/anastasis-webui/src/pages/home/AuthenticationEditorScreen.tsx index b95d3f1e3..93ca81194 100644 --- a/packages/anastasis-webui/src/pages/home/AuthenticationEditorScreen.tsx +++ b/packages/anastasis-webui/src/pages/home/AuthenticationEditorScreen.tsx @@ -135,7 +135,7 @@ export function AuthenticationEditorScreen(): VNode { return (
-

Secret found, you can select another version or continue to the challenges solving

@@ -140,3 +74,93 @@ export function SecretSelectionScreen(): VNode { ); } + + +function ChooseAnotherProviderScreen({ providers, selected, onChange }: { selected: string; providers: string[]; onChange: (prov: string) => void }): VNode { + return ( + +

No recovery document found, try with another provider

+
+ +
+
+ +
+ +
+
+
+
+
+ ); +} + +function SelectOtherVersionProviderScreen({ providers, provider, version, onConfirm, onCancel }: { onCancel: () => void; provider: string; version: number; providers: string[]; onConfirm: (prov: string, v: number) => Promise; }): VNode { + const [otherProvider, setOtherProvider] = useState(provider); + const [otherVersion, setOtherVersion] = useState(`${version}`); + + return ( + +
+
+
+

Provider {otherProvider}

+
+ {version === 0 ?

+ Set to recover the latest version +

:

+ Set to recover the version number {version} +

} +

Specify other version below or use the latest

+
+ +
+ +
+
+ +
+ +
+
+
+
+
+ +
+
+
+ +
+ onConfirm(otherProvider, 0)}>Use latest + onConfirm(otherProvider, parseInt(otherVersion, 10))}>Confirm +
+
+
+
+ . +
+
+ +
+ ); + +} diff --git a/packages/anastasis-webui/src/pages/home/SolveScreen.tsx b/packages/anastasis-webui/src/pages/home/SolveScreen.tsx index fae1b5631..bc1a88db3 100644 --- a/packages/anastasis-webui/src/pages/home/SolveScreen.tsx +++ b/packages/anastasis-webui/src/pages/home/SolveScreen.tsx @@ -137,7 +137,7 @@ export function SolveScreen(): VNode { - + Confirm
diff --git a/packages/anastasis-webui/src/pages/home/index.tsx b/packages/anastasis-webui/src/pages/home/index.tsx index 6ebc2a6e9..07bc7c604 100644 --- a/packages/anastasis-webui/src/pages/home/index.tsx +++ b/packages/anastasis-webui/src/pages/home/index.tsx @@ -120,7 +120,7 @@ export function AnastasisClientFrame(props: AnastasisClientFrameProps): VNode { {!props.hideNav ? (
- Next + Next
) : null} @@ -140,7 +140,7 @@ const AnastasisClient: FunctionalComponent = () => { ); }; -const AnastasisClientImpl: FunctionalComponent = () => { +function AnastasisClientImpl(): VNode { const reducer = useAnastasisContext() if (!reducer) { return

Fatal: Reducer must be in context.

; @@ -228,7 +228,7 @@ const AnastasisClientImpl: FunctionalComponent = () => {
); -}; +} /** * Show a dismissible error banner if there is a current error. -- cgit v1.2.3