fix(console): lock the group editor while saving

Prevent edits while a group save is in flight and make super-only
installation settings readonly instead of silently ignoring edits.
This commit is contained in:
翅膀 committed 2026-10-23 23:23:57 +08:00
1 parent f8dbb8ec0b
commit 0878a7768c
1 file changed
+211 -203
+211 -203
View File
@@ -14,225 +14,233 @@
</div> </div>
</template> </template>
<form class="editor-body" @submit.prevent="save"> <form class="editor-body" @submit.prevent="save">
<section class="editor-section"> <!-- Locked while saving: an edit made meanwhile would be lost when the
<h3 class="editor-section-title">{{ t("groupEditor.sectionBasic") }}</h3> save closes the editor. -->
<div class="row2"> <fieldset :disabled="saving" class="contents">
<div class="field"> <section class="editor-section">
<label>{{ t("groupEditor.name") }}</label> <h3 class="editor-section-title">{{ t("groupEditor.sectionBasic") }}</h3>
<RcInput <div class="row2">
v-model="form.name" <div class="field">
type="text" <label>{{ t("groupEditor.name") }}</label>
:placeholder="t('groupEditor.namePlaceholder')" <RcInput
required v-model="form.name"
/> type="text"
</div> :placeholder="t('groupEditor.namePlaceholder')"
<div class="field"> required
<label>{{ t("groupEditor.id") }}</label> />
<RcInput </div>
v-model="form.id" <div class="field">
type="text" <label>{{ t("groupEditor.id") }}</label>
:placeholder="t('groupEditor.idPlaceholder')" <RcInput
required v-model="form.id"
/> type="text"
<div class="hint"> :placeholder="t('groupEditor.idPlaceholder')"
{{ isEdit ? t("groupEditor.renameHint") : t("groupEditor.idHint") }} required
/>
<div class="hint">
{{ isEdit ? t("groupEditor.renameHint") : t("groupEditor.idHint") }}
</div>
</div> </div>
</div> </div>
</div> </section>
</section> <section class="editor-section">
<section class="editor-section"> <h3 class="editor-section-title">{{ t("groupEditor.sectionPreferences") }}</h3>
<h3 class="editor-section-title">{{ t("groupEditor.sectionPreferences") }}</h3> <div class="row2">
<div class="row2"> <div class="field">
<div class="field"> <label>{{ t("groupEditor.language") }}</label>
<label>{{ t("groupEditor.language") }}</label> <RcInput
<RcInput v-model="form.lang"
v-model="form.lang" type="text"
type="text" :placeholder="t('groupEditor.langPlaceholder')"
:placeholder="t('groupEditor.langPlaceholder')" />
/> <div class="hint">{{ t("groupEditor.langHint") }}</div>
<div class="hint">{{ t("groupEditor.langHint") }}</div> </div>
<div class="field">
<label
>{{ t("groupEditor.emoji") }}
<span class="lbl-note">{{ t("groupEditor.emojiNote") }}</span></label
>
<RcSwitch v-model="form.emoji" :label="t('groupEditor.emojiLabel')" />
</div>
</div> </div>
<div class="field"> <div class="field">
<label <label
>{{ t("groupEditor.emoji") }} >{{ t("groupEditor.forgeSources") }}
<span class="lbl-note">{{ t("groupEditor.emojiNote") }}</span></label <span class="lbl-note">{{ t("groupEditor.forgeSourcesNote") }}</span></label
> >
<RcSwitch v-model="form.emoji" :label="t('groupEditor.emojiLabel')" /> <div v-for="(s, i) in form.forgeSources" :key="i" class="forge-source-row">
</div> <div class="f-host">
</div> <RcInput
<div class="field"> v-model="s.host"
<label type="text"
>{{ t("groupEditor.forgeSources") }} :placeholder="t('groupEditor.forgeSourcesHost')"
<span class="lbl-note">{{ t("groupEditor.forgeSourcesNote") }}</span></label />
> </div>
<div v-for="(s, i) in form.forgeSources" :key="i" class="forge-source-row"> <div class="f-type">
<div class="f-host"> <RcSelect
<RcInput v-model="s.type"
v-model="s.host" :options="[
type="text" { label: 'GitHub', value: 'github' },
:placeholder="t('groupEditor.forgeSourcesHost')" { label: 'Gitea', value: 'gitea' },
/> ]"
/>
</div>
<RcButton
type="button"
variant="ghost"
color="error"
size="icon"
class="f-del h-9 w-9 text-muted hover:text-bad"
:title="t('groupEditor.forgeSourcesRemove')"
:aria-label="t('groupEditor.forgeSourcesRemove')"
@click="removeForgeSource(s)"
>
<Trash2 :size="15" />
</RcButton>
<div class="f-name">
<RcInput
v-model="s.name"
type="text"
:placeholder="t('groupEditor.forgeSourcesName')"
/>
</div>
</div> </div>
<div class="f-type"> <RcButton type="button" variant="ghost" class="add-filter" @click="addForgeSource">
<RcSelect {{ t("groupEditor.forgeSourcesAdd") }}
v-model="s.type"
:options="[
{ label: 'GitHub', value: 'github' },
{ label: 'Gitea', value: 'gitea' },
]"
/>
</div>
<RcButton
type="button"
variant="ghost"
color="error"
size="icon"
class="f-del h-9 w-9 text-muted hover:text-bad"
:title="t('groupEditor.forgeSourcesRemove')"
:aria-label="t('groupEditor.forgeSourcesRemove')"
@click="removeForgeSource(s)"
>
<Trash2 :size="15" />
</RcButton> </RcButton>
<div class="f-name"> <div class="hint">{{ t("groupEditor.forgeSourcesHint") }}</div>
<RcInput </div>
v-model="s.name" </section>
type="text" <section class="editor-section">
:placeholder="t('groupEditor.forgeSourcesName')" <h3 class="editor-section-title">{{ t("groupEditor.sectionAccess") }}</h3>
<div class="field">
<label
>{{ t("groupEditor.membersNote") }}
<span class="lbl-note">{{ t("groupEditor.membersHint") }}</span></label
>
<p class="hint">
{{ t("groupEditor.membersGoPanel") }}
</p>
</div>
<div v-if="superAdmin" class="field">
<label
>{{ t("groupEditor.owners") }}
<span class="lbl-note">{{ t("groupEditor.ownersNote") }}</span></label
>
<RcTagInput
v-model="owners"
separator=","
:placeholder="t('groupEditor.ownersPlaceholder')"
/>
<div class="hint">{{ t("groupEditor.ownersHint") }}</div>
</div>
<div v-else class="field">
<label
>{{ t("groupEditor.owners") }}
<span class="lbl-note">{{ t("groupEditor.ownersSuperOnly") }}</span></label
>
<RcInput v-model="ownersReadonly" type="text" class="opacity-60" disabled />
</div>
</section>
<section class="editor-section">
<h3 class="editor-section-title">{{ t("groupEditor.sectionProviders") }}</h3>
<div class="field">
<label
>{{ t("groupEditor.providers") }}
<span class="lbl-note">{{ t("groupEditor.providersNote") }}</span></label
>
<div class="flex flex-wrap gap-4">
<RcCheckbox
:model-value="form.providers.includes('github')"
label="GitHub"
@update:model-value="toggleProvider('github', $event)"
/>
<RcCheckbox
:model-value="form.providers.includes('gitea')"
label="Gitea"
@update:model-value="toggleProvider('gitea', $event)"
/> />
</div> </div>
<div class="hint">{{ t("groupEditor.providersHint") }}</div>
</div> </div>
<RcButton type="button" variant="ghost" class="add-filter" @click="addForgeSource"> <div class="field">
{{ t("groupEditor.forgeSourcesAdd") }} <label
</RcButton> >{{ t("groupEditor.installationId") }}
<div class="hint">{{ t("groupEditor.forgeSourcesHint") }}</div> <span class="lbl-note">{{ t("groupEditor.installationIdNote") }}</span></label
</div> >
</section> <div class="ctl-md">
<section class="editor-section"> <!-- Only super admins bind installations here (the server keeps
<h3 class="editor-section-title">{{ t("groupEditor.sectionAccess") }}</h3> the stored value for anyone else); owners use the install flow. -->
<div class="field">
<label
>{{ t("groupEditor.membersNote") }}
<span class="lbl-note">{{ t("groupEditor.membersHint") }}</span></label
>
<p class="hint">
{{ t("groupEditor.membersGoPanel") }}
</p>
</div>
<div v-if="superAdmin" class="field">
<label
>{{ t("groupEditor.owners") }}
<span class="lbl-note">{{ t("groupEditor.ownersNote") }}</span></label
>
<RcTagInput
v-model="owners"
separator=","
:placeholder="t('groupEditor.ownersPlaceholder')"
/>
<div class="hint">{{ t("groupEditor.ownersHint") }}</div>
</div>
<div v-else class="field">
<label
>{{ t("groupEditor.owners") }}
<span class="lbl-note">{{ t("groupEditor.ownersSuperOnly") }}</span></label
>
<RcInput v-model="ownersReadonly" type="text" class="opacity-60" disabled />
</div>
</section>
<section class="editor-section">
<h3 class="editor-section-title">{{ t("groupEditor.sectionProviders") }}</h3>
<div class="field">
<label
>{{ t("groupEditor.providers") }}
<span class="lbl-note">{{ t("groupEditor.providersNote") }}</span></label
>
<div class="flex flex-wrap gap-4">
<RcCheckbox
:model-value="form.providers.includes('github')"
label="GitHub"
@update:model-value="toggleProvider('github', $event)"
/>
<RcCheckbox
:model-value="form.providers.includes('gitea')"
label="Gitea"
@update:model-value="toggleProvider('gitea', $event)"
/>
</div>
<div class="hint">{{ t("groupEditor.providersHint") }}</div>
</div>
<div class="field">
<label
>{{ t("groupEditor.installationId") }}
<span class="lbl-note">{{ t("groupEditor.installationIdNote") }}</span></label
>
<div class="ctl-md">
<RcInput
v-model="form.installationId"
type="text"
inputmode="numeric"
:placeholder="t('groupEditor.installationIdPlaceholder')"
/>
</div>
<div class="hint">{{ t("groupEditor.installationIdHint") }}</div>
</div>
</section>
<section class="editor-section">
<h3 class="editor-section-title">{{ t("groupEditor.sectionLog") }}</h3>
<div class="field">
<label
>{{ t("groupEditor.logTarget") }}
<span class="lbl-note">{{ t("groupEditor.logTargetNote") }}</span></label
>
<div class="ctl-md">
<RcSelect
:model-value="form.logPlatform || 'none'"
:options="[
{ label: t('groupEditor.logDisabled'), value: 'none' },
{ label: 'Discord', value: 'discord' },
{ label: 'Telegram', value: 'telegram' },
{ label: t('groupEditor.logFeishu'), value: 'feishu' },
]"
@update:model-value="
form.logPlatform = ($event === 'none' ? '' : $event) as
'' | 'discord' | 'telegram' | 'feishu'
"
/>
</div>
<div v-if="form.logPlatform" class="ctl-stack">
<template v-if="form.logPlatform === 'discord'">
<RcInput <RcInput
v-model="form.logChannelId" v-model="form.installationId"
type="text" type="text"
:placeholder="t('routeEditor.channelPlaceholder')" inputmode="numeric"
:class="superAdmin ? '' : 'opacity-60'"
:disabled="!superAdmin"
:placeholder="t('groupEditor.installationIdPlaceholder')"
/> />
<RcInput </div>
v-model="form.logThreadId" <div class="hint">{{ t("groupEditor.installationIdHint") }}</div>
type="text" </div>
:placeholder="t('routeEditor.threadPlaceholder')" </section>
/> <section class="editor-section">
</template> <h3 class="editor-section-title">{{ t("groupEditor.sectionLog") }}</h3>
<template v-else> <div class="field">
<RcInput <label
v-model="form.logChatId" >{{ t("groupEditor.logTarget") }}
type="text" <span class="lbl-note">{{ t("groupEditor.logTargetNote") }}</span></label
:placeholder=" >
form.logPlatform === 'telegram' <div class="ctl-md">
? t('routeEditor.chatPlaceholder') <RcSelect
: t('routeEditor.feishuChatPlaceholder') :model-value="form.logPlatform || 'none'"
:options="[
{ label: t('groupEditor.logDisabled'), value: 'none' },
{ label: 'Discord', value: 'discord' },
{ label: 'Telegram', value: 'telegram' },
{ label: t('groupEditor.logFeishu'), value: 'feishu' },
]"
@update:model-value="
form.logPlatform = ($event === 'none' ? '' : $event) as
'' | 'discord' | 'telegram' | 'feishu'
" "
/> />
<RcInput </div>
v-if="form.logPlatform === 'telegram'" <div v-if="form.logPlatform" class="ctl-stack">
v-model="form.logTopicId" <template v-if="form.logPlatform === 'discord'">
type="text" <RcInput
:placeholder="t('routeEditor.topicPlaceholder')" v-model="form.logChannelId"
/> type="text"
</template> :placeholder="t('routeEditor.channelPlaceholder')"
/>
<RcInput
v-model="form.logThreadId"
type="text"
:placeholder="t('routeEditor.threadPlaceholder')"
/>
</template>
<template v-else>
<RcInput
v-model="form.logChatId"
type="text"
:placeholder="
form.logPlatform === 'telegram'
? t('routeEditor.chatPlaceholder')
: t('routeEditor.feishuChatPlaceholder')
"
/>
<RcInput
v-if="form.logPlatform === 'telegram'"
v-model="form.logTopicId"
type="text"
:placeholder="t('routeEditor.topicPlaceholder')"
/>
</template>
</div>
<div class="hint">{{ t("groupEditor.logTargetHint") }}</div>
</div> </div>
<div class="hint">{{ t("groupEditor.logTargetHint") }}</div> </section>
</div> <div class="err">{{ formError }}</div>
</section> </fieldset>
<div class="err">{{ formError }}</div>
</form> </form>
<template #footer> <template #footer>
<div class="editor-foot"> <div class="editor-foot">
@@ -424,7 +432,7 @@ function save(): void {
const all = [...form.providers, ...kept]; const all = [...form.providers, ...kept];
return all.length ? all : undefined; return all.length ? all : undefined;
})(), })(),
installationId, installationId: props.superAdmin ? installationId : props.group?.installationId,
emoji: form.emoji, emoji: form.emoji,
forgeSources: form.forgeSources.length forgeSources: form.forgeSources.length
? form.forgeSources.map((s) => ({ ? form.forgeSources.map((s) => ({