From 19d88751962528bce38336f52b00a4bada94e24c Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 10 Jun 2026 17:19:45 +0300 Subject: [PATCH] implemented status visibility change --- .../basic_user_card/basic_user_card.js | 2 +- .../moderation_tools/moderation_tools.js | 22 ++++---- .../admin_tabs/admin_status_card.js | 22 -------- .../status_action_buttons/action_button.js | 2 + .../action_button_container.js | 49 ++++++++++++++++- .../action_button_container.vue | 52 +++++++++++++++++++ .../buttons_definitions.js | 20 +++++++ src/components/user_card/user_card.js | 6 +++ src/components/user_card/user_card.vue | 4 +- src/components/user_profile/user_profile.scss | 15 ++++++ .../user_profile/user_profile_admin_view.js | 23 ++++---- .../user_profile/user_profile_admin_view.vue | 11 ++-- src/i18n/en.json | 5 +- src/services/api/api.service.js | 38 ++++++-------- .../entity_normalizer.service.js | 5 +- src/stores/admin_settings.js | 47 ++++++++++------- 16 files changed, 225 insertions(+), 98 deletions(-) diff --git a/src/components/basic_user_card/basic_user_card.js b/src/components/basic_user_card/basic_user_card.js index 1e807eca6..ae1f1c9c6 100644 --- a/src/components/basic_user_card/basic_user_card.js +++ b/src/components/basic_user_card/basic_user_card.js @@ -15,7 +15,7 @@ const BasicUserCard = { showLineLabels: { type: Boolean, default: false, - } + }, }, components: { UserPopover, diff --git a/src/components/moderation_tools/moderation_tools.js b/src/components/moderation_tools/moderation_tools.js index b75d85a1a..7ee049a7f 100644 --- a/src/components/moderation_tools/moderation_tools.js +++ b/src/components/moderation_tools/moderation_tools.js @@ -185,16 +185,15 @@ const ModerationTools = { entries() { return ENTRIES.map(({ check, label, separator, conditions }) => { if (separator) return 'separator' - const [, negateToken, group, name] = /^([!~]?)([a-z-_]+):([a-z-_]+)$/.exec( - check, - ) + const [, negateToken, group, name] = + /^([!~]?)([a-z-_]+):([a-z-_]+)$/.exec(check) const hasTag = this.tagsSet.has(`${group}:${name}`) const noTag = this.tagsSet.has(`!${group}:${name}`) const maybeTag = this.tagsSet.has(`~${group}:${name}`) // We are checking for condition to show element, i.e. only show "activate" if user is "deactivated" - const checkNegated = (negateToken === '!' || negateToken === '~') + const checkNegated = negateToken === '!' || negateToken === '~' // Naturally, new value should also be the same const value = checkNegated @@ -442,7 +441,11 @@ const ModerationTools = { return this.$store.state.users.currentUser.privileges.has(privilege) }, setTag(tag, value) { - useAdminSettingsStore().setUsersTags({ users: this.users, value, tags: [tag] }) + useAdminSettingsStore().setUsersTags({ + users: this.users, + value, + tags: [tag], + }) }, setRight(right, value) { useAdminSettingsStore().setUsersRight({ users: this.users, value, right }) @@ -542,9 +545,7 @@ const ModerationTools = { ) this.confirmDialogContent = 'user_card.admin_menu.confirm_modal.disable_mfa_content' - this.confirmDialogConfirm = this.$t( - 'settings.confirm' - ) + this.confirmDialogConfirm = this.$t('settings.confirm') break } case 'require_password_change': { @@ -554,12 +555,11 @@ const ModerationTools = { ) this.confirmDialogContent = 'user_card.admin_menu.confirm_modal.require_password_change_content' - this.confirmDialogConfirm = this.$t( - 'settings.confirm' - ) + this.confirmDialogConfirm = this.$t('settings.confirm') break } } + break } case 'state': { switch (name) { diff --git a/src/components/settings_modal/admin_tabs/admin_status_card.js b/src/components/settings_modal/admin_tabs/admin_status_card.js index 467f96472..ff078a709 100644 --- a/src/components/settings_modal/admin_tabs/admin_status_card.js +++ b/src/components/settings_modal/admin_tabs/admin_status_card.js @@ -6,19 +6,9 @@ import { parseStatus } from 'src/services/entity_normalizer/entity_normalizer.se const AdminStatusCard = { props: { - /** - * minimal status info - * @type {import('vue').PropType<{ - * id: string - * }>} - */ statusDetails: { type: Object, required: true, - /** - * @param {any} u - * @returns {u is { id: string }} - */ validator(u) { return typeof u.id === 'string' }, @@ -31,23 +21,14 @@ const AdminStatusCard = { } }, computed: { - /** - * @returns {boolean} is this status sensitive? - */ isSensitive() { return this.statusDetails.sensitive === true }, - /** - * @returns {'public' | 'unlisted' | 'private' | 'direct'} status visibility - */ visibility() { return this.statusDetails.visibility }, }, methods: { - /** - * @param {boolean} v set sensitive - */ changeSensitivity(v) { this.$store .dispatch('adminChangeStatusScope', { @@ -56,9 +37,6 @@ const AdminStatusCard = { .then((res) => parseStatus(res)) .then((s) => (this.statusCache = s)) }, - /** - * @param {boolean} v set visible - */ changeVisibility(v) { this.$store .dispatch('adminChangeStatusScope', { diff --git a/src/components/status_action_buttons/action_button.js b/src/components/status_action_buttons/action_button.js index 661d1befd..e3cdf1fb1 100644 --- a/src/components/status_action_buttons/action_button.js +++ b/src/components/status_action_buttons/action_button.js @@ -19,6 +19,7 @@ import { faChevronDown, faChevronRight, faExternalLinkAlt, + faEye, faEyeSlash, faHistory, faMinus, @@ -51,6 +52,7 @@ library.add( faBookmark, faBookmarkRegular, faEyeSlash, + faEye, faThumbtack, faShareAlt, faExternalLinkAlt, diff --git a/src/components/status_action_buttons/action_button_container.js b/src/components/status_action_buttons/action_button_container.js index 012844dc8..1f4cfc3f6 100644 --- a/src/components/status_action_buttons/action_button_container.js +++ b/src/components/status_action_buttons/action_button_container.js @@ -3,14 +3,30 @@ import { defineAsyncComponent } from 'vue' import Popover from 'src/components/popover/popover.vue' import ActionButton from './action_button.vue' +import { useAdminSettingsStore } from 'src/stores/admin_settings.js' + import { library } from '@fortawesome/fontawesome-svg-core' import { + faEnvelope, + faEye, + faEyeSlash, faFolderTree, faGlobe, + faLock, + faLockOpen, faUser, } from '@fortawesome/free-solid-svg-icons' -library.add(faUser, faGlobe, faFolderTree) +library.add( + faUser, + faGlobe, + faFolderTree, + faEye, + faEyeSlash, + faLock, + faLockOpen, + faEnvelope, +) export default { components: { @@ -61,8 +77,27 @@ export default { this.domain, ) }, + availableScopes() { + return ['private', 'unlisted', 'direct', 'public'].filter((scope) => { + return scope !== this.status.visibility + }) + }, }, methods: { + visibilityIcon(visibility) { + switch (visibility) { + case 'private': + return 'lock' + case 'unlisted': + return 'lock-open' + case 'direct': + return 'envelope' + case 'local': + return 'igloo' + default: + return 'globe' + } + }, unmuteUser() { return this.$store.dispatch('unmuteUser', this.user.id) }, @@ -79,6 +114,18 @@ export default { this.$refs.confirmUser.optionallyPrompt() } }, + setScope(visibility) { + return useAdminSettingsStore().changeStatusScope({ + id: this.status.id, + visibility, + }) + }, + setSensitive(sensitive) { + useAdminSettingsStore().changeStatusScope({ + id: this.status.id, + sensitive, + }) + }, toggleConversationMute() { if (this.conversationIsMuted) { this.unmuteConversation() diff --git a/src/components/status_action_buttons/action_button_container.vue b/src/components/status_action_buttons/action_button_container.vue index da0beed79..919207622 100644 --- a/src/components/status_action_buttons/action_button_container.vue +++ b/src/components/status_action_buttons/action_button_container.vue @@ -14,6 +14,58 @@ />