From e4dd6c0aa6b13b94f2afa113aebfdc9af446fbf9 Mon Sep 17 00:00:00 2001 From: shamsmosowi Date: Fri, 22 Oct 2021 08:27:34 +1100 Subject: [PATCH] added a temp skip button for rules setting step --- src/components/Setup/Step4Rules.tsx | 42 +++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/src/components/Setup/Step4Rules.tsx b/src/components/Setup/Step4Rules.tsx index 4ceecd06..52eaef83 100644 --- a/src/components/Setup/Step4Rules.tsx +++ b/src/components/Setup/Step4Rules.tsx @@ -21,6 +21,7 @@ import { CONFIG } from "config/dbPaths"; import { requiredRules, adminRules, utilFns } from "config/firestoreRules"; import { rowyRun } from "utils/rowyRun"; import { runRoutes } from "constants/runRoutes"; +import { useConfirmation } from "components/ConfirmationDialog"; export default function Step4Rules({ rowyRunUrl, @@ -28,6 +29,7 @@ export default function Step4Rules({ setCompletion, }: ISetupStepBodyProps) { const { projectId, getAuthToken } = useAppContext(); + const { requestConfirmation } = useConfirmation(); const [hasRules, setHasRules] = useState(completion.rules); const [adminRule, setAdminRule] = useState(true); @@ -83,13 +85,11 @@ export default function Step4Rules({ body: { ruleset: newRules }, }); if (!res.success) throw new Error(res.message); - const isSuccessful = await checkRules(rowyRunUrl, authToken); if (isSuccessful) { setCompletion((c) => ({ ...c, rules: true })); setHasRules(true); } - setRulesStatus("IDLE"); } catch (e: any) { console.error(e); @@ -97,6 +97,19 @@ export default function Step4Rules({ } }; + const handleSkip = () => { + requestConfirmation({ + title: "Skip rules", + body: "This might prevent you or other users in your project from accessing firestore data on Rowy", + confirm: "Skip", + cancel: "cancel", + handleConfirm: async () => { + setCompletion((c) => ({ ...c, rules: true })); + setHasRules(true); + }, + }); + }; + return ( <> @@ -201,15 +214,23 @@ export default function Step4Rules({ Please check the generated rules first. - - Set Firestore Rules - - + {" "} + + Set Firestore Rules + + + {rulesStatus !== "LOADING" && typeof rulesStatus === "string" && ( {rulesStatus} @@ -246,7 +267,6 @@ export const checkRules = async ( sanitizedRules.includes( utilFns.replace(/\s{2,}/g, " ").replace(/\n/g, " ") ); - return hasRules; } catch (e: any) { console.error(e);