mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-03 23:12:35 +00:00
Plugins base (#613)
* wip * wip * cleanup * notification channels * phpstan * services * remove server types * refactoring * refactoring
This commit is contained in:
@ -19,6 +19,8 @@ import { Form, FormField, FormFields } from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { SharedData } from '@/types';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import { DynamicFieldConfig } from '@/types/dynamic-field-config';
|
||||
import DynamicField from '@/components/ui/dynamic-field';
|
||||
|
||||
type NotificationChannelForm = {
|
||||
provider: string;
|
||||
@ -27,12 +29,10 @@ type NotificationChannelForm = {
|
||||
};
|
||||
|
||||
export default function ConnectNotificationChannel({
|
||||
providers,
|
||||
defaultProvider,
|
||||
onProviderAdded,
|
||||
children,
|
||||
}: {
|
||||
providers: string[];
|
||||
defaultProvider?: string;
|
||||
onProviderAdded?: () => void;
|
||||
children: ReactNode;
|
||||
@ -62,7 +62,7 @@ export default function ConnectNotificationChannel({
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger asChild>{children}</DialogTrigger>
|
||||
<DialogContent className="max-h-screen overflow-y-auto sm:max-w-2xl">
|
||||
<DialogContent className="max-h-screen overflow-y-auto sm:max-w-lg">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Connect to notification channel</DialogTitle>
|
||||
<DialogDescription className="sr-only">Connect to a new notification channel</DialogDescription>
|
||||
@ -83,9 +83,9 @@ export default function ConnectNotificationChannel({
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
{providers.map((provider) => (
|
||||
<SelectItem key={provider} value={provider}>
|
||||
{provider}
|
||||
{Object.entries(page.props.configs.notification_channel.providers).map(([key, provider]) => (
|
||||
<SelectItem key={key} value={key}>
|
||||
{provider.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectGroup>
|
||||
@ -105,29 +105,18 @@ export default function ConnectNotificationChannel({
|
||||
/>
|
||||
<InputError message={form.errors.name} />
|
||||
</FormField>
|
||||
<div
|
||||
className={
|
||||
page.props.configs.notification_channels_providers_custom_fields[form.data.provider].length > 1
|
||||
? 'grid grid-cols-2 items-start gap-6'
|
||||
: ''
|
||||
}
|
||||
>
|
||||
{page.props.configs.notification_channels_providers_custom_fields[form.data.provider]?.map((item: string) => (
|
||||
<FormField key={item}>
|
||||
<Label htmlFor={item} className="capitalize">
|
||||
{item.replaceAll('_', ' ')}
|
||||
</Label>
|
||||
<Input
|
||||
type="text"
|
||||
name={item}
|
||||
id={item}
|
||||
value={(form.data[item as keyof NotificationChannelForm] as string) ?? ''}
|
||||
onChange={(e) => form.setData(item as keyof NotificationChannelForm, e.target.value)}
|
||||
/>
|
||||
<InputError message={form.errors[item as keyof NotificationChannelForm]} />
|
||||
</FormField>
|
||||
))}
|
||||
</div>
|
||||
{page.props.configs.notification_channel.providers[form.data.provider]?.form?.map((field: DynamicFieldConfig) => (
|
||||
<DynamicField
|
||||
key={`field-${field.name}`}
|
||||
/*@ts-expect-error dynamic types*/
|
||||
value={form.data[field.name]}
|
||||
/*@ts-expect-error dynamic types*/
|
||||
onChange={(value) => form.setData(field.name, value)}
|
||||
config={field}
|
||||
/*@ts-expect-error dynamic types*/
|
||||
error={form.errors[field.name]}
|
||||
/>
|
||||
))}
|
||||
<FormField>
|
||||
<div className="flex items-center space-x-3">
|
||||
<Checkbox id="global" name="global" checked={form.data.global} onClick={() => form.setData('global', !form.data.global)} />
|
||||
|
Reference in New Issue
Block a user