feat(CommunitySettingsView): Integrate Kick/Ban/Destruct popups for TokenMaster
Closes: #12066
This commit is contained in:
parent
ec5bed6261
commit
82a5147bb5
|
@ -67,6 +67,11 @@ StackView {
|
|||
signal remotelyDestructCollectibles(var walletsAndAmounts, // { [walletAddress (string), amount (int)] }
|
||||
string tokenKey,
|
||||
string accountAddress)
|
||||
|
||||
signal remotelyDestructAndBan(string contactId, string tokenKey, string accountAddress,
|
||||
bool removeMessages)
|
||||
signal remotelyDestructAndKick(string contactId, string tokenKey, string accountAddress)
|
||||
|
||||
signal burnToken(string tokenKey, string amount, string accountAddress)
|
||||
signal airdropToken(string tokenKey, string amount, int type, var addresses)
|
||||
signal deleteToken(string tokenKey)
|
||||
|
@ -551,28 +556,31 @@ StackView {
|
|||
view.token.type, [address]) // tokenKey instead when backend airdrop ready to use key instead of symbol
|
||||
}
|
||||
|
||||
onViewProfileRequested: {
|
||||
Global.openProfilePopup(contactId)
|
||||
}
|
||||
|
||||
onViewMessagesRequested: {
|
||||
// TODO: https://github.com/status-im/status-desktop/issues/11860
|
||||
console.warn("View Messages is not implemented yet")
|
||||
}
|
||||
|
||||
onRemoteDestructRequested: {
|
||||
if (token.isPrivilegedToken) {
|
||||
tokenMasterActionPopup.openPopup(
|
||||
TokenMasterActionPopup.ActionType.RemotelyDestruct, name, address)
|
||||
TokenMasterActionPopup.ActionType.RemotelyDestruct,
|
||||
name, address, "")
|
||||
} else {
|
||||
remotelyDestructPopup.open()
|
||||
// TODO: set the address selected in the popup's list
|
||||
}
|
||||
}
|
||||
|
||||
onViewProfileRequested: {
|
||||
Global.openProfilePopup(contactId)
|
||||
}
|
||||
onViewMessagesRequested: {
|
||||
// TODO: https://github.com/status-im/status-desktop/issues/11860
|
||||
console.warn("View Messages is not implemented yet")
|
||||
}
|
||||
|
||||
onBanRequested: {
|
||||
if (token.isPrivilegedToken)
|
||||
tokenMasterActionPopup.openPopup(
|
||||
TokenMasterActionPopup.ActionType.Ban, name)
|
||||
TokenMasterActionPopup.ActionType.Ban, name,
|
||||
address, contactId)
|
||||
else
|
||||
kickBanPopup.openPopup(KickBanPopup.Mode.Ban, name, contactId)
|
||||
}
|
||||
|
@ -580,7 +588,8 @@ StackView {
|
|||
onKickRequested: {
|
||||
if (token.isPrivilegedToken)
|
||||
tokenMasterActionPopup.openPopup(
|
||||
TokenMasterActionPopup.ActionType.Kick, name)
|
||||
TokenMasterActionPopup.ActionType.Kick, name,
|
||||
address, contactId)
|
||||
else
|
||||
kickBanPopup.openPopup(KickBanPopup.Mode.Kick, name, contactId)
|
||||
}
|
||||
|
@ -589,6 +598,7 @@ StackView {
|
|||
id: tokenMasterActionPopup
|
||||
|
||||
property string address: ""
|
||||
property string contactId: ""
|
||||
|
||||
communityName: root.communityName
|
||||
networkName: view.token.chainName
|
||||
|
@ -598,24 +608,79 @@ StackView {
|
|||
feeErrorText: selfDestructFeesSubscriber.feeErrorText
|
||||
isFeeLoading: !selfDestructFeesSubscriber.feesResponse
|
||||
|
||||
function openPopup(type, userName, address) {
|
||||
function openPopup(type, userName, address, contactId) {
|
||||
tokenMasterActionPopup.actionType = type
|
||||
tokenMasterActionPopup.userName = userName ||
|
||||
SQUtils.Utils.elideAndFormatWalletAddress(address)
|
||||
tokenMasterActionPopup.address = address
|
||||
tokenMasterActionPopup.contactId = contactId
|
||||
open()
|
||||
}
|
||||
|
||||
onRemotelyDestructClicked: signPopup.open()
|
||||
onKickClicked: signPopup.open()
|
||||
onBanClicked: signPopup.open()
|
||||
|
||||
SelfDestructFeesSubscriber {
|
||||
id: selfDestructFeesSubscriber
|
||||
|
||||
walletsAndAmounts: [{
|
||||
walletAddress: tokenMasterActionPopup.address,
|
||||
amount: 1
|
||||
amount: 1
|
||||
}]
|
||||
accountAddress: tokenMasterActionPopup.selectedAccount
|
||||
tokenKey: view.token.key
|
||||
enabled: tokenMasterActionPopup.opened
|
||||
Component.onCompleted: root.registerSelfDestructFeesSubscriber(selfDestructFeesSubscriber)
|
||||
Component.onCompleted: root.registerSelfDestructFeesSubscriber(
|
||||
selfDestructFeesSubscriber)
|
||||
}
|
||||
|
||||
SignTransactionsPopup {
|
||||
id: signPopup
|
||||
|
||||
title: qsTr("Sign transaction - Remotely-destruct TokenMaster token")
|
||||
|
||||
totalFeeText: tokenMasterActionPopup.feeText
|
||||
errorText: tokenMasterActionPopup.feeErrorText
|
||||
|
||||
accountName: tokenMasterActionPopup.selectedAccountName
|
||||
|
||||
model: QtObject {
|
||||
readonly property string title: tokenMasterActionPopup.feeLabel
|
||||
readonly property string feeText: tokenMasterActionPopup.feeText
|
||||
readonly property bool error: tokenMasterActionPopup.feeErrorText !== ""
|
||||
}
|
||||
|
||||
onSignTransactionClicked: {
|
||||
// https://bugreports.qt.io/browse/QTBUG-91917
|
||||
var contactId = tokenMasterActionPopup.contactId
|
||||
var tokenKey = tokenViewPage.token.key
|
||||
var accountAddress = tokenMasterActionPopup.selectedAccount
|
||||
|
||||
switch (tokenMasterActionPopup.actionType) {
|
||||
case TokenMasterActionPopup.ActionType.RemotelyDestruct:
|
||||
var tokenToDestruct = {
|
||||
walletAddress: tokenMasterActionPopup.address,
|
||||
amount: 1
|
||||
}
|
||||
|
||||
root.remotelyDestructCollectibles(
|
||||
[tokenToDestruct],
|
||||
tokenKey, accountAddress)
|
||||
break
|
||||
case TokenMasterActionPopup.ActionType.Kick:
|
||||
root.remotelyDestructAndKick(contactId, tokenKey,
|
||||
accountAddress)
|
||||
break
|
||||
case TokenMasterActionPopup.ActionType.Ban:
|
||||
root.remotelyDestructAndBan(contactId, tokenKey,
|
||||
accountAddress,
|
||||
tokenMasterActionPopup.deleteMessages)
|
||||
break
|
||||
}
|
||||
|
||||
tokenMasterActionPopup.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ Control {
|
|||
signal viewMessagesRequested(string contactId)
|
||||
signal airdropRequested(string address)
|
||||
signal remoteDestructRequested(string name, string address)
|
||||
signal kickRequested(string name, string contactId)
|
||||
signal banRequested(string name, string contactId)
|
||||
signal kickRequested(string name, string contactId, string address)
|
||||
signal banRequested(string name, string contactId, string address)
|
||||
|
||||
signal generalAirdropRequested
|
||||
|
||||
|
@ -202,7 +202,8 @@ Control {
|
|||
enabled: !menu.rawAddress
|
||||
type: StatusBaseButton.Type.Danger
|
||||
|
||||
onTriggered: root.kickRequested(menu.name, menu.contactId)
|
||||
onTriggered: root.kickRequested(menu.name, menu.contactId,
|
||||
menu.currentAddress)
|
||||
}
|
||||
|
||||
StatusAction {
|
||||
|
@ -213,7 +214,8 @@ Control {
|
|||
enabled: !menu.rawAddress
|
||||
type: StatusBaseButton.Type.Danger
|
||||
|
||||
onTriggered: root.banRequested(menu.name, menu.contactId)
|
||||
onTriggered: root.banRequested(menu.name, menu.contactId,
|
||||
menu.currentAddress)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,9 @@ StatusDialog {
|
|||
|
||||
property var accountsModel
|
||||
readonly property alias selectedAccount: d.accountAddress
|
||||
readonly property alias selectedAccountName: d.accountName
|
||||
|
||||
readonly property alias deleteMessages: deleteMessagesSwitch.checked
|
||||
|
||||
readonly property string feeLabel: qsTr("Remotely destruct 1 TokenMaster token on %1").arg(
|
||||
root.networkName)
|
||||
|
@ -53,6 +56,13 @@ StatusDialog {
|
|||
signal kickClicked
|
||||
signal banClicked
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
|
||||
property string accountAddress: ""
|
||||
property string accountName: ""
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
spacing: 20
|
||||
|
@ -155,6 +165,7 @@ StatusDialog {
|
|||
const item = ModelUtils.get(accountsSelector.model,
|
||||
accountsSelector.currentIndex)
|
||||
d.accountAddress = item.address
|
||||
d.accountName = item.name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -191,10 +202,4 @@ StatusDialog {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
|
||||
property string accountAddress: ""
|
||||
}
|
||||
}
|
||||
|
|
|
@ -353,6 +353,14 @@ StatusSectionLayout {
|
|||
communityTokensStore.remoteSelfDestructCollectibles(
|
||||
root.community.id, walletsAndAmounts, tokenKey, accountAddress)
|
||||
|
||||
onRemotelyDestructAndBan:
|
||||
communityTokensStore.remotelyDestructAndBan(
|
||||
root.community.id, contactId, tokenKey, accountAddress)
|
||||
|
||||
onRemotelyDestructAndKick:
|
||||
communityTokensStore.remotelyDestructAndKick(
|
||||
root.community.id, contactId, tokenKey, accountAddress)
|
||||
|
||||
onBurnToken:
|
||||
communityTokensStore.burnToken(root.community.id, tokenKey, amount, accountAddress)
|
||||
|
||||
|
|
|
@ -71,8 +71,8 @@ StatusScrollView {
|
|||
signal viewMessagesRequested(string contactId)
|
||||
|
||||
signal remoteDestructRequested(string name, string address)
|
||||
signal kickRequested(string name, string contactId)
|
||||
signal banRequested(string name, string contactId)
|
||||
signal kickRequested(string name, string contactId, string address)
|
||||
signal banRequested(string name, string contactId, string address)
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
|
@ -213,8 +213,8 @@ StatusScrollView {
|
|||
onGeneralAirdropRequested: root.generalAirdropRequested()
|
||||
onRemoteDestructRequested: root.remoteDestructRequested(name, address)
|
||||
|
||||
onKickRequested: root.kickRequested(name, contactId)
|
||||
onBanRequested: root.banRequested(name, contactId)
|
||||
onKickRequested: root.kickRequested(name, contactId, address)
|
||||
onBanRequested: root.banRequested(name, contactId, address)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,6 +137,14 @@ QtObject {
|
|||
communityTokensModuleInst.selfDestructCollectibles(communityId, JSON.stringify(walletsAndAmounts), tokenKey, accountAddress)
|
||||
}
|
||||
|
||||
function remotelyDestructAndBan(communityId, contactId, tokenKey, accountAddress, deleteMessages) {
|
||||
console.warn("remotelyDestructAndBan, not implemented yet!")
|
||||
}
|
||||
|
||||
function remotelyDestructAndKick(communityId, contactId, tokenKey, accountAddress) {
|
||||
console.warn("remotelyDestructAndKick, not implemented yet!")
|
||||
}
|
||||
|
||||
function burnToken(communityId, tokenKey, burnAmount, accountAddress) {
|
||||
console.assert(typeof burnAmount === "string")
|
||||
communityTokensModuleInst.burnTokens(communityId, tokenKey, burnAmount, accountAddress)
|
||||
|
|
Loading…
Reference in New Issue