feat(system): consolidate system admin and settings into one Settings panel
Replace the standalone /platform/system/* routes with a single
"系统设置" section inside the canonical Settings modal. The previous
SystemLayout.vue / SystemAdmins.vue surfaces are removed and their
functionality (system admin roster, global settings) is hosted directly
in SystemSettings.vue under the standard `.section-header` /
`.settings-group` skeleton. Legacy URLs redirect to the modal section
so external bookmarks don't 404.
Backend:
- SystemSettingService.Reset + repo.Delete: drop the DB override for a
key so the 3-tier resolver falls back to ENV / built-in default.
Idempotent (resetting a never-persisted key returns nil); emits an
audit row only on real deletions, invalidates the local cache, and
publishes to peers via the existing pubsub channel.
- TenantService.BulkSetStorageQuota: overwrite every tenant's
storage_quota in one statement. Powers POST /system/admin/tenants/
apply-default-storage-quota; bypasses the per-tenant whitelist on
PUT /tenants/:id which intentionally forbids storage_quota edits.
- AuditAction{SystemAdminPromoted,SystemAdminRevoked} constants and
emitAdminAudit() in SystemHandler — promote / revoke now leave an
audit trail with TenantID=0 and {target_email,target_username,
idempotent|changed} in details.
- SystemSetting.LastModifiedByName: derived per-request display label
(username, email fallback) so the UI shows "wizardchen" instead of
a UUID prefix without storing a denormalised column.
Frontend:
- SystemSettings.vue rewritten against the Settings modal skeleton with
auto-persisting controls (switch/select @change, input/inputnumber
@blur, tag-input + per-delta popconfirm for SSRF whitelist and admin
roster). auth.registration_mode change goes through an inline
popconfirm; cancel rolls back. Reset / bulk-apply also inline
popconfirms — no dialog modal for these per-row affordances.
- Priority hint panel surfaces the DB > ENV > default resolver order
so operators can reason about "I set the env but it doesn't show up".
- Router: /platform/system, /platform/system/settings, /platform/system/
admins are now compatibility redirects to /platform/settings?section=
system-global.
- Settings modal sized 900x700 → 1080x780 and content-wrapper 600 → 760
so the wider tables (members, system settings) breathe; <1100px
viewport still flexes to the screen.
- i18n: system.globalSettings.* keys for title / description / loading /
empty / badges / priority hint / per-key labels / reset / bulkApply /
admins (label, placeholder, save messages, popconfirm copy) across
zh-CN, en-US, ko-KR, ru-RU.
Misc:
- internal/utils/filesize.go doc: clarify MAX_FILE_SIZE_MB is a
deploy-time-only knob (nginx + docreader + frontend each cache the
env at startup); a SystemAdmin UI override would mislead operators
because nginx would still 413. Until all four layers can hot-reload
the limit in lockstep, this stays env-only.
- internal/utils/security.go: SSRF whitelist parser/runtime now drives
off SystemSettingService for live updates; ENV remains the fallback
for never-overridden deployments.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { get, post, put } from '@/utils/request'
|
||||
import { get, post, put, del } from '@/utils/request'
|
||||
|
||||
export interface SystemInfo {
|
||||
version: string
|
||||
@@ -251,6 +251,10 @@ export interface ListSystemAdminsResponse {
|
||||
/**
|
||||
* Promote a user to system administrator.
|
||||
*
|
||||
* Identify the target either by user_id (UUID, for API clients) or
|
||||
* email (the human-friendly path used by the SystemAdmin UI). Backend
|
||||
* accepts whichever is provided; user_id wins when both are set.
|
||||
*
|
||||
* Backend handler (system.go) returns the updated UserInfo directly as
|
||||
* the response body — no {data: ...} wrapping. The shared axios
|
||||
* interceptor in utils/request.ts unwraps response.data at the
|
||||
@@ -262,8 +266,17 @@ export interface ListSystemAdminsResponse {
|
||||
* compile (sometimes — vue-tsc is inconsistent on AxiosResponse vs
|
||||
* inline interface assignability) but is fragile.
|
||||
*/
|
||||
export async function promoteUserToSystemAdmin(userId: string): Promise<SystemAdminUser> {
|
||||
const response = await post('/api/v1/system/admin/promote', { user_id: userId })
|
||||
export interface PromoteUserToSystemAdminRequest {
|
||||
/** UUID of the user to promote. Optional; supply this OR `email`. */
|
||||
user_id?: string
|
||||
/** Email address of the user to promote. Optional; supply this OR `user_id`. */
|
||||
email?: string
|
||||
}
|
||||
|
||||
export async function promoteUserToSystemAdmin(
|
||||
req: PromoteUserToSystemAdminRequest,
|
||||
): Promise<SystemAdminUser> {
|
||||
const response = await post('/api/v1/system/admin/promote', req)
|
||||
return response as unknown as SystemAdminUser
|
||||
}
|
||||
|
||||
@@ -320,6 +333,13 @@ export interface SystemSettingItem {
|
||||
/** P3+ — currently always false. UI may show "needs restart to take effect" badge when true. */
|
||||
requires_restart: boolean
|
||||
last_modified_by: string
|
||||
/**
|
||||
* Display label resolved from last_modified_by (UUID) on the server —
|
||||
* username when known, email as a fallback. Empty/undefined for
|
||||
* virtual rows that were never persisted; UI then falls back to the
|
||||
* UUID prefix.
|
||||
*/
|
||||
last_modified_by_name?: string
|
||||
created_at: string
|
||||
updated_at: string
|
||||
/**
|
||||
@@ -367,3 +387,35 @@ export async function updateSystemSetting(
|
||||
)
|
||||
return response as unknown as SystemSettingItem
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset a system setting back to its ENV / built-in default by deleting
|
||||
* the DB override row. Idempotent — resetting a key that was never
|
||||
* persisted resolves successfully.
|
||||
*/
|
||||
export async function resetSystemSetting(key: string): Promise<void> {
|
||||
await del(`/api/v1/system/admin/settings/${encodeURIComponent(key)}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* Result of POST /system/admin/tenants/apply-default-storage-quota.
|
||||
* `affected` is the count of tenant rows whose storage_quota was
|
||||
* overwritten; `quota_bytes` is the value written.
|
||||
*/
|
||||
export interface ApplyDefaultStorageQuotaResult {
|
||||
affected: number
|
||||
quota_bytes: number
|
||||
quota_gb: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the current `tenant.default_storage_quota_gb` setting to every
|
||||
* existing tenant. Reads the resolved setting server-side (DB > ENV >
|
||||
* default), then writes that quota to every row. SystemAdmin only.
|
||||
*
|
||||
* Idempotent: running twice with the same setting has the same effect.
|
||||
*/
|
||||
export async function applyDefaultStorageQuotaToAllTenants(): Promise<ApplyDefaultStorageQuotaResult> {
|
||||
const response = await post('/api/v1/system/admin/tenants/apply-default-storage-quota')
|
||||
return response as unknown as ApplyDefaultStorageQuotaResult
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user