diff --git a/app/components/MembersPanel.vue b/app/components/MembersPanel.vue index f1fe841..ccc2320 100644 --- a/app/components/MembersPanel.vue +++ b/app/components/MembersPanel.vue @@ -94,6 +94,7 @@ import type { Group, GroupInvite, GroupMember, GroupRole } from "~/types"; import { useInvitesApi } from "~/composables/useInvites"; const { t } = useI18n(); +const { confirm } = useConfirm(); const props = defineProps<{ group: Group; canEdit: boolean; saving: boolean }>(); const emit = defineEmits<{ (e: "save", group: Group): void }>(); @@ -156,11 +157,17 @@ function addMember(): void { emitSave(); } -function removeMember(m: GroupMember): void { +async function removeMember(m: GroupMember): Promise { + formError.value = ""; if (m.role === "owner" && ownerCount() === 1) { formError.value = t("members.errLastOwner"); return; } + const confirmed = await confirm({ + title: t("confirm.removeMember", { name: m.login }), + confirmText: t("members.remove"), + }); + if (!confirmed) return; members.value = members.value.filter((x) => x !== m); emitSave(); } @@ -202,6 +209,11 @@ async function copyInvite(inv: GroupInvite): Promise { } async function revoke(inv: GroupInvite): Promise { + const confirmed = await confirm({ + title: t("confirm.revokeInvite"), + confirmText: t("members.revoke"), + }); + if (!confirmed) return; try { await invitesApi.revoke(inv.token); invites.value = invites.value.filter((i) => i.token !== inv.token); diff --git a/app/components/WebhookPanel.vue b/app/components/WebhookPanel.vue index e0f797f..92923d9 100644 --- a/app/components/WebhookPanel.vue +++ b/app/components/WebhookPanel.vue @@ -41,6 +41,7 @@ v-if="info.hasSecret" type="button" variant="ghost" + color="error" size="sm" :disabled="busy" @click="onDisable" @@ -67,6 +68,7 @@ import { ref, watch } from "vue"; import { useWebhookApi, type GroupWebhookInfo } from "~/composables/useWebhook"; const { t } = useI18n(); +const { confirm } = useConfirm(); const props = defineProps<{ groupId: string; canEdit: boolean }>(); @@ -123,6 +125,12 @@ async function onRegenerate(): Promise { } async function onDisable(): Promise { + const confirmed = await confirm({ + title: t("confirm.disableWebhook"), + description: t("confirm.disableWebhookDetail"), + confirmText: t("webhook.disable"), + }); + if (!confirmed) return; busy.value = true; error.value = ""; try { diff --git a/app/composables/useI18n.ts b/app/composables/useI18n.ts index 22c6dcd..dcb13eb 100644 --- a/app/composables/useI18n.ts +++ b/app/composables/useI18n.ts @@ -396,6 +396,10 @@ const en: Dict = { "confirm.deleteGroupWarn": " {n} route(s) reference it and will lose their group.", "confirm.cancel": "Cancel", "confirm.delete": "Delete", + "confirm.removeMember": 'Remove member "{name}"?', + "confirm.revokeInvite": "Revoke this invite link?", + "confirm.disableWebhook": "Disable this group's webhook endpoint?", + "confirm.disableWebhookDetail": "The secret is deleted; senders still using it will be rejected.", }; const zh: Dict = { @@ -786,6 +790,10 @@ const zh: Dict = { "confirm.deleteGroupWarn": " 有 {n} 条路由引用它,将失去所属分组。", "confirm.cancel": "取消", "confirm.delete": "删除", + "confirm.removeMember": "确定移除成员“{name}”吗?", + "confirm.revokeInvite": "确定撤销该邀请链接吗?", + "confirm.disableWebhook": "确定停用该分组的 webhook 入口吗?", + "confirm.disableWebhookDetail": "secret 将被删除,仍在使用它的发送方会被拒绝。", }; const messages: Record = { en, zh }; diff --git a/docs/guide/configuration.md b/docs/guide/configuration.md index 1ce2802..9cf3eae 100644 --- a/docs/guide/configuration.md +++ b/docs/guide/configuration.md @@ -65,7 +65,7 @@ For local debugging only, set `DEBUG_MODE=true` to bypass GitHub OAuth and grant The console is served as an SPA at `/admin`; its tabs are deep-linkable via the URL path (`/admin/groups`, `/admin/logs`, `/admin/audit`). URLs outside `/admin` that do not match an endpoint return a plain `404` instead of the console. -Destructive actions — deleting routes or groups — ask for confirmation in an in-app dialog. +Destructive actions — deleting routes or groups, removing members, revoking invites, disabling a group's webhook — ask for confirmation in an in-app dialog. All management endpoints (`/admin/api/*`) are documented in the [Admin API](../api/admin). Saved routes and groups are persisted to D1 (`d1_routes` / `d1_groups`) immediately, the KV cache is invalidated and the config cache is refreshed so the webhook pipeline picks them up on the next run. diff --git a/docs/zh/guide/configuration.md b/docs/zh/guide/configuration.md index fcacb35..f995d70 100644 --- a/docs/zh/guide/configuration.md +++ b/docs/zh/guide/configuration.md @@ -64,7 +64,7 @@ WebHooker 在 `/admin` 提供内置配置控制台,可在浏览器中管理路 控制台以 SPA 形式在 `/admin` 提供;其标签页可通过 URL 路径直达(`/admin/groups`、`/admin/logs`、`/admin/audit`)。`/admin` 之外未匹配到端点的 URL 直接返回 `404`,而不会展示控制台。 -删除类操作——删除路由或分组——都会先弹出应用内确认框。 +删除类操作——删除路由或分组,移除成员,撤销邀请,停用分组 webhook——都会先弹出应用内确认框。 所有管理端点(`/admin/api/*`)见 [Admin API](../api/admin)。保存的路由和分组会立即持久化到 D1(`d1_routes` / `d1_groups`),并使 KV 缓存失效、刷新配置缓存,下一次 webhook 处理即会生效。