mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-11 14:54:48 +00:00
8b4cbc59a8
The new account selector expects a generic account model. It will display all the account data if provided, including preferred chains, balance or asset balance. Otherwise it will display only the available data. The account selector can receive an initial selection based on account address and will provide the current selected address and the current selected model item. - Unify the account selector between communities and wallet - Update the account selector to work with addresses instead of model indexes - Adapt all components using the account selector or the account selection - Move/reuse qml components involved in the account selector UI - Remove nim logic used to handle index based account selection. - Adding storybook page
197 lines
6.5 KiB
QML
197 lines
6.5 KiB
QML
import QtQuick 2.15
|
|
import QtQuick.Controls 2.15
|
|
import QtQuick.Layouts 1.15
|
|
import QtQml.Models 2.15
|
|
|
|
import StatusQ.Core 0.1
|
|
import StatusQ.Controls 0.1
|
|
import StatusQ.Popups.Dialog 0.1
|
|
import StatusQ.Core.Theme 0.1
|
|
import StatusQ.Core.Utils 0.1
|
|
|
|
import AppLayouts.Communities.panels 1.0
|
|
|
|
import utils 1.0
|
|
|
|
|
|
StatusDialog {
|
|
id: root
|
|
|
|
enum ActionType {
|
|
RemotelyDestruct, Kick, Ban
|
|
}
|
|
|
|
title: {
|
|
if (actionType === TokenMasterActionPopup.ActionType.Ban)
|
|
return qsTr("Ban %1").arg(userName)
|
|
if (actionType === TokenMasterActionPopup.ActionType.Kick)
|
|
return qsTr("Kick %1").arg(userName)
|
|
|
|
return qsTr("Remotely destruct TokenMaster token")
|
|
}
|
|
|
|
implicitWidth: 600
|
|
|
|
property int actionType: TokenMasterActionPopup.ActionType.RemotelyDestruct
|
|
|
|
property string communityName
|
|
property string userName
|
|
property string networkName
|
|
|
|
property string feeText
|
|
property string feeErrorText
|
|
property bool isFeeLoading
|
|
|
|
|
|
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)
|
|
|
|
signal remotelyDestructClicked
|
|
signal kickClicked
|
|
signal banClicked
|
|
|
|
QtObject {
|
|
id: d
|
|
|
|
readonly property string accountAddress: feesBox.accountsSelector.currentAccountAddress
|
|
readonly property string accountName: feesBox.accountsSelector.currentAccount.name ?? ""
|
|
}
|
|
|
|
ColumnLayout {
|
|
anchors.fill: parent
|
|
spacing: 20
|
|
|
|
StatusBaseText {
|
|
Layout.fillWidth: true
|
|
text: {
|
|
if (root.actionType === TokenMasterActionPopup.ActionType.RemotelyDestruct)
|
|
return qsTr('Continuing will destroy the TokenMaster token held by <span style="font-weight:600;">%1</span> and revoke the permissions they have by virtue of holding this token.')
|
|
.arg(root.userName)
|
|
|
|
if (root.actionType === TokenMasterActionPopup.ActionType.Kick)
|
|
return qsTr('Are you sure you kick <span style="font-weight:600;">%1</span> from %2? <span style="font-weight:600;">%1</span> is a TokenMaster hodler. In order to kick them you must also remotely destruct their TokenMaster token to revoke the permissions they have by virtue of holding this token.')
|
|
.arg(root.userName).arg(root.communityName)
|
|
|
|
if (root.actionType === TokenMasterActionPopup.ActionType.Ban)
|
|
return qsTr('Are you sure you ban <span style="font-weight:600;">%1</span> from %2? <span style="font-weight:600;">%1</span> is a TokenMaster hodler. In order to kick them you must also remotely destruct their TokenMaster token to revoke the permissions they have by virtue of holding this token.')
|
|
.arg(root.userName).arg(root.communityName)
|
|
}
|
|
|
|
textFormat: Text.RichText
|
|
wrapMode: Text.Wrap
|
|
lineHeight: 22
|
|
lineHeightMode: Text.FixedHeight
|
|
}
|
|
|
|
Rectangle {
|
|
Layout.bottomMargin: 2
|
|
Layout.preferredHeight: 1
|
|
Layout.fillWidth: true
|
|
|
|
visible: root.actionType
|
|
!== TokenMasterActionPopup.ActionType.RemotelyDestruct
|
|
color: Theme.palette.baseColor2
|
|
}
|
|
|
|
RowLayout {
|
|
visible: root.actionType === TokenMasterActionPopup.ActionType.Ban
|
|
|
|
StatusBaseText {
|
|
Layout.fillWidth: true
|
|
|
|
text: qsTr("Delete all messages posted by the user")
|
|
color: Theme.palette.directColor1
|
|
font.pixelSize: Theme.primaryTextFontSize
|
|
}
|
|
|
|
StatusSwitch {
|
|
id: deleteMessagesSwitch
|
|
|
|
checked: true
|
|
verticalPadding: 2
|
|
}
|
|
}
|
|
|
|
RowLayout {
|
|
Layout.bottomMargin: 2
|
|
|
|
visible: root.actionType
|
|
!== TokenMasterActionPopup.ActionType.RemotelyDestruct
|
|
|
|
StatusBaseText {
|
|
Layout.fillWidth: true
|
|
|
|
text: qsTr("Remotely destruct 1 TokenMaster token")
|
|
color: Theme.palette.directColor1
|
|
font.pixelSize: Theme.primaryTextFontSize
|
|
}
|
|
|
|
StatusSwitch {
|
|
id: remotelyDestructSwitch
|
|
|
|
checked: true
|
|
enabled: false
|
|
verticalPadding: 2
|
|
}
|
|
}
|
|
|
|
FeesBox {
|
|
id: feesBox
|
|
Layout.fillWidth: true
|
|
|
|
implicitWidth: 0
|
|
|
|
accountsSelector.model: root.accountsModel
|
|
accountErrorText: root.feeErrorText
|
|
|
|
model: QtObject {
|
|
id: singleFeeModel
|
|
|
|
readonly property string title: root.feeLabel
|
|
readonly property string feeText: root.isFeeLoading ?
|
|
"" : root.feeText
|
|
readonly property bool error: root.feeErrorText !== ""
|
|
}
|
|
}
|
|
}
|
|
|
|
footer: StatusDialogFooter {
|
|
spacing: Style.current.padding
|
|
|
|
rightButtons: ObjectModel {
|
|
StatusFlatButton {
|
|
text: qsTr("Cancel")
|
|
onClicked: close()
|
|
}
|
|
StatusButton {
|
|
enabled: !root.isFeeLoading && root.feeErrorText === ""
|
|
text: {
|
|
if (root.actionType === TokenMasterActionPopup.ActionType.Ban)
|
|
return qsTr("Ban %1 and remotely destruct 1 token").arg(root.userName)
|
|
|
|
if (root.actionType === TokenMasterActionPopup.ActionType.Kick)
|
|
return qsTr("Kick %1 and remotely destruct 1 token").arg(root.userName)
|
|
|
|
return qsTr("Remotely destruct 1 token")
|
|
}
|
|
|
|
type: StatusBaseButton.Type.Danger
|
|
onClicked: {
|
|
if (root.actionType === TokenMasterActionPopup.ActionType.RemotelyDestruct)
|
|
root.remotelyDestructClicked()
|
|
else if (root.actionType === TokenMasterActionPopup.ActionType.Ban)
|
|
root.banClicked()
|
|
else if (root.actionType === TokenMasterActionPopup.ActionType.Kick)
|
|
root.kickClicked()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|