From bce1c5d9b85ff5f949f38a9c6e588d2e60773e7a Mon Sep 17 00:00:00 2001 From: charlesgauthereau Date: Sat, 17 Jan 2026 22:41:39 +0100 Subject: [PATCH] feat: adding storage system ping method in order to test. --- .../(admin)/storages/channels/page.tsx | 2 +- .../channel-form/channel-test-button.tsx | 17 +++++++++-- src/features/storages/providers/index.ts | 7 +++-- src/features/storages/providers/local.ts | 18 ++++++++++++ src/features/storages/providers/s3.ts | 28 +++++++++++++++++++ src/features/storages/types.ts | 3 +- 6 files changed, 68 insertions(+), 7 deletions(-) diff --git a/app/(customer)/dashboard/(admin)/storages/channels/page.tsx b/app/(customer)/dashboard/(admin)/storages/channels/page.tsx index e265ae74..e7d58774 100644 --- a/app/(customer)/dashboard/(admin)/storages/channels/page.tsx +++ b/app/(customer)/dashboard/(admin)/storages/channels/page.tsx @@ -3,7 +3,7 @@ import {Page, PageActions, PageContent, PageHeader, PageTitle} from "@/features/ import {Metadata} from "next"; import {ChannelsSection} from "@/components/wrappers/dashboard/admin/channels/channels-section"; import {db} from "@/db"; -import {desc, eq, isNotNull, isNull, not} from "drizzle-orm"; +import {desc, eq, isNull} from "drizzle-orm"; import * as drizzleDb from "@/db"; import {StorageChannelWith} from "@/db/schema/12_storage-channel"; import {ChannelAddEditModal} from "@/components/wrappers/dashboard/admin/channels/channel/channel-add-edit-modal"; diff --git a/src/components/wrappers/dashboard/admin/channels/channel/channel-form/channel-test-button.tsx b/src/components/wrappers/dashboard/admin/channels/channel/channel-form/channel-test-button.tsx index 39b52903..e5a0f212 100644 --- a/src/components/wrappers/dashboard/admin/channels/channel/channel-form/channel-test-button.tsx +++ b/src/components/wrappers/dashboard/admin/channels/channel/channel-form/channel-test-button.tsx @@ -10,6 +10,8 @@ import {useIsMobile} from "@/hooks/use-mobile"; import {cn} from "@/lib/utils"; import {StorageChannel} from "@/db/schema/12_storage-channel"; import {ChannelKind, getChannelTextBasedOnKind} from "@/components/wrappers/dashboard/admin/channels/helpers/common"; +import type {StorageInput} from "@/features/storages/types"; +import {dispatchStorage} from "@/features/storages/dispatch"; type NotifierTestChannelButtonProps = { channel: NotificationChannel | StorageChannel; @@ -19,7 +21,6 @@ type NotifierTestChannelButtonProps = { export const ChannelTestButton = ({channel, organizationId, kind}: NotifierTestChannelButtonProps) => { const channelText = getChannelTextBasedOnKind(kind) - const isMobile = useIsMobile() const mutation = useMutation({ mutationFn: async () => { @@ -34,7 +35,18 @@ export const ChannelTestButton = ({channel, organizationId, kind}: NotifierTestC if (result.success) { toast.success(result.message); } else { - toast.error("An error occurred while testing the notification channel"); + toast.error("An error occurred while testing the notification channel, check your configuration"); + } + } else if (kind === "storage") { + const input: StorageInput = { + action: "ping", + }; + const result = await dispatchStorage(input, undefined, channel.id); + + if (result.success) { + toast.success("Successfully connected to storage channel"); + } else { + toast.error("An error occurred while testing the storage channel, check your configuration"); } } else { toast.error("Not yet supported"); @@ -43,7 +55,6 @@ export const ChannelTestButton = ({channel, organizationId, kind}: NotifierTestC }, }); - return (