From a62deeef5d0cbe5fa98be390eac0e03bcae0f0b5 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 10 Nov 2021 10:20:52 -0300 Subject: prettier --- .../src/pages/home/ReviewPoliciesScreen.tsx | 119 +++++++++++++++------ 1 file changed, 87 insertions(+), 32 deletions(-) (limited to 'packages/anastasis-webui/src/pages/home/ReviewPoliciesScreen.tsx') diff --git a/packages/anastasis-webui/src/pages/home/ReviewPoliciesScreen.tsx b/packages/anastasis-webui/src/pages/home/ReviewPoliciesScreen.tsx index aa98b5dd9..c43f0cdea 100644 --- a/packages/anastasis-webui/src/pages/home/ReviewPoliciesScreen.tsx +++ b/packages/anastasis-webui/src/pages/home/ReviewPoliciesScreen.tsx @@ -6,16 +6,20 @@ import { EditPoliciesScreen } from "./EditPoliciesScreen"; import { AnastasisClientFrame } from "./index"; export function ReviewPoliciesScreen(): VNode { - const [editingPolicy, setEditingPolicy] = useState() - const reducer = useAnastasisContext() + const [editingPolicy, setEditingPolicy] = useState(); + const reducer = useAnastasisContext(); if (!reducer) { - return
no reducer in context
+ return
no reducer in context
; } - if (!reducer.currentReducerState || reducer.currentReducerState.backup_state === undefined) { - return
invalid state
+ if ( + !reducer.currentReducerState || + reducer.currentReducerState.backup_state === undefined + ) { + return
invalid state
; } - const configuredAuthMethods = reducer.currentReducerState.authentication_methods ?? []; + const configuredAuthMethods = + reducer.currentReducerState.authentication_methods ?? []; const policies = reducer.currentReducerState.policies ?? []; if (editingPolicy !== undefined) { @@ -28,58 +32,109 @@ export function ReviewPoliciesScreen(): VNode { policy_index: editingPolicy, policy: newMethods, }); - setEditingPolicy(undefined) + setEditingPolicy(undefined); }} /> - ) + ); } - const errors = policies.length < 1 ? 'Need more policies' : undefined + const errors = policies.length < 1 ? "Need more policies" : undefined; return ( - - {policies.length > 0 &&

- Based on your configured authentication method you have created, some policies - have been configured. In order to recover your secret you have to solve all the - challenges of at least one policy. -

} - {policies.length < 1 &&

- No policies had been created. Go back and add more authentication methods. -

} -
- + + {policies.length > 0 && ( +

+ Based on your configured authentication method you have created, some + policies have been configured. In order to recover your secret you + have to solve all the challenges of at least one policy. +

+ )} + {policies.length < 1 && ( +

+ No policies had been created. Go back and add more authentication + methods. +

+ )} +
+
{policies.map((p, policy_index) => { const methods = p.methods - .map(x => configuredAuthMethods[x.authentication_method] && ({ ...configuredAuthMethods[x.authentication_method], provider: x.provider })) - .filter(x => !!x) + .map( + (x) => + configuredAuthMethods[x.authentication_method] && { + ...configuredAuthMethods[x.authentication_method], + provider: x.provider, + }, + ) + .filter((x) => !!x); - const policyName = methods.map(x => x.type).join(" + "); + const policyName = methods.map((x) => x.type).join(" + "); + + if (p.methods.length > methods.length) { + //there is at least one authentication method that is corrupted + return null; + } return ( -
+

Policy #{policy_index + 1}: {policyName}

- {!methods.length &&

- No auth method found -

} + {!methods.length &&

No auth method found

} {methods.map((m, i) => { return ( -

+

{authMethods[m.type as KnownAuthMethods]?.icon} - {m.instructions} recovery provided by {m.provider} + {m.instructions} recovery provided by{" "} + {m.provider}

); })}
-
- - +
+ +
); -- cgit v1.2.3