Skip to content

Commit bd89d61

Browse files
committed
refactor(logging): replace console.log with console.info for better log level usage
Replace `console.log` with `console.info` to better reflect the informational nature of the messages. This change improves log readability and aligns with best practices for log level usage. refactor(types): use unknown type instead of any for better type safety Replace `any` with `unknown` in various parts of the codebase to enhance type safety. This change encourages more explicit type checking and reduces potential runtime errors. refactor(api-client): use type assertion for error handling Use type assertion for errorBody in `handleResponseError` to ensure proper type handling and improve code clarity. refactor: remove unused configurator components and related exports Remove the `ConfiguratorPage` and related components as they are no longer needed. This cleanup reduces code complexity and improves maintainability. The changes improve code quality by enhancing type safety, aligning log levels with their intended use, and removing unused components to reduce complexity.
1 parent 1e31f68 commit bd89d61

File tree

15 files changed

+66
-2879
lines changed

15 files changed

+66
-2879
lines changed

src/actions/files.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -531,12 +531,12 @@ export async function GetStorageInfo(): Promise<
531531
config.apiConfig.isTeamDrive && config.apiConfig.sharedDrive
532532
);
533533

534-
console.log("[GetStorageInfo] isSharedDrive:", isSharedDrive);
535-
console.log(
534+
console.info("[GetStorageInfo] isSharedDrive:", isSharedDrive);
535+
console.info(
536536
"[GetStorageInfo] config.apiConfig.isTeamDrive:",
537537
config.apiConfig.isTeamDrive
538538
);
539-
console.log(
539+
console.info(
540540
"[GetStorageInfo] config.apiConfig.sharedDrive:",
541541
config.apiConfig.sharedDrive
542542
);
@@ -561,12 +561,12 @@ export async function GetStorageInfo(): Promise<
561561
{};
562562
let pageToken: string | null | undefined = null;
563563

564-
console.log(
564+
console.info(
565565
"[GetStorageInfo] Starting comprehensive scan of shared drive..."
566566
);
567567

568568
do {
569-
const response: any = await gdrive.files.list({
569+
const response: unknown = await gdrive.files.list({
570570
q: "trashed = false",
571571
fields: "files(id,name,size,mimeType,fileExtension), nextPageToken",
572572
supportsAllDrives: true,
@@ -577,8 +577,8 @@ export async function GetStorageInfo(): Promise<
577577
pageToken: pageToken || undefined,
578578
});
579579

580-
if (response.data.files) {
581-
for (const file of response.data.files) {
580+
if (response && (response as any).data.files) {
581+
for (const file of (response as any).data.files) {
582582
if (file.mimeType === "application/vnd.google-apps.folder") {
583583
totalFolders++;
584584
} else {
@@ -619,13 +619,13 @@ export async function GetStorageInfo(): Promise<
619619
}
620620
}
621621

622-
pageToken = response.data.nextPageToken;
623-
console.log(
622+
pageToken = (response as any).data.nextPageToken;
623+
console.info(
624624
`[GetStorageInfo] Processed page, total files so far: ${totalFiles}, folders: ${totalFolders}, size: ${(totalSize / 1024 ** 4).toFixed(2)} TB`
625625
);
626626
} while (pageToken);
627627

628-
console.log("[GetStorageInfo] Final stats:", {
628+
console.info("[GetStorageInfo] Final stats:", {
629629
totalFiles,
630630
totalFolders,
631631
totalSize,

src/app/ngdi-internal/configurator/page.tsx

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/app/page.tsx

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
1919
import Icon from "@/components/ui/icon";
2020
import { Separator } from "@/components/ui/separator";
2121
import { Skeleton } from "@/components/ui/skeleton";
22+
import { type Schema_File } from "@/types/schema";
23+
import { type z } from "zod";
2224

2325
type StorageInfo = {
2426
usage: { bytes: number; tb: number; gb: number };
@@ -40,6 +42,20 @@ type StorageInfo = {
4042
isSharedDrive: boolean;
4143
};
4244

45+
// Define the expected type for data objects
46+
interface FileData {
47+
data: {
48+
files: unknown[];
49+
nextPageToken?: string;
50+
};
51+
}
52+
interface ReadmeData {
53+
data: {
54+
content: string;
55+
type: string;
56+
};
57+
}
58+
4359
// Fallback components for Suspense
4460
const FileActionsFallback = () => (
4561
<div className="flex items-center gap-2">
@@ -263,6 +279,8 @@ export default function RootPage() {
263279
if (!data || !readme)
264280
return <div className="p-8 text-center">No data available</div>;
265281

282+
const files = (data as FileData).data?.files as z.infer<typeof Schema_File>[];
283+
266284
return (
267285
<div className={cn("h-fit w-full", "flex flex-col gap-6")}>
268286
{/* Combined Navigation/Status Bar */}
@@ -289,7 +307,7 @@ export default function RootPage() {
289307
{/* System Info Sidebar */}
290308
<div className="lg:col-span-1 space-y-4">
291309
<SystemInfoPanel
292-
rootItemCount={(data as any)?.data?.files?.length || 0}
310+
rootItemCount={(data as FileData).data?.files?.length || 0}
293311
/>
294312
</div>
295313

@@ -301,7 +319,7 @@ export default function RootPage() {
301319
<div className="flex items-center gap-3">
302320
<CardTitle className="grow font-mono">File System</CardTitle>
303321
<Badge variant="secondary" className="font-mono text-xs">
304-
{(data as any)?.data?.files?.length || 0} items
322+
{(data as FileData).data?.files?.length || 0} items
305323
</Badge>
306324
</div>
307325
<div className="flex items-center gap-2">
@@ -315,19 +333,21 @@ export default function RootPage() {
315333
<CardContent className="p-2 pt-0 tablet:p-4 tablet:pt-0">
316334
<FileExplorerLayout
317335
encryptedId={config.apiConfig.rootFolder}
318-
files={(data as any)?.data?.files || []}
319-
nextPageToken={(data as any)?.data?.nextPageToken ?? undefined}
336+
files={files}
337+
nextPageToken={
338+
(data as FileData).data?.nextPageToken ?? undefined
339+
}
320340
/>
321341
</CardContent>
322342
</Card>
323343
</div>
324344
</div>
325345

326-
{(readme as any)?.data && (
346+
{(readme as ReadmeData).data && (
327347
<Suspense fallback={<FileReadmeFallback />}>
328348
<FileReadme
329-
content={(readme as any).data.content}
330-
title={`README.${(readme as any).data.type === "markdown" ? "md" : "txt"}`}
349+
content={(readme as ReadmeData).data.content}
350+
title={`README.${(readme as ReadmeData).data.type === "markdown" ? "md" : "txt"}`}
331351
/>
332352
</Suspense>
333353
)}

src/components/explorer/FileLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const FileExplorerLayout = React.memo(
103103
<p className="text-muted-foreground text-center max-w-md font-mono text-sm">
104104
No files or directories found in current path.
105105
<br />
106-
<span className="text-xs mt-2 block flex items-center justify-center gap-2">
106+
<span className="text-xs mt-2 block items-center justify-center gap-2">
107107
<div className="w-1 h-1 bg-destructive rounded-full animate-pulse"></div>
108108
errno: ENOENT • status: 404
109109
</span>

0 commit comments

Comments
 (0)