From e2c915a25663ae64fd193aea55db1fc497751c3c Mon Sep 17 00:00:00 2001 From: silverpill Date: Sun, 19 Mar 2023 19:43:27 +0000 Subject: [PATCH] Add "Copy profile ID" item to profile menu if current user is admin --- CHANGELOG.md | 4 ++++ src/api/users.ts | 1 + src/views/Profile.vue | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29d53e7..a5c1257 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/src/api/users.ts b/src/api/users.ts index 5bf213c..b2a57e9 100644 --- a/src/api/users.ts +++ b/src/api/users.ts @@ -33,6 +33,7 @@ interface Role { export enum Permissions { CreatePost = "create_post", + DeleteAnyProfile = "delete_any_profile", ManageSubscriptionOptions = "manage_subscription_options", } diff --git a/src/views/Profile.vue b/src/views/Profile.vue index c37a4fd..9ef5a28 100644 --- a/src/views/Profile.vue +++ b/src/views/Profile.vue @@ -100,6 +100,14 @@
  • +
  • + +
  • @@ -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