feat: Working on storage modal in database page in order to add multiple backend storages. Adding a system to manage independently channels from organizations and from system admin.

This commit is contained in:
charlesgauthereau
2026-01-14 21:54:13 +01:00
parent d8e9e2dac3
commit 91f25bc25d
32 changed files with 7663 additions and 461 deletions
@@ -74,7 +74,6 @@ export const ChannelAddEditModal = ({
}
</DialogTrigger>
)}
<DialogContent onOpenAutoFocus={(e) => e.preventDefault()}>
<DialogHeader>
<DialogTitle> {isCreate ? "Add" : "Edit"} {channelText} Channel</DialogTitle>
@@ -82,11 +81,8 @@ export const ChannelAddEditModal = ({
Configure your {channelText.toLowerCase()} channel preferences.
</DialogDescription>
</DialogHeader>
<div>
{adminView ?
<Tabs className="flex flex-col flex-1" defaultValue="configuration">
<TabsList className="grid w-full grid-cols-2">
<TabsTrigger value="configuration">Configuration</TabsTrigger>
@@ -25,9 +25,12 @@ export type ChannelCardProps = {
export const ChannelCard = (props: ChannelCardProps) => {
const {data, organization, kind} = props;
const {data, organization, kind, adminView} = props;
const isMobile = useIsMobile()
const isOwned = data.organizationId ? true : !organization;
const isLocalSystem = data.provider == "local";
return (
<div className="block transition-all duration-200 rounded-xl">
<Card className="flex flex-row justify-between p-4">
@@ -38,7 +41,6 @@ export const ChannelCard = (props: ChannelCardProps) => {
</div>
<div className={`h-2 w-2 rounded-full ${data.enabled ? "bg-green-600" : "bg-muted"}`}/>
</div>
<div className="flex justify-start w-full">
<div className="flex flex-col items-start md:flex-row md:items-center gap-2 ">
<h3 className="font-medium text-foreground">{isMobile ? truncateWords(data.name, 2) : data.name}</h3>
@@ -49,18 +51,22 @@ export const ChannelCard = (props: ChannelCardProps) => {
</div>
{kind && (
<div className="flex items-center gap-2">
<EditChannelButton
organizations={props.organizations}
adminView={props.adminView}
organization={organization}
channel={data}
kind={kind}
/>
<DeleteChannelButton
kind={kind}
organizationId={organization?.id}
channelId={data.id}
/>
{(isOwned && !isLocalSystem) && (
<>
<EditChannelButton
organizations={props.organizations}
adminView={props.adminView}
organization={organization}
channel={data}
kind={kind}
/>
<DeleteChannelButton
kind={kind}
organizationId={organization?.id}
channelId={data.id}
/>
</>
)}
</div>
)}
</Card>
@@ -94,16 +94,13 @@ export const ChannelForm = ({onSuccessAction, organization, defaultValues, kind}
});
const provider = form.watch("provider");
const channelTypes = kind == "notification" ? notificationTypes : storageTypes
const selectedProviderDetails = channelTypes.find(t => t.value === provider);
if (isCreate && !provider) {
return (
<div className="grid grid-cols-2 sm:grid-cols-3 gap-4 py-4">
{channelTypes.map((type) => {
{channelTypes.filter(p => p.value != "local").map((type) => {
const Icon = type.icon;
return (
<Card
@@ -28,6 +28,7 @@ export const addNotificationChannelAction = userAction.schema(
name: data.name,
config: data.config,
enabled: data.enabled ?? true,
organizationId: organizationId ?? null,
})
.returning();
@@ -29,6 +29,7 @@ export const addStorageChannelAction = userAction.schema(
name: data.name,
config: data.config,
enabled: data.enabled ?? true,
organizationId: organizationId ?? null
})
.returning();
@@ -75,7 +76,7 @@ export const removeStorageChannelAction = userAction.schema(
try {
if (organizationId) {
await db
.delete(drizzleDb.schemas.organizationNotificationChannel)
.delete(drizzleDb.schemas.organizationStorageChannel)
.where(
and(
eq(drizzleDb.schemas.organizationStorageChannel.organizationId, organizationId),