From 9e9fe26f746483c2a629cfb5f45b707e3358c58f Mon Sep 17 00:00:00 2001 From: arily Date: Sat, 27 Apr 2024 01:13:53 +0800 Subject: [PATCH] refine roles, define sever roles --- src/common/options/roles.ts | 1 - src/components/T/multi-checkbox.vue | 65 +++++++++++++++++++ src/composables/useAdapterConfig.ts | 2 + src/def/user.ts | 9 +-- src/locales/base/en-GB.ts | 1 - src/locales/base/fr-FR.ts | 1 - src/locales/base/zh-CN.ts | 1 - src/pages/admin/users/[id].vue | 62 +++++++++++++++--- src/pages/admin/users/index.vue | 1 + src/server/backend/$base/index.ts | 1 + .../backend/bancho.py/drizzle/schema.ts | 1 - src/server/backend/bancho.py/index.ts | 14 ++++ .../backend/bancho.py/transforms/user.ts | 16 ++--- src/server/backend/ppy.sb@bancho.py/index.ts | 1 + src/server/trpc/config.ts | 1 + src/server/trpc/routers/user.ts | 22 +++---- src/store/session.ts | 4 ++ 17 files changed, 163 insertions(+), 40 deletions(-) create mode 100644 src/components/T/multi-checkbox.vue diff --git a/src/common/options/roles.ts b/src/common/options/roles.ts index 68c0e51d..93212af7 100644 --- a/src/common/options/roles.ts +++ b/src/common/options/roles.ts @@ -4,7 +4,6 @@ export const variant: Record = { [UserRole.Disabled]: { class: 'badge-ghost' }, [UserRole.Restricted]: { class: 'badge-error' }, [UserRole.Inactive]: { class: 'badge-ghost' }, - [UserRole.Normal]: { class: 'badge-neutral' }, [UserRole.Supported]: { class: 'badge-neutral' }, [UserRole.Supporter]: { class: 'badge-primary' }, [UserRole.Verified]: { class: 'badge-outline' }, diff --git a/src/components/T/multi-checkbox.vue b/src/components/T/multi-checkbox.vue new file mode 100644 index 00000000..6693bacb --- /dev/null +++ b/src/components/T/multi-checkbox.vue @@ -0,0 +1,65 @@ + + + diff --git a/src/composables/useAdapterConfig.ts b/src/composables/useAdapterConfig.ts index 0d8d1a6f..3d22b37c 100644 --- a/src/composables/useAdapterConfig.ts +++ b/src/composables/useAdapterConfig.ts @@ -6,6 +6,7 @@ import { leaderboardRankingSystems as supportedLeaderboardRankingSystems, modes as supportedModes, rankingSystems as supportedRankingSystems, + userRoles as supportedRoles, rulesets as supportedRulesets, } from '~/server/trpc/config' @@ -19,5 +20,6 @@ export default () => { hasRuleset, hasLeaderboardRankingSystem, hasRankingSystem, + supportedRoles, } } diff --git a/src/def/user.ts b/src/def/user.ts index 14874950..de3a7901 100755 --- a/src/def/user.ts +++ b/src/def/user.ts @@ -39,16 +39,11 @@ export enum UserRole { // restricted type Disabled = 'disabled', Restricted = 'restricted', - - // // registered without login - // Registered = 'registered', Inactive = 'inactive', - Normal = 'normal', Supported = 'supported', Supporter = 'supporter', - // bancho.py privileges - Verified = 'whitelisted', + Verified = 'verified', // bancho privileges Alumni = 'alumni', @@ -68,6 +63,8 @@ export enum UserRole { Bot = 'bot', } +export const userRoles = Object.values(UserRole).filter((value): value is UserRole => typeof value === 'number') as readonly UserRole[] + export interface UserOldName { from: Date to: Date diff --git a/src/locales/base/en-GB.ts b/src/locales/base/en-GB.ts index f2b28302..27b101fe 100644 --- a/src/locales/base/en-GB.ts +++ b/src/locales/base/en-GB.ts @@ -71,7 +71,6 @@ export default { [UserRole.Restricted]: 'Restricted', // [UserRole.Registered]: 'Registered', [UserRole.Inactive]: 'Inactive', - [UserRole.Normal]: 'Normal', [UserRole.Supported]: 'Supported', [UserRole.Supporter]: 'Supporter', [UserRole.Verified]: 'Verified', diff --git a/src/locales/base/fr-FR.ts b/src/locales/base/fr-FR.ts index 6759e1a7..9f821ead 100644 --- a/src/locales/base/fr-FR.ts +++ b/src/locales/base/fr-FR.ts @@ -52,7 +52,6 @@ export default { [UserRole.Restricted]: 'Restreint', // [UserRole.Registered]: 'Enregistré', [UserRole.Inactive]: 'Inactif', - [UserRole.Normal]: 'Normal', [UserRole.Supported]: 'Supporté', [UserRole.Supporter]: 'Supporter', [UserRole.Verified]: 'Vérifié', diff --git a/src/locales/base/zh-CN.ts b/src/locales/base/zh-CN.ts index 4cfe6761..bb5e5b5e 100644 --- a/src/locales/base/zh-CN.ts +++ b/src/locales/base/zh-CN.ts @@ -65,7 +65,6 @@ export default { [UserRole.Restricted]: '已被封禁', // [UserRole.Registered]: '已注册', [UserRole.Inactive]: '不活跃的', - [UserRole.Normal]: '普通', [UserRole.Supported]: '赞助过', [UserRole.Supporter]: '赞助者', [UserRole.Verified]: '已认证', diff --git a/src/pages/admin/users/[id].vue b/src/pages/admin/users/[id].vue index 5dfc48e3..9fabdda2 100644 --- a/src/pages/admin/users/[id].vue +++ b/src/pages/admin/users/[id].vue @@ -1,15 +1,26 @@ @@ -78,7 +122,12 @@ fr-FR: