From 67004368d95de8d484dc5a8abe62f544b97cd214 Mon Sep 17 00:00:00 2001 From: yessenia Date: Thu, 11 Sep 2025 16:13:13 +0800 Subject: [PATCH] feat: sub card style --- .../subscription-list/index.tsx | 15 ++- .../subscription-list/subscription-card.tsx | 121 +++++------------- web/i18n/en-US/plugin-trigger.ts | 1 + web/i18n/zh-Hans/plugin-trigger.ts | 1 + 4 files changed, 45 insertions(+), 93 deletions(-) diff --git a/web/app/components/plugins/plugin-detail-panel/subscription-list/index.tsx b/web/app/components/plugins/plugin-detail-panel/subscription-list/index.tsx index ff95d6cd08..9c7ae0c7cc 100644 --- a/web/app/components/plugins/plugin-detail-panel/subscription-list/index.tsx +++ b/web/app/components/plugins/plugin-detail-panel/subscription-list/index.tsx @@ -30,7 +30,7 @@ export const SubscriptionList = ({ detail }: Props) => { const showTopBorder = detail.declaration.tool || detail.declaration.endpoint // Fetch subscriptions - const { data: subscriptions, isLoading } = useTriggerSubscriptions(`${detail.plugin_id}/${detail.declaration.name}`) + const { data: subscriptions, isLoading, refetch } = useTriggerSubscriptions(`${detail.plugin_id}/${detail.declaration.name}`) // Modal states const [isShowAddModal, { @@ -58,8 +58,7 @@ export const SubscriptionList = ({ detail }: Props) => { } const handleRefreshList = () => { - // This will be called after successful operations - // The query will auto-refresh due to React Query + refetch() } if (isLoading) { @@ -98,9 +97,11 @@ export const SubscriptionList = ({ detail }: Props) => { ) : ( // List state with header and secondary add button <> -
-
- {t('pluginTrigger.subscription.list.title')} +
+
+ + {t('pluginTrigger.subscription.listNum', { num: subscriptions?.length || 0 })} + {
-
+
{subscriptions?.map(subscription => ( void } -const getProviderIcon = (provider: string) => { - switch (provider) { - case 'github': - return - case 'gitlab': - return - default: - return - } -} - -const getCredentialIcon = (credentialType: string) => { - switch (credentialType) { - case 'oauth2': - return - case 'api_key': - return - case 'unauthorized': - return - default: - return - } -} - const SubscriptionCard = ({ data, onRefresh }: Props) => { const { t } = useTranslation() - const [isHovered, setIsHovered] = useState(false) const [isShowDeleteModal, { setTrue: showDeleteModal, setFalse: hideDeleteModal, }] = useBoolean(false) - // API mutations const { mutate: deleteSubscription, isPending: isDeleting } = useDeleteTriggerSubscription() const handleDelete = () => { @@ -71,78 +43,55 @@ const SubscriptionCard = ({ data, onRefresh }: Props) => { type: 'error', message: error?.message || 'Failed to delete subscription', }) - hideDeleteModal() }, }) } - // Determine if subscription is active/enabled based on properties const isActive = data.properties?.active !== false return ( <>
setIsHovered(true)} - onMouseLeave={() => setIsHovered(false)} > -
-
- {getProviderIcon(data.provider)} +
+
+ + + {data.name} +
-
-
- - {data.name} - - {getCredentialIcon(data.credential_type)} -
-
- {data.provider} - - - {isActive - ? t('pluginTrigger.subscription.list.item.status.active') - : t('pluginTrigger.subscription.list.item.status.inactive') - } - -
+ +
+ +
+ +
+ + +
- {/* Delete button - only show on hover */} -
- - - +
+
+ {data.endpoint} +
+
·
+
+ {isActive ? 'Used by 3 workflows' : 'No workflow used'} +
diff --git a/web/i18n/en-US/plugin-trigger.ts b/web/i18n/en-US/plugin-trigger.ts index 4c636d7f2f..a7689dec7b 100644 --- a/web/i18n/en-US/plugin-trigger.ts +++ b/web/i18n/en-US/plugin-trigger.ts @@ -1,6 +1,7 @@ const translation = { subscription: { title: 'Subscriptions', + listNum: '{{num}} subscriptions', empty: { title: 'No subscriptions', description: 'Create your first subscription to start receiving events', diff --git a/web/i18n/zh-Hans/plugin-trigger.ts b/web/i18n/zh-Hans/plugin-trigger.ts index 6f623736e8..6d0534f553 100644 --- a/web/i18n/zh-Hans/plugin-trigger.ts +++ b/web/i18n/zh-Hans/plugin-trigger.ts @@ -1,6 +1,7 @@ const translation = { subscription: { title: '订阅', + listNum: '{{num}} 个订阅', empty: { title: '暂无订阅', description: '创建您的第一个订阅以开始接收事件',