mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
remove service account step
This commit is contained in:
Binary file not shown.
@@ -13,7 +13,7 @@ import { rowyRun } from "@src/utils/rowyRun";
|
||||
import { runRoutes } from "@src/constants/runRoutes";
|
||||
import CopyIcon from "@src/assets/icons/Copy";
|
||||
|
||||
export default function Step3ProjectOwner({
|
||||
export default function Step2ProjectOwner({
|
||||
rowyRunUrl,
|
||||
completion,
|
||||
setCompletion,
|
||||
@@ -1,174 +0,0 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import { ISetupStepBodyProps } from "@src/pages/Setup";
|
||||
|
||||
import { Typography, Link, Stack } from "@mui/material";
|
||||
import LoadingButton from "@mui/lab/LoadingButton";
|
||||
import InlineOpenInNewIcon from "@src/components/InlineOpenInNewIcon";
|
||||
|
||||
import SetupItem from "./SetupItem";
|
||||
|
||||
import { name } from "@root/package.json";
|
||||
import { useAppContext } from "@src/contexts/AppContext";
|
||||
import { rowyRun } from "@src/utils/rowyRun";
|
||||
import { runRoutes } from "@src/constants/runRoutes";
|
||||
import { WIKI_LINKS } from "@src/constants/externalLinks";
|
||||
import screenRecording from "@src/assets/service-account.mp4";
|
||||
|
||||
export default function Step2ServiceAccount({
|
||||
rowyRunUrl,
|
||||
completion,
|
||||
setCompletion,
|
||||
}: ISetupStepBodyProps) {
|
||||
const [hasAllRoles, setHasAllRoles] = useState(completion.serviceAccount);
|
||||
// const [roles, setRoles] = useState<Record<string, any>>({});
|
||||
const [verificationStatus, setVerificationStatus] = useState<
|
||||
"IDLE" | "LOADING" | "FAIL"
|
||||
>("IDLE");
|
||||
|
||||
const { projectId } = useAppContext();
|
||||
const [region, setRegion] = useState("");
|
||||
useEffect(() => {
|
||||
fetch(rowyRunUrl + runRoutes.region.path, {
|
||||
method: runRoutes.region.method,
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((data) => setRegion(data.region))
|
||||
.catch((e) => console.error(e));
|
||||
}, []);
|
||||
|
||||
const verifyRoles = async () => {
|
||||
setVerificationStatus("LOADING");
|
||||
try {
|
||||
const result = await checkServiceAccount(rowyRunUrl);
|
||||
// setRoles(result);
|
||||
if (result.hasAllRoles) {
|
||||
setVerificationStatus("IDLE");
|
||||
setHasAllRoles(true);
|
||||
setCompletion((c) => ({ ...c, serviceAccount: true }));
|
||||
} else {
|
||||
setVerificationStatus("FAIL");
|
||||
setHasAllRoles(false);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setVerificationStatus("FAIL");
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Typography variant="inherit">
|
||||
{name} Run uses a{" "}
|
||||
<Link
|
||||
href="https://firebase.google.com/support/guides/service-accounts"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
color="text.primary"
|
||||
>
|
||||
service account
|
||||
</Link>{" "}
|
||||
to access your project. It operates exclusively on your GCP project, so
|
||||
we never have access to any of your data.{" "}
|
||||
<Link
|
||||
href={WIKI_LINKS.rowyRun}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
color="text.secondary"
|
||||
>
|
||||
Learn more
|
||||
<InlineOpenInNewIcon />
|
||||
</Link>
|
||||
</Typography>
|
||||
|
||||
<SetupItem
|
||||
status={hasAllRoles ? "complete" : "incomplete"}
|
||||
title={
|
||||
hasAllRoles
|
||||
? "Rowy Run has access to a service account with all the required roles."
|
||||
: "Set up a service account with the following roles:"
|
||||
}
|
||||
>
|
||||
{!hasAllRoles && (
|
||||
<>
|
||||
<ul>
|
||||
<li>Service Account User</li>
|
||||
<li>Firebase Admin</li>
|
||||
</ul>
|
||||
|
||||
<Stack direction="row" spacing={1}>
|
||||
<LoadingButton
|
||||
// loading={!region}
|
||||
href={`https://console.cloud.google.com/run/deploy/${region}/rowy-run?project=${projectId}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Set up service account
|
||||
<InlineOpenInNewIcon />
|
||||
</LoadingButton>
|
||||
<LoadingButton
|
||||
variant="contained"
|
||||
color="primary"
|
||||
onClick={verifyRoles}
|
||||
loading={verificationStatus === "LOADING"}
|
||||
>
|
||||
Verify
|
||||
</LoadingButton>
|
||||
</Stack>
|
||||
|
||||
{verificationStatus === "FAIL" && (
|
||||
<Typography variant="inherit" color="error">
|
||||
Some roles are missing. Also make sure your Firebase project has
|
||||
Firestore and Authentication enabled.{" "}
|
||||
<Link
|
||||
href={WIKI_LINKS.setupFirebaseProject}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
color="text.primary"
|
||||
>
|
||||
Setup guide
|
||||
<InlineOpenInNewIcon />
|
||||
</Link>
|
||||
</Typography>
|
||||
)}
|
||||
|
||||
<Typography variant="inherit">
|
||||
Follow the steps in the screen recording below:
|
||||
</Typography>
|
||||
|
||||
<video
|
||||
src={screenRecording}
|
||||
controls
|
||||
muted
|
||||
playsInline
|
||||
style={{ width: "100%" }}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</SetupItem>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export const checkServiceAccount = async (
|
||||
serviceUrl: string,
|
||||
signal?: AbortSignal
|
||||
) => {
|
||||
try {
|
||||
const res = await rowyRun({
|
||||
serviceUrl,
|
||||
route: runRoutes.serviceAccountAccess,
|
||||
signal,
|
||||
});
|
||||
|
||||
return {
|
||||
...res,
|
||||
hasAllRoles: Object.values(res).reduce(
|
||||
(acc, value) => acc && value,
|
||||
true
|
||||
) as boolean,
|
||||
};
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -30,7 +30,7 @@ import { rowyRun } from "@src/utils/rowyRun";
|
||||
import { runRoutes } from "@src/constants/runRoutes";
|
||||
// import { useConfirmation } from "@src/components/ConfirmationDialog";
|
||||
|
||||
export default function Step4Rules({
|
||||
export default function Step3Rules({
|
||||
rowyRunUrl,
|
||||
completion,
|
||||
setCompletion,
|
||||
@@ -12,7 +12,7 @@ import { CONFIG } from "@src/config/dbPaths";
|
||||
import { rowyRun } from "@src/utils/rowyRun";
|
||||
import { runRoutes } from "@src/constants/runRoutes";
|
||||
|
||||
export default function Step5Migrate({
|
||||
export default function Step4Migrate({
|
||||
rowyRunUrl,
|
||||
completion,
|
||||
setCompletion,
|
||||
@@ -31,12 +31,11 @@ import { SlideTransition } from "@src/components/Modal/SlideTransition";
|
||||
import Step0Welcome from "@src/components/Setup/Step0Welcome";
|
||||
import Step1RowyRun, { checkRowyRun } from "@src/components/Setup/Step1RowyRun";
|
||||
// prettier-ignore
|
||||
import Step2ServiceAccount, { checkServiceAccount } from "@src/components/Setup/Step2ServiceAccount";
|
||||
// prettier-ignore
|
||||
import Step3ProjectOwner, { checkProjectOwner } from "@src/components/Setup/Step3ProjectOwner";
|
||||
import Step4Rules, { checkRules } from "@src/components/Setup/Step4Rules";
|
||||
import Step5Migrate, { checkMigrate } from "@src/components/Setup/Step5Migrate";
|
||||
import Step6Finish from "@src/components/Setup/Step6Finish";
|
||||
import Step2ProjectOwner, { checkProjectOwner } from "@src/components/Setup/Step2ProjectOwner";
|
||||
import Step3Rules, { checkRules } from "@src/components/Setup/Step3Rules";
|
||||
import Step4Migrate, { checkMigrate } from "@src/components/Setup/Step4Migrate";
|
||||
import Step5Finish from "@src/components/Setup/Step6Finish";
|
||||
|
||||
import { name } from "@root/package.json";
|
||||
import routes from "@src/constants/routes";
|
||||
@@ -77,9 +76,6 @@ const checkAllSteps = async (
|
||||
if (rowyRunValidation.isLatestVersion) completion.rowyRun = true;
|
||||
|
||||
const promises = [
|
||||
checkServiceAccount(rowyRunUrl, signal).then((serviceAccount) => {
|
||||
if (serviceAccount.hasAllRoles) completion.serviceAccount = true;
|
||||
}),
|
||||
checkProjectOwner(rowyRunUrl, currentUser, userRoles, signal).then(
|
||||
(projectOwner) => {
|
||||
if (projectOwner) completion.projectOwner = true;
|
||||
@@ -182,30 +178,24 @@ export default function SetupPage() {
|
||||
title: `Set up ${name} Run`,
|
||||
body: <Step1RowyRun {...stepProps} />,
|
||||
},
|
||||
{
|
||||
id: "serviceAccount",
|
||||
shortTitle: `Service account`,
|
||||
title: `Set up service account`,
|
||||
body: <Step2ServiceAccount {...stepProps} />,
|
||||
},
|
||||
{
|
||||
id: "projectOwner",
|
||||
shortTitle: `Project owner`,
|
||||
title: `Set up project owner`,
|
||||
body: <Step3ProjectOwner {...stepProps} />,
|
||||
body: <Step2ProjectOwner {...stepProps} />,
|
||||
},
|
||||
{
|
||||
id: "rules",
|
||||
shortTitle: `Rules`,
|
||||
title: `Set up Firestore Rules`,
|
||||
body: <Step4Rules {...stepProps} />,
|
||||
body: <Step3Rules {...stepProps} />,
|
||||
},
|
||||
completion.migrate !== undefined
|
||||
? {
|
||||
id: "migrate",
|
||||
shortTitle: `Migrate`,
|
||||
title: `Migrate to ${name} (optional)`,
|
||||
body: <Step5Migrate {...stepProps} />,
|
||||
body: <Step4Migrate {...stepProps} />,
|
||||
}
|
||||
: ({} as ISetupStep),
|
||||
{
|
||||
@@ -213,7 +203,7 @@ export default function SetupPage() {
|
||||
layout: "centered" as "centered",
|
||||
shortTitle: `Finish`,
|
||||
title: `You’re all set up!`,
|
||||
body: <Step6Finish />,
|
||||
body: <Step5Finish />,
|
||||
actions: (
|
||||
<Button
|
||||
variant="contained"
|
||||
|
||||
Reference in New Issue
Block a user