feat(Communities): Add TokenMasterActionPopup to MintTokensSettingsPanel

Closes: #11622
This commit is contained in:
Michał Cieślak 2023-08-02 17:32:36 +02:00 committed by Michał
parent 383cd6dcf7
commit a793865835
5 changed files with 99 additions and 28 deletions

View File

@ -1,6 +1,8 @@
import QtQuick 2.14 import QtQuick 2.15
import QtQuick.Controls 2.14 import QtQuick.Controls 2.15
import QtQuick.Layouts 1.14 import QtQuick.Layouts 1.15
import Qt.labs.settings 1.0
import AppLayouts.Communities.panels 1.0 import AppLayouts.Communities.panels 1.0
import AppLayouts.Chat.stores 1.0 import AppLayouts.Chat.stores 1.0
@ -185,6 +187,12 @@ SplitView {
} }
} }
} }
Settings {
property alias editorModelChecked: editorModelChecked.checked
property alias privilegedModelChecked: privilegedModelChecked.checked
property alias completeModelChecked: completeModelChecked.checked
}
} }
// category: Panels // category: Panels

View File

@ -4,6 +4,7 @@ ListModel {
id: root id: root
readonly property ListModel tokenOwnersModel: TokenHoldersModel {} readonly property ListModel tokenOwnersModel: TokenHoldersModel {}
readonly property ListModel emptyModel: ListModel {}
readonly property var data: [ readonly property var data: [
{ {
@ -24,7 +25,8 @@ ListModel {
chainId: 2, chainId: 2,
chainName: "Optimism", chainName: "Optimism",
chainIcon: ModelsData.networks.optimism, chainIcon: ModelsData.networks.optimism,
accountName: "Another account - generated" accountName: "Another account - generated",
tokenOwnersModel: root.emptyModel
}, },
{ {
isPrivilegedToken: true, isPrivilegedToken: true,
@ -44,7 +46,8 @@ ListModel {
chainId: 2, chainId: 2,
chainName: "Optimism", chainName: "Optimism",
chainIcon: ModelsData.networks.optimism, chainIcon: ModelsData.networks.optimism,
accountName: "Another account - generated" accountName: "Another account - generated",
tokenOwnersModel: root.tokenOwnersModel
}, },
{ {
isPrivilegedToken: false, isPrivilegedToken: false,
@ -64,7 +67,8 @@ ListModel {
chainId: 1, chainId: 1,
chainName: "Testnet", chainName: "Testnet",
chainIcon: ModelsData.networks.testnet, chainIcon: ModelsData.networks.testnet,
accountName: "Status Account" accountName: "Status Account",
tokenOwnersModel: root.emptyModel
}, },
{ {
isPrivilegedToken: false, isPrivilegedToken: false,
@ -84,7 +88,8 @@ ListModel {
chainId: 2, chainId: 2,
chainName: "Optimism", chainName: "Optimism",
chainIcon: ModelsData.networks.optimism, chainIcon: ModelsData.networks.optimism,
accountName: "Status New Account" accountName: "Status New Account",
tokenOwnersModel: root.emptyModel
}, },
{ {
isPrivilegedToken: false, isPrivilegedToken: false,
@ -104,7 +109,8 @@ ListModel {
chainId: 5, chainId: 5,
chainName: "Custom", chainName: "Custom",
chainIcon: ModelsData.networks.custom, chainIcon: ModelsData.networks.custom,
accountName: "Other Account" accountName: "Other Account",
tokenOwnersModel: root.emptyModel
}, },
{ {
isPrivilegedToken: false, isPrivilegedToken: false,
@ -144,7 +150,8 @@ ListModel {
chainId: 2, chainId: 2,
chainName: "Optimism", chainName: "Optimism",
chainIcon: ModelsData.networks.optimism, chainIcon: ModelsData.networks.optimism,
accountName: "Status SNT Account" accountName: "Status SNT Account",
tokenOwnersModel: root.emptyModel
}, },
{ {
isPrivilegedToken: false, isPrivilegedToken: false,
@ -163,7 +170,8 @@ ListModel {
chainId: 1, chainId: 1,
chainName: "Testnet", chainName: "Testnet",
chainIcon: ModelsData.networks.testnet, chainIcon: ModelsData.networks.testnet,
accountName: "Status Account" accountName: "Status Account",
tokenOwnersModel: root.emptyModel
} }
] ]

View File

@ -540,8 +540,58 @@ StackView {
} }
onRemoteDestructRequested: { onRemoteDestructRequested: {
remotelyDestructPopup.open() if (token.isPrivilegedToken) {
// TODO: set the address selected in the popup's list tokenMasterActionPopup.openPopup(
TokenMasterActionPopup.ActionType.RemotelyDestruct, name)
} else {
remotelyDestructPopup.open()
// TODO: set the address selected in the popup's list
}
}
onBanRequested: {
tokenMasterActionPopup.openPopup(
TokenMasterActionPopup.ActionType.Ban, name)
}
onKickRequested: {
tokenMasterActionPopup.openPopup(
TokenMasterActionPopup.ActionType.Kick, name)
}
TokenMasterActionPopup {
id: tokenMasterActionPopup
communityName: root.communityName
networkName: view.token.chainName
accountsModel: SortFilterProxyModel {
sourceModel: root.accounts
proxyRoles: [
ExpressionRole {
name: "color"
function getColor(colorId) {
return Utils.getColorForId(colorId)
}
// Direct call for singleton function is not handled properly by
// SortFilterProxyModel that's why helper function is used instead.
expression: { return getColor(model.colorId) }
}
]
filters: ValueFilter {
roleName: "walletType"
value: Constants.watchWalletType
inverted: true
}
}
function openPopup(type, userName) {
tokenMasterActionPopup.actionType = type
tokenMasterActionPopup.userName = userName
open()
}
} }
} }

View File

@ -30,9 +30,9 @@ Control {
signal viewProfileRequested(string address) signal viewProfileRequested(string address)
signal viewMessagesRequested(string address) signal viewMessagesRequested(string address)
signal airdropRequested(string address) signal airdropRequested(string address)
signal remoteDestructRequested(string address) signal remoteDestructRequested(string name, string address)
signal kickRequested(string address) signal kickRequested(string name, string address)
signal banRequested(string address) signal banRequested(string name, string address)
signal generalAirdropRequested signal generalAirdropRequested
@ -134,11 +134,9 @@ Control {
return return
const entry = ModelUtils.get(proxyModel, index) const entry = ModelUtils.get(proxyModel, index)
const address = entry.walletAddress
const name = entry.name
menu.rawAddress = name === "" menu.name = entry.name
menu.currentAddress = address menu.currentAddress = entry.walletAddress
menu.popup(parent, mouse.x, mouse.y) menu.popup(parent, mouse.x, mouse.y)
holdersList.currentIndex = index holdersList.currentIndex = index
@ -149,8 +147,9 @@ Control {
StatusMenu { StatusMenu {
id: menu id: menu
property string name
property string currentAddress property string currentAddress
property bool rawAddress readonly property bool rawAddress: name === ""
onClosed: holdersList.currentIndex = -1 onClosed: holdersList.currentIndex = -1
@ -190,7 +189,8 @@ Control {
enabled: root.showRemotelyDestructMenuItem enabled: root.showRemotelyDestructMenuItem
type: StatusBaseButton.Type.Danger type: StatusBaseButton.Type.Danger
onTriggered: root.remoteDestructRequested(menu.currentAddress) onTriggered: root.remoteDestructRequested(menu.name,
menu.currentAddress)
} }
StatusAction { StatusAction {
@ -201,7 +201,8 @@ Control {
enabled: !menu.rawAddress enabled: !menu.rawAddress
type: StatusBaseButton.Type.Danger type: StatusBaseButton.Type.Danger
onTriggered: root.kickRequested(menu.currentAddress) onTriggered: root.kickRequested(menu.name,
menu.currentAddress)
} }
StatusAction { StatusAction {
@ -212,7 +213,8 @@ Control {
enabled: !menu.rawAddress enabled: !menu.rawAddress
type: StatusBaseButton.Type.Danger type: StatusBaseButton.Type.Danger
onTriggered: root.banRequested(menu.currentAddress) onTriggered: root.banRequested(menu.name,
menu.currentAddress)
} }
} }
} }

View File

@ -67,7 +67,9 @@ StatusScrollView {
signal airdropRequested(string address) signal airdropRequested(string address)
signal generalAirdropRequested signal generalAirdropRequested
signal remoteDestructRequested(string address) signal remoteDestructRequested(string name, string address)
signal kickRequested(string name, string address)
signal banRequested(string name, string address)
signal deployFeesRequested signal deployFeesRequested
@ -150,8 +152,6 @@ StatusScrollView {
accountErrorText: root.feeErrorText accountErrorText: root.feeErrorText
model: QtObject { model: QtObject {
id: singleFeeModel
readonly property string title: root.feeLabel readonly property string title: root.feeLabel
readonly property string feeText: root.isFeeLoading ? readonly property string feeText: root.isFeeLoading ?
"" : root.feeText "" : root.feeText
@ -159,7 +159,7 @@ StatusScrollView {
} }
accountsSelector.model: SortFilterProxyModel { accountsSelector.model: SortFilterProxyModel {
sourceModel: root.accounts sourceModel: root.accounts || null
proxyRoles: [ proxyRoles: [
ExpressionRole { ExpressionRole {
name: "color" name: "color"
@ -230,7 +230,10 @@ StatusScrollView {
onAirdropRequested: root.airdropRequested(address) onAirdropRequested: root.airdropRequested(address)
onGeneralAirdropRequested: root.generalAirdropRequested() onGeneralAirdropRequested: root.generalAirdropRequested()
onRemoteDestructRequested: root.remoteDestructRequested(address) onRemoteDestructRequested: root.remoteDestructRequested(name, address)
onKickRequested: root.kickRequested(name, address)
onBanRequested: root.banRequested(name, address)
} }
} }
} }