feat(console): confirm member and webhook removal

Removing a member, revoking an invite link and disabling a group's
webhook endpoint took effect on the first click. They now ask first;
disabling the webhook explains that senders still using the secret will
be rejected, and its button is styled as destructive.
This commit is contained in:
翅膀 committed 2026-10-17 00:29:51 +08:00
1 parent 24f5d0477c
commit 85f8cb74bc
5 files changed
+31 -3

No files matched your search

+13 -1
View File
@@ -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<void> {
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<void> {
}
async function revoke(inv: GroupInvite): Promise<void> {
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);
+8
View File
@@ -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<void> {
}
async function onDisable(): Promise<void> {
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 {
+8
View File
@@ -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<Locale, Dict> = { en, zh };
+1 -1
View File
@@ -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.
+1 -1
View File
@@ -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 处理即会生效。