fix(MembershipRequests): Remove MembershipRequestsPopup and set-up the navigation to CommunityMembersSettingsPanel

Part of https://github.com/status-im/status-desktop/issues/9912
This commit is contained in:
Alex Jbanca 2023-04-06 14:11:57 +03:00 committed by Alex Jbanca
parent 5ec4360d8c
commit 23f493f251
10 changed files with 102 additions and 152 deletions

View File

@ -1048,7 +1048,7 @@ method osNotificationClicked*[T](self: Module[T], details: NotificationDetails)
self.view.emitOpenActivityCenterSignal()
elif(details.notificationType == NotificationType.JoinCommunityRequest):
self.controller.switchTo(details.sectionId, "", "")
self.view.emitOpenCommunityMembershipRequestsPopupSignal(details.sectionId)
self.view.emitOpenCommunityMembershipRequestsViewSignal(details.sectionId)
elif(details.notificationType == NotificationType.MyRequestToJoinCommunityAccepted):
self.controller.switchTo(details.sectionId, "", "")
elif(details.notificationType == NotificationType.MyRequestToJoinCommunityRejected):

View File

@ -221,9 +221,9 @@ QtObject:
proc emitOpenActivityCenterSignal*(self: View) =
self.openActivityCenter()
proc openCommunityMembershipRequestsPopup*(self: View, sectionId: string) {.signal.}
proc emitOpenCommunityMembershipRequestsPopupSignal*(self: View, sectionId: string) =
self.openCommunityMembershipRequestsPopup(sectionId)
proc openCommunityMembershipRequestsView*(self: View, sectionId: string) {.signal.}
proc emitOpenCommunityMembershipRequestsViewSignal*(self: View, sectionId: string) =
self.openCommunityMembershipRequestsView(sectionId)
proc onlineStatusChanged(self: View, connected: bool) {.signal.}

View File

