mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-23 00:21:28 +00:00
feat(groups): allow renaming a group id
Add PUT /admin/api/groups/:id/rename (owner role) which re-points the group's routes, migrates the per-group webhook secret (tenant:{id}) and pending invites, and records an audit entry. The group editor's id field is now editable and the console renames first, then persists remaining edits under the new id.
This commit is contained in:
parent
39bb639883
commit
f4959eebf8
11 changed files with 372 additions and 53 deletions
|
|
@ -70,6 +70,24 @@ export function useGroupsApi() {
|
|||
groups.value = next;
|
||||
}
|
||||
|
||||
/** Rename a group; routes, webhook secret and invites follow automatically. */
|
||||
async function rename(oldId: string, newId: string): Promise<void> {
|
||||
const res = await fetch(`/admin/api/groups/${encodeURIComponent(oldId)}/rename`, {
|
||||
method: "PUT",
|
||||
headers: { "content-type": "application/json" },
|
||||
credentials: "same-origin",
|
||||
body: JSON.stringify({ newId }),
|
||||
});
|
||||
if (res.status === 401) {
|
||||
needLogin.value = true;
|
||||
throw new Error("unauthorized");
|
||||
}
|
||||
if (!res.ok) {
|
||||
const data = (await res.json().catch(() => ({}))) as { error?: string };
|
||||
throw new Error(data.error ?? `HTTP ${res.status}`);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
groups,
|
||||
isSuper,
|
||||
|
|
@ -82,5 +100,6 @@ export function useGroupsApi() {
|
|||
error,
|
||||
load,
|
||||
save,
|
||||
rename,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,6 +167,8 @@ const en: Dict = {
|
|||
"groupEditor.id": "ID",
|
||||
"groupEditor.idPlaceholder": "my-team",
|
||||
"groupEditor.idHint": "Unique, use a-z / 0-9 / dashes",
|
||||
"groupEditor.renameHint":
|
||||
"Changing the id also updates routes, webhook secrets and invites that reference this group.",
|
||||
"groupEditor.language": "Message language",
|
||||
"groupEditor.langPlaceholder": "en",
|
||||
"groupEditor.langHint": "en or zh; custom via KV i18n:<lang>",
|
||||
|
|
@ -416,6 +418,7 @@ const zh: Dict = {
|
|||
"groupEditor.id": "ID",
|
||||
"groupEditor.idPlaceholder": "my-team",
|
||||
"groupEditor.idHint": "唯一,使用 a-z / 0-9 / 短横线",
|
||||
"groupEditor.renameHint": "修改 id 会同步更新引用该分组的路由、webhook secret 与邀请链接。",
|
||||
"groupEditor.language": "消息语言",
|
||||
"groupEditor.langPlaceholder": "zh",
|
||||
"groupEditor.langHint": "en 或 zh;可通过 KV i18n:<lang> 自定义",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue