Add "Copy profile ID" item to profile menu if current user is admin

This commit is contained in:
silverpill 2023-03-19 19:43:27 +00:00
parent 14fbce0285
commit e2c915a256
3 changed files with 27 additions and 0 deletions

View file

@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Added
- Add "Copy profile ID" item to profile menu if current user is admin.
### Changed
- Show better error message if HTTP status code is 413.

View file

@ -33,6 +33,7 @@ interface Role {
export enum Permissions {
CreatePost = "create_post",
DeleteAnyProfile = "delete_any_profile",
ManageSubscriptionOptions = "manage_subscription_options",
}

View file

@ -100,6 +100,14 @@
<li v-if="canShowReplies()">
<button @click="onFollow(undefined, true)">Show replies</button>
</li>
<li v-if="isAdmin()">
<button
title="Copy profile ID"
@click="hideProfileMenu(); copyProfileId()"
>
Copy profile ID
</button>
</li>
</menu>
</div>
</div>
@ -575,6 +583,20 @@ function canSubscribe(): boolean {
)
}
function isAdmin(): boolean {
if (!currentUser) {
return false
}
return currentUser.role.permissions.includes(Permissions.DeleteAnyProfile)
}
function copyProfileId(): void {
if (!profile) {
return
}
navigator.clipboard.writeText(profile.id)
}
async function loadNextPage(maxId: string) {
if (!profile) {
return