@ -32,18 +32,6 @@ StackLayout {
Global.closeCreateChatView()
}
Component {
id: membershipRequestPopupComponent
MembershipRequestsPopup {
anchors.centerIn: parent
store: root.rootStore
communityData: sectionItemModel
onClosed: {
destroy()
}
}
}
Loader {
readonly property var chatItem: root.rootStore.chatCommunitySectionModule
@ -124,7 +112,6 @@ StackLayout {
contactsStore: root.contactsStore
rootStore: root.rootStore
sectionItemModel: root.sectionItemModel
membershipRequestPopup: membershipRequestPopupComponent
onCommunityInfoButtonClicked: root.currentIndex = 1
onCommunityManageButtonClicked: root.currentIndex = 1
@ -145,9 +132,11 @@ StackLayout {
}
Loader {
id: communitySettingsLoader
active: root.rootStore.chatCommunitySectionModule.isCommunity()
sourceComponent: CommunitySettingsView {
id: communitySettingsView
rootStore: root.rootStore
hasAddedContacts: root.contactsStore.myContactsModel.count > 0
@ -158,6 +147,13 @@ StackLayout {
// TODO: remove me when migration to new settings is done
onOpenLegacyPopupClicked: Global.openCommunityProfilePopupRequested(root.rootStore, community, chatCommunitySectionModule)
Connections {
target: root.rootStore
function onGoToMembershipRequestsPage() {
root.currentIndex = 1 // go to settings
communitySettingsView.goTo(Constants.CommunitySettingsSections.Members, Constants.CommunityMembershipSubSections.MembershipRequests)
}
}
}
}
}

View File

@ -33,9 +33,37 @@ SettingsPageLayout {
signal acceptRequestToJoin(string id)
signal declineRequestToJoin(string id)
function goTo(tab: int) {
if(root.contentItem) {
root.contentItem.goTo(tab)
}
}
title: qsTr("Members")
content: ColumnLayout {
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
}
if(tabButton.enabled)
membersTabBar.currentIndex = tabButton.TabBar.index
}
spacing: 19
StatusTabBar {

View File

@ -1,97 +0,0 @@
import QtQuick 2.12
import QtQuick.Controls 2.3
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Controls 0.1
import StatusQ.Components 0.1
import StatusQ.Popups 0.1
import utils 1.0
import shared 1.0
StatusModal {
id: popup
property var store
property var communitySectionModule
property var communityData
onOpened: {
contentItem.errorText.text = ""
}
header.title: qsTr("Membership requests")
header.subTitle: contentItem.membershipRequestList.count
contentItem: Column {
property alias errorText: errorText
property alias membershipRequestList: membershipRequestList
width: popup.width
StatusBaseText {
id: errorText
visible: !!text
height: visible ? implicitHeight : 0
color: Theme.palette.dangerColor1
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.Wrap
width: parent.width
}
Item {
height: 8
width: parent.width
}
StatusScrollView {
width: parent.width
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
topPadding: 8
bottomPadding: 8
height: 300
StatusListView {
id: membershipRequestList
width: parent.width
height: parent.height
model: popup.communityData.pendingRequestsToJoin
delegate: StatusListItem {
anchors.horizontalCenter: parent.horizontalCenter
readonly property var contactDetails: Utils.getContactDetailsAsJson(model.pubKey, false)
readonly property string displayName: contactDetails.displayName || popup.store.generateAlias(model.pubKey)
asset.name: contactDetails.thumbnailImage
asset.isImage: true
title: displayName
components: [
StatusRoundButton {
icon.name: "thumbs-up"
icon.color: Style.current.white
icon.hoverColor: Style.current.white
implicitWidth: 28
implicitHeight: 28
color: Theme.palette.successColor1
onClicked: popup.store.acceptRequestToJoinCommunity(id, popup.communityData.id)
},
StatusRoundButton {
icon.name: "thumbs-down"
icon.color: Style.current.white
icon.hoverColor: Style.current.white
implicitWidth: 28
implicitHeight: 28
color: Theme.palette.dangerColor1
onClicked: popup.store.declineRequestToJoinCommunity(id, popup.communityData.id)
}
]
}
}
}
}
leftButtons: [
StatusBackButton {
onClicked: popup.close()
}
]
}

View File

@ -28,7 +28,6 @@ QtObject {
property string createChatStickerPackId: ""
property string createChatStickerUrl: ""
property var membershipRequestPopup
property var contactsModel: root.contactsStore.myContactsModel
// Important:
@ -113,6 +112,8 @@ QtObject {
signal importingCommunityStateChanged(string communityId, int state, string errorMsg)
signal goToMembershipRequestsPage()
function setActiveCommunity(communityId) {
mainModule.setActiveSectionById(communityId);
}
@ -681,4 +682,15 @@ QtObject {
root.importingCommunityStateChanged(communityId, state, errorMsg)
}
}
readonly property Connections mainModuleInstConnections: Connections {
target: mainModuleInst
enabled: !!chatCommunitySectionModule
function onOpenCommunityMembershipRequestsView(sectionId: string) {
if(root.getMySectionId() != sectionId)
return
root.goToMembershipRequestsPage()
}
}
}

View File

@ -30,7 +30,6 @@ StatusSectionLayout {
property RootStore rootStore
property var sectionItemModel
property Component membershipRequestPopup
property var emojiPopup
property var stickersPopup
property bool stickersLoaded: false
@ -160,7 +159,6 @@ StatusSectionLayout {
store: root.rootStore
emojiPopup: root.emojiPopup
hasAddedContacts: root.hasAddedContacts
membershipRequestPopup: root.membershipRequestPopup
onInfoButtonClicked: root.communityInfoButtonClicked()
onManageButtonClicked: root.communityManageButtonClicked()
}

View File

@ -34,7 +34,6 @@ Item {
property var store
property bool hasAddedContacts: false
property var communityData
property Component membershipRequestPopup
signal infoButtonClicked
signal manageButtonClicked
@ -134,9 +133,7 @@ Item {
StatusContactRequestsIndicatorListItem {
title: qsTr("Membership requests")
requestsCount: membershipRequests.nbRequests
onClicked: Global.openPopup(root.membershipRequestPopup, {
communitySectionModule: root.communitySectionModule
})
onClicked: root.store.goToMembershipRequestsPage()
}
}
}
@ -564,17 +561,4 @@ Item {
}
}
}
Connections {
target: root.store.mainModuleInst
function onOpenCommunityMembershipRequestsPopup(sectionId: string) {
if(root.store.getMySectionId() != sectionId)
return
Global.openPopup(membershipRequestPopup, {
communitySectionModule: root.communitySectionModule
})
}
}
}

View File

@ -1,8 +1,8 @@
import QtQuick 2.14
import QtQuick.Layouts 1.14
import QtQuick.Controls 2.14
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import QtQuick.Dialogs 1.3
import QtGraphicalEffects 1.13
import QtGraphicalEffects 1.15
import SortFilterProxyModel 0.2
@ -34,11 +34,11 @@ StatusSectionLayout {
hasUnseenNotifications: activityCenterStore.hasUnseenNotifications
onNotificationButtonClicked: Global.openActivityCenterPopup()
// TODO: get this model from backend?
property var settingsMenuModel: [{name: qsTr("Overview"), icon: "show", enabled: true},
{name: qsTr("Members"), icon: "group-chat", enabled: true},
{name: qsTr("Permissions"), icon: "objects", enabled: root.rootStore.communityPermissionsEnabled},
{name: qsTr("Mint Tokens"), icon: "token", enabled: root.rootStore.communityTokensEnabled},
{name: qsTr("Airdrops"), icon: "airdrop", enabled: root.rootStore.communityTokensEnabled}]
property var settingsMenuModel: [{id: Constants.CommunitySettingsSections.Overview, name: qsTr("Overview"), icon: "show", enabled: true},
{id: Constants.CommunitySettingsSections.Members, name: qsTr("Members"), icon: "group-chat", enabled: true, },
{id: Constants.CommunitySettingsSections.Permissions, name: qsTr("Permissions"), icon: "objects", enabled: root.rootStore.communityPermissionsEnabled},
{id: Constants.CommunitySettingsSections.MintTokens, name: qsTr("Mint Tokens"), icon: "token", enabled: root.rootStore.communityTokensEnabled},
{id: Constants.CommunitySettingsSections.Airdrops, name: qsTr("Airdrops"), icon: "airdrop", enabled: root.rootStore.communityTokensEnabled}]
// TODO: Next community settings options:
// {name: qsTr("Token sales"), icon: "token-sale"},
// {name: qsTr("Subscriptions"), icon: "subscription"},
@ -69,6 +69,11 @@ StatusSectionLayout {
signal backToCommunityClicked
signal openLegacyPopupClicked // TODO: remove me when migration to new settings is done
//navigate to a specific section and subsection
function goTo(section: int, subSection: int) {
d.goTo(section, subSection)
}
onBackButtonClicked: {
centerPanelContentLoader.item.children[d.currentIndex].navigateBack()
}
@ -175,6 +180,7 @@ StatusSectionLayout {
anchors.fill: parent
active: root.community
sourceComponent: StackLayout {
id: stackLayout
currentIndex: d.currentIndex
CommunityOverviewSettingsPanel {
@ -283,7 +289,7 @@ StatusSectionLayout {
onPreviousPageNameChanged: root.backButtonName = previousPageName
onNavigateToMintTokenSettings: d.currentIndex = d.mintTokensSettingsIndex
onNavigateToMintTokenSettings: root.goTo(Constants.CommunitySettingsSections.MintTokens)
}
CommunityMintTokensSettingsPanel {
@ -318,12 +324,6 @@ StatusSectionLayout {
accountName)
}
Binding {
target: d
property: "mintTokensSettingsIndex"
value: communityMintTokensSettingsPanel.StackView.index
}
Connections {
target: rootStore.communityTokensStore
function onDeployFeeUpdated(ethCurrency, fiatCurrency, errorCode) {
@ -356,7 +356,7 @@ StatusSectionLayout {
onPreviousPageNameChanged: root.backButtonName = previousPageName
onAirdropClicked: communityTokensStore.airdrop(root.community.id, airdropTokens, addresses)
onNavigateToMintTokenSettings: d.currentIndex = d.mintTokensSettingsIndex
onNavigateToMintTokenSettings: root.goTo(Constants.CommunitySettingsSections.MintTokens)
}
onCurrentIndexChanged: root.backButtonName = centerPanelContentLoader.item.children[d.currentIndex].previousPageName
@ -369,7 +369,21 @@ StatusSectionLayout {
id: d
property int currentIndex: 0
property int mintTokensSettingsIndex
readonly property var currentItem: centerPanelContentLoader.item && centerPanelContentLoader.item.children[d.currentIndex]
? centerPanelContentLoader.item.children[d.currentIndex]
: null
function goTo(section: int, subSection: int) {
//find and enable section
const matchingIndex = listView.model.findIndex((modelItem, index) => modelItem.id == section && modelItem.enabled)
if(matchingIndex != -1) {
d.currentIndex = matchingIndex
//find and enable subsection if subSection navigation is available
if(d.currentItem && d.currentItem.goTo) {
d.currentItem.goTo(subSection)
}
}
}
}
MessageDialog {

View File

@ -906,4 +906,19 @@ QtObject {
readonly property string addAccountLabelOptionAddNewMasterKey: "LABEL-OPTION-ADD-NEW-MASTER-KEY"
readonly property string addAccountLabelOptionAddWatchOnlyAcc: "LABEL-OPTION-ADD-WATCH-ONLY-ACC"
}
enum CommunitySettingsSections {
Overview,
Members,
Permissions,
MintTokens,
Airdrops
}
enum CommunityMembershipSubSections {
Members,
MembershipRequests,
RejectedMembers,
BannedMembers
}
}