2023-06-29 10:03:15 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2024-10-26 01:25:50 +00:00
|
|
|
import StatusQ 0.1
|
2022-03-23 15:38:23 +00:00
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import utils 1.0
|
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
import AppLayouts.Chat.stores 1.0
|
2023-06-23 06:17:04 +00:00
|
|
|
import AppLayouts.Communities.layouts 1.0
|
2023-08-31 22:26:24 +00:00
|
|
|
import AppLayouts.Communities.popups 1.0
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2023-06-29 10:03:15 +00:00
|
|
|
SettingsPage {
|
2022-03-23 15:38:23 +00:00
|
|
|
id: root
|
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
property RootStore rootStore
|
2022-03-23 15:38:23 +00:00
|
|
|
property var membersModel
|
2022-06-28 15:03:10 +00:00
|
|
|
property var bannedMembersModel
|
2024-10-26 01:25:50 +00:00
|
|
|
property var pendingMembersModel
|
|
|
|
property var declinedMembersModel
|
2022-06-28 15:03:10 +00:00
|
|
|
property string communityName
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2023-08-21 19:07:40 +00:00
|
|
|
property int memberRole
|
2022-03-23 15:38:23 +00:00
|
|
|
property bool editable: true
|
|
|
|
|
|
|
|
signal membershipRequestsClicked()
|
|
|
|
signal kickUserClicked(string id)
|
2024-02-22 11:01:01 +00:00
|
|
|
signal banUserClicked(string id, bool deleteAllMessages)
|
2022-06-28 15:03:10 +00:00
|
|
|
signal unbanUserClicked(string id)
|
2022-08-04 07:49:41 +00:00
|
|
|
signal acceptRequestToJoin(string id)
|
|
|
|
signal declineRequestToJoin(string id)
|
2024-03-20 10:50:10 +00:00
|
|
|
signal viewMemberMessagesClicked(string pubKey, string displayName)
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2023-04-06 11:11:57 +00:00
|
|
|
function goTo(tab: int) {
|
|
|
|
if(root.contentItem) {
|
|
|
|
root.contentItem.goTo(tab)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-30 14:36:46 +00:00
|
|
|
title: qsTr("Members")
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2023-06-29 10:03:15 +00:00
|
|
|
contentItem: ColumnLayout {
|
2023-04-06 11:11:57 +00:00
|
|
|
|
|
|
|
function goTo(tab: int) {
|
|
|
|
let tabButton = membersTabBar.currentItem
|
|
|
|
switch (tab) {
|
|
|
|
case Constants.CommunityMembershipSubSections.Members:
|
|
|
|
tabButton = allMembersBtn
|
|
|
|
break
|
|
|
|
case Constants.CommunityMembershipSubSections.MembershipRequests:
|
|
|
|
tabButton = pendingRequestsBtn
|
|
|
|
break
|
|
|
|
case Constants.CommunityMembershipSubSections.RejectedMembers:
|
|
|
|
tabButton = declinedRequestsBtn
|
|
|
|
break
|
|
|
|
case Constants.CommunityMembershipSubSections.BannedMembers:
|
|
|
|
tabButton = bannedBtn
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
2024-10-26 01:25:50 +00:00
|
|
|
if (tabButton.enabled)
|
2023-04-06 11:11:57 +00:00
|
|
|
membersTabBar.currentIndex = tabButton.TabBar.index
|
|
|
|
}
|
|
|
|
|
2022-08-08 15:56:57 +00:00
|
|
|
spacing: 19
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2022-06-28 15:03:10 +00:00
|
|
|
StatusTabBar {
|
|
|
|
id: membersTabBar
|
2022-03-23 15:38:23 +00:00
|
|
|
Layout.fillWidth: true
|
2022-08-08 15:56:57 +00:00
|
|
|
Layout.topMargin: 5
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2022-06-28 15:03:10 +00:00
|
|
|
StatusTabButton {
|
|
|
|
id: allMembersBtn
|
2024-07-30 05:44:35 +00:00
|
|
|
objectName: "allMembersButton"
|
2022-06-28 15:03:10 +00:00
|
|
|
width: implicitWidth
|
|
|
|
text: qsTr("All Members")
|
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2022-08-04 07:49:41 +00:00
|
|
|
StatusTabButton {
|
|
|
|
id: pendingRequestsBtn
|
2024-07-30 05:44:35 +00:00
|
|
|
objectName: "pendingRequestsButton"
|
2022-08-04 07:49:41 +00:00
|
|
|
width: implicitWidth
|
|
|
|
text: qsTr("Pending Requests")
|
2024-10-26 01:25:50 +00:00
|
|
|
enabled: pendingMembersModel.ModelCount.count > 0
|
2022-08-04 07:49:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusTabButton {
|
|
|
|
id: declinedRequestsBtn
|
2024-07-30 05:44:35 +00:00
|
|
|
objectName: "declinedRequestsButton"
|
2022-08-04 07:49:41 +00:00
|
|
|
width: implicitWidth
|
|
|
|
text: qsTr("Rejected")
|
2024-10-26 01:25:50 +00:00
|
|
|
enabled: declinedMembersModel.ModelCount.count > 0
|
2022-08-04 07:49:41 +00:00
|
|
|
}
|
2022-06-28 15:03:10 +00:00
|
|
|
|
|
|
|
StatusTabButton {
|
|
|
|
id: bannedBtn
|
2024-07-30 05:44:35 +00:00
|
|
|
objectName: "bannedButton"
|
2022-06-28 15:03:10 +00:00
|
|
|
width: implicitWidth
|
2024-10-26 01:25:50 +00:00
|
|
|
enabled: bannedMembersModel.ModelCount.count > 0
|
2022-06-28 15:03:10 +00:00
|
|
|
text: qsTr("Banned")
|
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
}
|
|
|
|
|
2022-06-28 15:03:10 +00:00
|
|
|
StackLayout {
|
|
|
|
id: stackLayout
|
2022-03-23 15:38:23 +00:00
|
|
|
Layout.fillWidth: true
|
2022-06-28 15:03:10 +00:00
|
|
|
Layout.fillHeight: true
|
|
|
|
currentIndex: membersTabBar.currentIndex
|
|
|
|
|
2023-06-26 11:48:45 +00:00
|
|
|
MembersTabPanel {
|
2022-06-28 15:03:10 +00:00
|
|
|
model: root.membersModel
|
2023-06-20 07:14:25 +00:00
|
|
|
rootStore: root.rootStore
|
2023-08-21 19:07:40 +00:00
|
|
|
memberRole: root.memberRole
|
2022-06-28 15:03:10 +00:00
|
|
|
placeholderText: {
|
2024-10-26 01:25:50 +00:00
|
|
|
if (root.membersModel.ModelCount.count === 0)
|
2022-06-28 15:03:10 +00:00
|
|
|
return qsTr("No members to search")
|
2023-06-21 20:37:51 +00:00
|
|
|
|
2024-10-26 01:25:50 +00:00
|
|
|
return qsTr("Search %1's %n member(s)", "", root.membersModel ? root.membersModel.ModelCount.count : 0).arg(root.communityName)
|
2022-06-28 15:03:10 +00:00
|
|
|
}
|
2023-06-26 11:48:45 +00:00
|
|
|
panelType: MembersTabPanel.TabType.AllMembers
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2022-06-28 15:03:10 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2022-06-28 15:03:10 +00:00
|
|
|
onKickUserClicked: {
|
2023-08-31 22:26:24 +00:00
|
|
|
kickBanPopup.mode = KickBanPopup.Mode.Kick
|
|
|
|
kickBanPopup.username = name
|
|
|
|
kickBanPopup.userId = id
|
|
|
|
kickBanPopup.open()
|
2022-06-28 15:03:10 +00:00
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2022-06-28 15:03:10 +00:00
|
|
|
onBanUserClicked: {
|
2023-08-31 22:26:24 +00:00
|
|
|
kickBanPopup.mode = KickBanPopup.Mode.Ban
|
|
|
|
kickBanPopup.username = name
|
|
|
|
kickBanPopup.userId = id
|
|
|
|
kickBanPopup.open()
|
2022-06-28 15:03:10 +00:00
|
|
|
}
|
2024-03-20 10:50:10 +00:00
|
|
|
|
|
|
|
onViewMemberMessagesClicked: root.viewMemberMessagesClicked(pubKey, displayName)
|
2022-06-28 15:03:10 +00:00
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2023-06-26 11:48:45 +00:00
|
|
|
MembersTabPanel {
|
2024-10-26 01:25:50 +00:00
|
|
|
model: root.pendingMembersModel
|
2023-06-20 07:14:25 +00:00
|
|
|
rootStore: root.rootStore
|
2023-08-21 19:07:40 +00:00
|
|
|
memberRole: root.memberRole
|
2022-08-04 07:49:41 +00:00
|
|
|
placeholderText: {
|
2024-10-26 01:25:50 +00:00
|
|
|
if (root.pendingMembersModel.ModelCount.count === 0)
|
2022-08-04 07:49:41 +00:00
|
|
|
return qsTr("No pending requests to search")
|
2023-06-21 20:37:51 +00:00
|
|
|
|
2024-10-26 01:25:50 +00:00
|
|
|
return qsTr("Search %1's %n pending request(s)", "", root.pendingMembersModel.ModelCount.count).arg(root.communityName)
|
2022-08-04 07:49:41 +00:00
|
|
|
}
|
2023-06-26 11:48:45 +00:00
|
|
|
panelType: MembersTabPanel.TabType.PendingRequests
|
2022-08-04 07:49:41 +00:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
onAcceptRequestToJoin: root.acceptRequestToJoin(id)
|
|
|
|
onDeclineRequestToJoin: root.declineRequestToJoin(id)
|
|
|
|
}
|
|
|
|
|
2023-06-26 11:48:45 +00:00
|
|
|
MembersTabPanel {
|
2024-10-26 01:25:50 +00:00
|
|
|
model: root.declinedMembersModel
|
2023-06-20 07:14:25 +00:00
|
|
|
rootStore: root.rootStore
|
2023-08-21 19:07:40 +00:00
|
|
|
memberRole: root.memberRole
|
2022-08-04 07:49:41 +00:00
|
|
|
placeholderText: {
|
2024-10-26 01:25:50 +00:00
|
|
|
if (root.declinedMembersModel.ModelCount.count === 0)
|
2022-08-04 07:49:41 +00:00
|
|
|
return qsTr("No rejected members to search")
|
2023-06-21 20:37:51 +00:00
|
|
|
|
2024-10-26 01:25:50 +00:00
|
|
|
return qsTr("Search %1's %n rejected member(s)", "", root.declinedMembersModel.ModelCount.count).arg(root.communityName)
|
2022-08-04 07:49:41 +00:00
|
|
|
}
|
2023-06-26 11:48:45 +00:00
|
|
|
panelType: MembersTabPanel.TabType.DeclinedRequests
|
2022-08-04 07:49:41 +00:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
onAcceptRequestToJoin: root.acceptRequestToJoin(id)
|
|
|
|
}
|
|
|
|
|
2023-06-26 11:48:45 +00:00
|
|
|
MembersTabPanel {
|
2022-06-28 15:03:10 +00:00
|
|
|
model: root.bannedMembersModel
|
2023-06-20 07:14:25 +00:00
|
|
|
rootStore: root.rootStore
|
2023-08-21 19:07:40 +00:00
|
|
|
memberRole: root.memberRole
|
2022-06-28 15:03:10 +00:00
|
|
|
placeholderText: {
|
2024-10-26 01:25:50 +00:00
|
|
|
if (root.bannedMembersModel.ModelCount.count === 0)
|
2022-06-28 15:03:10 +00:00
|
|
|
return qsTr("No banned members to search")
|
2023-06-21 20:37:51 +00:00
|
|
|
|
2024-10-26 01:25:50 +00:00
|
|
|
return qsTr("Search %1's %n banned member(s)", "", root.bannedMembersModel.ModelCount.count).arg(root.communityName)
|
2022-06-28 15:03:10 +00:00
|
|
|
}
|
2023-06-26 11:48:45 +00:00
|
|
|
panelType: MembersTabPanel.TabType.BannedMembers
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2022-06-28 15:03:10 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2022-06-28 15:03:10 +00:00
|
|
|
onUnbanUserClicked: root.unbanUserClicked(id)
|
2024-03-20 10:50:10 +00:00
|
|
|
onViewMemberMessagesClicked: root.viewMemberMessagesClicked(pubKey, displayName)
|
2022-06-28 15:03:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2023-08-31 22:26:24 +00:00
|
|
|
KickBanPopup {
|
|
|
|
id: kickBanPopup
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2023-08-31 22:26:24 +00:00
|
|
|
property string userId
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2023-08-31 22:26:24 +00:00
|
|
|
communityName: root.communityName
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2024-02-22 11:01:01 +00:00
|
|
|
onBanUserClicked: root.banUserClicked(userId, deleteAllMessages)
|
|
|
|
onKickUserClicked: root.kickUserClicked(userId)
|
2022-03-23 15:38:23 +00:00
|
|
|
}
|
|
|
|
}
|