feat(frontend): add bot user model support and badge
This commit is contained in:
parent
05acc2b660
commit
c4e5f55b6d
|
|
@ -15,6 +15,10 @@
|
|||
v-if="showUsername"
|
||||
class="username"
|
||||
>{{ displayName }}</span>
|
||||
<span
|
||||
v-if="isBot"
|
||||
class="bot-badge"
|
||||
>{{ $t('user.bot.badge') }}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
@ -36,6 +40,7 @@ const props = withDefaults(defineProps<{
|
|||
})
|
||||
|
||||
const displayName = computed(() => getDisplayName(props.user))
|
||||
const isBot = computed(() => ((props.user as IUser & {botOwnerId?: number}).botOwnerId ?? 0) > 0)
|
||||
const avatarSrc = ref('')
|
||||
|
||||
async function loadAvatar() {
|
||||
|
|
@ -60,4 +65,17 @@ watch(() => [props.user, props.avatarSize], loadAvatar, { immediate: true })
|
|||
vertical-align: middle;
|
||||
margin-inline-end: .5rem;
|
||||
}
|
||||
|
||||
.bot-badge {
|
||||
display: inline-block;
|
||||
align-self: center;
|
||||
margin-inline-start: .5rem;
|
||||
padding: 0 .4rem;
|
||||
font-size: .75rem;
|
||||
line-height: 1.2;
|
||||
color: var(--grey-700);
|
||||
background: var(--grey-200);
|
||||
border-radius: 4px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -59,6 +59,9 @@
|
|||
"text": "Please check your network connection and try again."
|
||||
},
|
||||
"user": {
|
||||
"bot": {
|
||||
"badge": "Bot"
|
||||
},
|
||||
"auth": {
|
||||
"username": "Username",
|
||||
"usernameEmail": "Username Or Email Address",
|
||||
|
|
|
|||
|
|
@ -24,4 +24,5 @@ export interface IUser extends IAbstract {
|
|||
isLocalUser: boolean
|
||||
deletionScheduledAt: string | Date | null
|
||||
isAdmin?: boolean
|
||||
botOwnerId?: number
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ export default class UserModel extends AbstractModel<IUser> implements IUser {
|
|||
isLocalUser: boolean
|
||||
deletionScheduledAt: null
|
||||
isAdmin?: boolean
|
||||
botOwnerId = 0
|
||||
|
||||
constructor(data: Partial<IUser> = {}) {
|
||||
super()
|
||||
|
|
@ -92,4 +93,8 @@ export default class UserModel extends AbstractModel<IUser> implements IUser {
|
|||
|
||||
this.settings = new UserSettingsModel(this.settings || {})
|
||||
}
|
||||
|
||||
get isBot(): boolean {
|
||||
return (this.botOwnerId ?? 0) > 0
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ export interface ConfigState {
|
|||
},
|
||||
},
|
||||
publicTeamsEnabled: boolean,
|
||||
botUsersEnabled: boolean,
|
||||
enabledProFeatures: string[],
|
||||
}
|
||||
|
||||
|
|
@ -84,6 +85,7 @@ export const useConfigStore = defineStore('config', () => {
|
|||
},
|
||||
},
|
||||
publicTeamsEnabled: false,
|
||||
botUsersEnabled: false,
|
||||
enabledProFeatures: [],
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue