From 9d990c9ed0ea2d6a2a118fef99f7359b937c094d Mon Sep 17 00:00:00 2001
From: mbaharip <62494292+mbahArip@users.noreply.github.com>
Date: Tue, 28 Jan 2025 07:18:52 +0700
Subject: [PATCH 1/3] update: deploy guide
---
src/components/internal/DeployPage.tsx | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/src/components/internal/DeployPage.tsx b/src/components/internal/DeployPage.tsx
index e503d18..b8f51dc 100644
--- a/src/components/internal/DeployPage.tsx
+++ b/src/components/internal/DeployPage.tsx
@@ -62,11 +62,7 @@ If you are new, you can follow along from the beginning. However, if you have pr
You can also utilize the [next-gdrive-index configurator](/ngdi-internal/configurator) to generate configuration for your deployment!
-This guide assumes that you have a fundamental understanding of how to deploy a Next.js application on Vercel or other platforms.
-
----
-
-If you prefer a video tutorial, you can watch the video below to deploy the project.`,
+This guide assumes that you have a fundamental understanding of how to deploy a Next.js application on Vercel or other platforms.`,
newUser: `For new user, this guide will provide step-by-step instructions on deploying the project to Vercel or similar services.
Before you begin, you'll need to have the following:
@@ -495,14 +491,14 @@ export default function DeployPage() {
customComponents={customComponents}
content={guide.gettingStarted.content}
/>
-
+ > */}
From 5cba2f7452b7a9fcdaf8d4fa3952053622097e7a Mon Sep 17 00:00:00 2001
From: mbaharip <62494292+mbahArip@users.noreply.github.com>
Date: Tue, 28 Jan 2025 07:34:11 +0700
Subject: [PATCH 2/3] fix: Load JSON button not loading when processing
---
.../internal/ConfiguratorPage.Environment.tsx | 90 ++++++++++---------
1 file changed, 48 insertions(+), 42 deletions(-)
diff --git a/src/components/internal/ConfiguratorPage.Environment.tsx b/src/components/internal/ConfiguratorPage.Environment.tsx
index 9bb0c26..0a0967a 100644
--- a/src/components/internal/ConfiguratorPage.Environment.tsx
+++ b/src/components/internal/ConfiguratorPage.Environment.tsx
@@ -1,54 +1,58 @@
"use client";
-import { type ChangeEvent, useRef, useState } from "react";
+import { useState } from "react";
import { toast } from "sonner";
import { LoadingButton } from "~/components/ui/button";
import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from "~/components/ui/form";
import { Input } from "~/components/ui/input";
+import { type PickFileResponse, pickFile } from "~/lib/configurationHelper";
+
import { GenerateServiceAccountB64 } from "~/actions/configuration";
import { type FormProps, FormSection } from "./ConfiguratorPage";
export default function EnvironmentForm({ onResetField, form }: FormProps) {
- const serviceInputRef = useRef(null);
- const [serviceInputLoading, setServiceInputLoading] = useState(false);
+ const [isLoadServiceLoading, setLoadServiceLoading] = useState(false);
- function onLoadServiceAccount(e: ChangeEvent) {
- setServiceInputLoading(true);
- toast.loading("Processing service account file", {
- id: "service-account",
+ async function onLoadServiceAccount(response: PickFileResponse) {
+ const id = `service-account-${Date.now()}`;
+ toast.loading("Waiting for file...", {
+ id,
+ duration: 0,
});
-
- try {
- const file = e.target.files?.[0];
- if (!file) throw new Error("No file selected");
-
- const fr = new FileReader();
- fr.onload = async () => {
- if (!fr.result) throw new Error("Failed to read file content");
- const stringResult = typeof fr.result === "object" ? JSON.stringify(fr.result) : String(fr.result);
- const b64 = await GenerateServiceAccountB64(stringResult);
- if (!b64.success) throw new Error(b64.error);
-
- form.setValue("environment.GD_SERVICE_B64", b64.data);
- toast.success("Service account encoded", {
- id: "service-account",
- });
- };
- fr.readAsText(file);
- } catch (error) {
- const e = error as Error;
- console.error(e.message);
+ if (!response.success) {
toast.error("Failed to load service account file", {
- description: e.message,
- id: "service-account",
+ id,
+ description: response.details.length ? (
+
+ {response.details.join("\n")}
+
+ ) : undefined,
});
- } finally {
- e.target.value = ""; // Reset file input wether success or not
- setServiceInputLoading(false);
+ setLoadServiceLoading(false);
+ return;
}
+
+ toast.loading("Processing service account file", {
+ id,
+ });
+ const data = await GenerateServiceAccountB64(response.data);
+ if (!data.success) {
+ toast.error("Failed to encode service account", {
+ id,
+ description: