feat(Communities): Integrate kick/ban actions with token holders list

Closes: #11033
This commit is contained in:
Michał Cieślak 2023-09-01 00:26:24 +02:00 committed by Michał
parent 20de907982
commit 0d2f11912c
8 changed files with 240 additions and 103 deletions

View File

@ -0,0 +1,111 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import Storybook 1.0
import AppLayouts.Communities.popups 1.0
SplitView {
Logs { id: logs }
orientation: Qt.Vertical
SplitView.fillWidth: true
Item {
SplitView.fillWidth: true
SplitView.fillHeight: true
PopupBackground {
anchors.fill: parent
}
Button {
anchors.centerIn: parent
text: "Reopen"
onClicked: dialog.open()
}
KickBanPopup {
id: dialog
mode: modesButtonGroup.checkedButton.mode
username: usernameTextField.text
communityName: communityNameTextField.text
closePolicy: Popup.NoAutoClose
visible: true
modal: false
destroyOnClose: false
anchors.centerIn: parent
onAccepted: logs.logEvent("KickBanPopup::accepted")
}
}
LogsAndControlsPanel {
id: logsAndControlsPanel
SplitView.minimumHeight: 100
SplitView.preferredHeight: 250
logsView.logText: logs.logText
ColumnLayout {
ButtonGroup {
id: modesButtonGroup
buttons: modesRow.children
}
RowLayout {
id: modesRow
RadioButton {
readonly property int mode: KickBanPopup.Mode.Kick
text: "Kick"
checked: true
}
RadioButton {
readonly property int mode: KickBanPopup.Mode.Ban
text: "Ban"
}
}
MenuSeparator {
Layout.fillWidth: true
}
RowLayout {
Label {
text: "Username:"
}
TextField {
id: usernameTextField
text: "John"
}
}
RowLayout {
Label {
text: "Community:"
}
TextField {
id: communityNameTextField
text: "CryptoKitties"
}
}
}
}
}
// category: Popups

View File

@ -1,17 +1,11 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Controls 0.1 import StatusQ.Controls 0.1
import StatusQ.Components 0.1
import StatusQ.Popups 0.1
import utils 1.0 import utils 1.0
import shared.controls.chat 1.0
import AppLayouts.Communities.layouts 1.0 import AppLayouts.Communities.layouts 1.0
import AppLayouts.Communities.popups 1.0
SettingsPage { SettingsPage {
id: root id: root
@ -121,15 +115,17 @@ SettingsPage {
Layout.fillHeight: true Layout.fillHeight: true
onKickUserClicked: { onKickUserClicked: {
kickModal.userNameToKick = name kickBanPopup.mode = KickBanPopup.Mode.Kick
kickModal.userIdToKick = id kickBanPopup.username = name
kickModal.open() kickBanPopup.userId = id
kickBanPopup.open()
} }
onBanUserClicked: { onBanUserClicked: {
banModal.userNameToBan = name kickBanPopup.mode = KickBanPopup.Mode.Ban
banModal.userIdToBan = id kickBanPopup.username = name
banModal.open() kickBanPopup.userId = id
kickBanPopup.open()
} }
} }
@ -190,85 +186,18 @@ SettingsPage {
} }
} }
StatusModal { KickBanPopup {
id: banModal id: kickBanPopup
property string userNameToBan: "" property string userId
property string userIdToBan: ""
readonly property string text: qsTr("Are you sure you ban <b>%1</b> from %2?").arg(userNameToBan).arg(root.communityName) communityName: root.communityName
anchors.centerIn: parent onAccepted: {
width: 400 if (mode === KickBanPopup.Mode.Kick)
headerSettings.title: qsTr("Ban %1").arg(userNameToBan) root.kickUserClicked(userId)
else
contentItem: StatusBaseText { root.banUserClicked(userId)
id: banContentText
anchors.centerIn: parent
font.pixelSize: 15
color: Theme.palette.directColor1
padding: 15
wrapMode: Text.WordWrap
text: banModal.text
} }
rightButtons: [
StatusButton {
text: qsTr("Cancel")
onClicked: banModal.close()
normalColor: "transparent"
hoverColor: "transparent"
},
StatusButton {
id: banButton
text: qsTr("Ban")
type: StatusBaseButton.Type.Danger
onClicked: {
root.banUserClicked(banModal.userIdToBan)
banModal.close()
}
}
]
}
StatusModal {
id: kickModal
property string userNameToKick: ""
property string userIdToKick: ""
readonly property string text : qsTr("Are you sure you kick <b>%1</b> from %2?").arg(userNameToKick).arg(communityName)
anchors.centerIn: parent
width: 400
headerSettings.title: qsTr("Kick %1").arg(userNameToKick)
contentItem: StatusBaseText {
id: kickContentText
anchors.centerIn: parent
font.pixelSize: 15
color: Theme.palette.directColor1
padding: 15
wrapMode: Text.WordWrap
text: kickModal.text
}
rightButtons: [
StatusButton {
text: qsTr("Cancel")
onClicked: kickModal.close()
normalColor: "transparent"
hoverColor: "transparent"
},
StatusButton {
objectName: "CommunityMembers_KickModal_KickButton"
text: qsTr("Kick")
type: StatusBaseButton.Type.Danger
onClicked: {
root.kickUserClicked(kickModal.userIdToKick)
kickModal.close()
}
}
]
} }
} }

View File

@ -65,6 +65,9 @@ StackView {
signal mintAsset(var assetItem) signal mintAsset(var assetItem)
signal mintOwnerToken(var ownerToken, var tMasterToken) signal mintOwnerToken(var ownerToken, var tMasterToken)
signal kickUserRequested(string contactId)
signal banUserRequested(string contactId)
signal deployFeesRequested(int chainId, string accountAddress, int tokenType) signal deployFeesRequested(int chainId, string accountAddress, int tokenType)
signal burnFeesRequested(string tokenKey, string amount, string accountAddress) signal burnFeesRequested(string tokenKey, string amount, string accountAddress)
signal remotelyDestructFeesRequest(var walletsAndAmounts, // { [walletAddress (string), amount (int)] } signal remotelyDestructFeesRequest(var walletsAndAmounts, // { [walletAddress (string), amount (int)] }
@ -551,13 +554,19 @@ StackView {
} }
onBanRequested: { onBanRequested: {
if (token.isPrivilegedToken)
tokenMasterActionPopup.openPopup( tokenMasterActionPopup.openPopup(
TokenMasterActionPopup.ActionType.Ban, name) TokenMasterActionPopup.ActionType.Ban, name)
else
kickBanPopup.openPopup(KickBanPopup.Mode.Ban, name, contactId)
} }
onKickRequested: { onKickRequested: {
if (token.isPrivilegedToken)
tokenMasterActionPopup.openPopup( tokenMasterActionPopup.openPopup(
TokenMasterActionPopup.ActionType.Kick, name) TokenMasterActionPopup.ActionType.Kick, name)
else
kickBanPopup.openPopup(KickBanPopup.Mode.Kick, name, contactId)
} }
TokenMasterActionPopup { TokenMasterActionPopup {
@ -574,6 +583,28 @@ StackView {
open() open()
} }
} }
KickBanPopup {
id: kickBanPopup
property string contactId
communityName: root.communityName
onAccepted: {
if (mode === KickBanPopup.Mode.Kick)
root.kickUserRequested(contactId)
else
root.banUserRequested(contactId)
}
function openPopup(mode, userName, contactId) {
kickBanPopup.mode = mode
kickBanPopup.username = userName
kickBanPopup.contactId = contactId
open()
}
}
} }
footer: MintTokensFooterPanel { footer: MintTokensFooterPanel {

View File

@ -31,8 +31,8 @@ Control {
signal viewMessagesRequested(string contactId) signal viewMessagesRequested(string contactId)
signal airdropRequested(string address) signal airdropRequested(string address)
signal remoteDestructRequested(string name, string address) signal remoteDestructRequested(string name, string address)
signal kickRequested(string name, string address) signal kickRequested(string name, string contactId)
signal banRequested(string name, string address) signal banRequested(string name, string contactId)
signal generalAirdropRequested signal generalAirdropRequested
@ -202,8 +202,7 @@ Control {
enabled: !menu.rawAddress enabled: !menu.rawAddress
type: StatusBaseButton.Type.Danger type: StatusBaseButton.Type.Danger
onTriggered: root.kickRequested(menu.name, onTriggered: root.kickRequested(menu.name, menu.contactId)
menu.currentAddress)
} }
StatusAction { StatusAction {
@ -214,8 +213,7 @@ Control {
enabled: !menu.rawAddress enabled: !menu.rawAddress
type: StatusBaseButton.Type.Danger type: StatusBaseButton.Type.Danger
onTriggered: root.banRequested(menu.name, onTriggered: root.banRequested(menu.name, menu.contactId)
menu.currentAddress)
} }
} }
} }

