refactor: simplify default value assignment in EditModal and update TriggerSubscription types

- Updated the default value assignment in the EditModal component to use a more concise syntax.
- Changed TriggerSubscription structure to use generic Record types for credentials, parameters, and properties, enhancing flexibility.
This commit is contained in:
Harry
2025-12-16 17:42:21 +08:00
parent ade3e24dd2
commit f8503f31f3
2 changed files with 4 additions and 21 deletions

View File

@@ -122,7 +122,7 @@ export const EditModal = ({ onClose, subscription, pluginDetail }: Props) => {
...schema, ...schema,
type: normalizeFormType(schema.type as string), type: normalizeFormType(schema.type as string),
tooltip: schema.description, tooltip: schema.description,
default: (subscription.properties as Record<string, any>)?.[schema.name] ?? schema.default, default: subscription.properties?.[schema.name] || schema.default,
})), })),
], [t, subscription.name, subscription.endpoint, subscription.properties, propertiesSchema]) ], [t, subscription.name, subscription.endpoint, subscription.properties, propertiesSchema])

View File

@@ -237,32 +237,15 @@ type TriggerSubscriptionStructure = {
name: string name: string
provider: string provider: string
credential_type: TriggerCredentialTypeEnum credential_type: TriggerCredentialTypeEnum
credentials: TriggerSubCredentials credentials: Record<string, any>
endpoint: string endpoint: string
parameters: TriggerSubParameters parameters: Record<string, any>
properties: TriggerSubProperties properties: Record<string, any>
workflows_in_use: number workflows_in_use: number
} }
export type TriggerSubscription = TriggerSubscriptionStructure export type TriggerSubscription = TriggerSubscriptionStructure
export type TriggerSubCredentials = {
access_tokens: string
}
export type TriggerSubParameters = {
repository: string
webhook_secret?: string
}
export type TriggerSubProperties = {
active: boolean
events: string[]
external_id: string
repository: string
webhook_secret?: string
}
export type TriggerSubscriptionBuilder = TriggerSubscriptionStructure export type TriggerSubscriptionBuilder = TriggerSubscriptionStructure
// OAuth configuration types // OAuth configuration types