fix(CommunityMembersSettings): Add member context menu + fix user click action

Part of https://github.com/status-im/status-desktop/issues/9912
This commit is contained in:
Alex Jbanca 2023-04-06 17:23:19 +03:00 committed by Alex Jbanca
parent a6429133e0
commit 79ea3e7d66
4 changed files with 42 additions and 1 deletions

View File

@ -21,6 +21,7 @@ SettingsPageLayout {
property var pendingMemberRequestsModel
property var declinedMemberRequestsModel
property string communityName
property var communityMemberContextMenu
property bool editable: true
@ -78,6 +79,7 @@ SettingsPageLayout {
CommunityMembersTabPanel {
model: root.membersModel
communityMemberContextMenu: root.communityMemberContextMenu
placeholderText: {
if (root.membersModel.count === 0) {
return qsTr("No members to search")
@ -106,6 +108,7 @@ SettingsPageLayout {
CommunityMembersTabPanel {
model: root.pendingMemberRequestsModel
communityMemberContextMenu: root.communityMemberContextMenu
placeholderText: {
if (root.pendingMemberRequestsModel.count === 0) {
return qsTr("No pending requests to search")
@ -120,12 +123,14 @@ SettingsPageLayout {
Layout.fillWidth: true
Layout.fillHeight: true
onUserProfileClicked: root.userProfileClicked(id)
onAcceptRequestToJoin: root.acceptRequestToJoin(id)
onDeclineRequestToJoin: root.declineRequestToJoin(id)
}
CommunityMembersTabPanel {
model: root.declinedMemberRequestsModel
communityMemberContextMenu: root.communityMemberContextMenu
placeholderText: {
if (root.declinedMemberRequestsModel.count === 0) {
return qsTr("No rejected members to search")
@ -140,11 +145,13 @@ SettingsPageLayout {
Layout.fillWidth: true
Layout.fillHeight: true
onUserProfileClicked: root.userProfileClicked(id)
onAcceptRequestToJoin: root.acceptRequestToJoin(id)
}
CommunityMembersTabPanel {
model: root.bannedMembersModel
communityMemberContextMenu: root.communityMemberContextMenu
placeholderText: {
if (root.bannedMembersModel.count === 0) {
return qsTr("No banned members to search")

View File

@ -18,6 +18,7 @@ Item {
property string placeholderText
property var model
property var communityMemberContextMenu
signal userProfileClicked(string id)
signal kickUserClicked(string id, string name)
@ -143,7 +144,19 @@ Item {
ringSettings.ringSpecModel: model.colorHash
statusListItemIcon.badge.visible: (root.panelType === CommunityMembersTabPanel.TabType.AllMembers)
onClicked: root.userProfileClicked(model.pubKey)
onClicked: {
if(mouse.button === Qt.RightButton) {
// Set parent, X & Y positions for the messageContextMenu
root.communityMemberContextMenu.parent = this
root.communityMemberContextMenu.isProfile = true
root.communityMemberContextMenu.selectedUserPublicKey = model.pubKey
root.communityMemberContextMenu.selectedUserDisplayName = userName
root.communityMemberContextMenu.selectedUserIcon = asset.name
root.communityMemberContextMenu.popup()
} else {
root.userProfileClicked(model.pubKey)
}
}
}
}
}

View File

@ -266,6 +266,10 @@ QtObject {
return isCurrentUser(pubkey) ? qsTr("You") : name
}
function myPubKey() {
return userProfileInst.pubKey
}
function getCommunity(communityId) {
// Not Refactored Yet
// try {

View File

@ -21,6 +21,7 @@ import StatusQ.Controls.Validators 0.1
import AppLayouts.Chat.stores 1.0
import shared.stores 1.0
import shared.views.chat 1.0
import "../panels/communities"
import "../popups/community"
@ -235,6 +236,7 @@ StatusSectionLayout {
declinedMemberRequestsModel: root.community.declinedMemberRequests
editable: root.community.amISectionAdmin
communityName: root.community.name
communityMemberContextMenu: memberContextMenuView
onUserProfileClicked: Global.openProfilePopup(id)
onKickUserClicked: root.rootStore.removeUserFromCommunity(id)
@ -396,6 +398,21 @@ StatusSectionLayout {
}
}
MessageContextMenuView {
id: memberContextMenuView
store: root.rootStore
amIChatAdmin: root.rootStore.amIChatAdmin()
myPublicKey: root.rootStore.myPublicKey()
onOpenProfileClicked: {
Global.openProfilePopup(publicKey, null)
}
onCreateOneToOneChat: {
Global.changeAppSectionBySectionType(Constants.appSection.chat)
root.rootStore.chatCommunitySectionModule.createOneToOneChat(communityId, chatId, ensName)
}
}
Connections {
target: root.chatCommunitySectionModule
function onOpenNoPermissionsToJoinPopup(communityName: string, userName: string, communityId: string, requestId: string) {