View File

@ -0,0 +1,64 @@
import QtQuick 2.15
import QtQml.Models 2.15
import StatusQ.Controls 0.1
import StatusQ.Core 0.1
import StatusQ.Popups.Dialog 0.1
import utils 1.0
StatusDialog {
id: root
property string username: ""
property string communityName: ""
property int mode: KickBanPopup.Mode.Kick
enum Mode {
Kick, Ban
}
width: 400
title: root.mode === KickBanPopup.Mode.Kick
? qsTr("Kick %1").arg(root.username)
: qsTr("Ban %1").arg(root.username)
contentItem: StatusBaseText {
anchors.centerIn: parent
font.pixelSize: Style.current.primaryTextFontSize
wrapMode: Text.Wrap
text: root.mode === KickBanPopup.Mode.Kick
? qsTr("Are you sure you kick <b>%1</b> from %2?")
.arg(root.username).arg(root.communityName)
: qsTr("Are you sure you ban <b>%1</b> from %2?")
.arg(root.username).arg(root.communityName)
}
footer: StatusDialogFooter {
rightButtons: ObjectModel {
StatusFlatButton {
text: qsTr("Cancel")
onClicked: root.close()
}
StatusButton {
id: banButton
objectName: root.mode === KickBanPopup.Mode.Kick
? "CommunityMembers_KickModal_KickButton"
: "CommunityMembers_BanModal_BanButton"
text: root.mode === KickBanPopup.Mode.Kick ? qsTr("Kick")
: qsTr("Ban")
type: StatusBaseButton.Type.Danger
onClicked: {
root.accept()
root.close()
}
}
}
}
}

View File

@ -10,6 +10,7 @@ HoldingsDropdown 1.0 HoldingsDropdown.qml
ImportControlNodePopup 1.0 ImportControlNodePopup.qml ImportControlNodePopup 1.0 ImportControlNodePopup.qml
InDropdown 1.0 InDropdown.qml InDropdown 1.0 InDropdown.qml
InviteFriendsToCommunityPopup 1.0 InviteFriendsToCommunityPopup.qml InviteFriendsToCommunityPopup 1.0 InviteFriendsToCommunityPopup.qml
KickBanPopup 1.0 KickBanPopup.qml
MembersDropdown 1.0 MembersDropdown.qml MembersDropdown 1.0 MembersDropdown.qml
PermissionsDropdown 1.0 PermissionsDropdown.qml PermissionsDropdown 1.0 PermissionsDropdown.qml
RecipientTypeSelectionDropdown 1.0 RecipientTypeSelectionDropdown.qml RecipientTypeSelectionDropdown 1.0 RecipientTypeSelectionDropdown.qml

View File

@ -410,6 +410,9 @@ StatusSectionLayout {
// Set given addresses as recipients // Set given addresses as recipients
airdropPanel.addAddresses(addresses) airdropPanel.addAddresses(addresses)
} }
onKickUserRequested: root.rootStore.removeUserFromCommunity(contactId)
onBanUserRequested: root.rootStore.banUserFromCommunity(contactId)
} }
AirdropsSettingsPanel { AirdropsSettingsPanel {

View File

@ -71,8 +71,8 @@ StatusScrollView {
signal viewMessagesRequested(string contactId) signal viewMessagesRequested(string contactId)
signal remoteDestructRequested(string name, string address) signal remoteDestructRequested(string name, string address)
signal kickRequested(string name, string address) signal kickRequested(string name, string contactId)
signal banRequested(string name, string address) signal banRequested(string name, string contactId)
signal deployFeesRequested signal deployFeesRequested
@ -217,8 +217,8 @@ StatusScrollView {
onGeneralAirdropRequested: root.generalAirdropRequested() onGeneralAirdropRequested: root.generalAirdropRequested()
onRemoteDestructRequested: root.remoteDestructRequested(name, address) onRemoteDestructRequested: root.remoteDestructRequested(name, address)
onKickRequested: root.kickRequested(name, address) onKickRequested: root.kickRequested(name, contactId)
onBanRequested: root.banRequested(name, address) onBanRequested: root.banRequested(name, contactId)
} }
} }
} }