mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-07 04:06:02 +00:00
chore(Storybook): MintedTokensModel refactored to be a regular component instead of a stateful singleton
This commit is contained in:
parent
5a0a5357d1
commit
c4e68b50db
@ -34,8 +34,7 @@ SplitView {
|
||||
enabledNetworks: NetworksModel.enabledNetworks
|
||||
allNetworks: enabledNetworks
|
||||
accounts: WalletAccountsModel {}
|
||||
tokensModel: isAssetBox.checked ? MintedTokensModel.mintedAssetsModel : MintedTokensModel.mintedCollectiblesModel
|
||||
|
||||
tokensModel: MintedTokensModel {}
|
||||
onPreviewClicked: logs.logEvent("EditCommunityTokenView::previewClicked")
|
||||
}
|
||||
}
|
||||
@ -48,17 +47,12 @@ SplitView {
|
||||
SplitView.preferredHeight: 150
|
||||
|
||||
logsView.logText: logs.logText
|
||||
}
|
||||
}
|
||||
|
||||
Pane {
|
||||
SplitView.minimumWidth: 300
|
||||
SplitView.preferredWidth: 300
|
||||
|
||||
CheckBox {
|
||||
id: isAssetBox
|
||||
text: "Is Assets View?"
|
||||
checked: false
|
||||
CheckBox {
|
||||
id: isAssetBox
|
||||
text: "Is Assets View?"
|
||||
checked: false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,9 +32,13 @@ SplitView {
|
||||
MintTokensSettingsPanel {
|
||||
id: panel
|
||||
|
||||
MintedTokensModel {
|
||||
id: mintedTokensModel
|
||||
}
|
||||
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: 50
|
||||
tokensModel: editorModelChecked.checked ? emptyModel : MintedTokensModel.mintedTokensModel
|
||||
tokensModel: editorModelChecked.checked ? emptyModel : mintedTokensModel
|
||||
layer1Networks: NetworksModel.layer1Networks
|
||||
layer2Networks: NetworksModel.layer2Networks
|
||||
testNetworks: NetworksModel.testNetworks
|
||||
@ -79,9 +83,9 @@ SplitView {
|
||||
checked: true
|
||||
onCheckedChanged:{
|
||||
if(checked)
|
||||
MintedTokensModel.changeAllMintingStates(1/*In progress*/)
|
||||
mintedTokensModel.changeAllMintingStates(1/*In progress*/)
|
||||
else
|
||||
MintedTokensModel.changeAllMintingStates(2/*Deployed*/)
|
||||
mintedTokensModel.changeAllMintingStates(2/*Deployed*/)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,21 +1,44 @@
|
||||
import QtQuick 2.14
|
||||
import QtQuick.Controls 2.14
|
||||
import QtQuick.Layouts 1.14
|
||||
|
||||
import StatusQ.Core.Theme 0.1
|
||||
import StatusQ.Components 0.1
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
import AppLayouts.Communities.views 1.0
|
||||
|
||||
import Storybook 1.0
|
||||
import Models 1.0
|
||||
|
||||
import SortFilterProxyModel 0.2
|
||||
|
||||
import utils 1.0
|
||||
|
||||
SplitView {
|
||||
|
||||
Logs { id: logs }
|
||||
|
||||
MintedTokensModel {
|
||||
id: allTokensModel
|
||||
}
|
||||
|
||||
SortFilterProxyModel {
|
||||
id: filteredTokensModel
|
||||
|
||||
sourceModel: allTokensModel
|
||||
|
||||
filters: [
|
||||
ValueFilter {
|
||||
enabled: !allTokensRadioButton.checked
|
||||
roleName: "tokenType"
|
||||
value: onlyAssetsRadioButton.checked ? Constants.TokenType.ERC20
|
||||
: Constants.TokenType.ERC721
|
||||
},
|
||||
IndexFilter {
|
||||
enabled: nothingRadioButton.checked
|
||||
minimumIndex: -1
|
||||
maximumIndex: 0
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
|
||||
SplitView {
|
||||
orientation: Qt.Vertical
|
||||
SplitView.fillWidth: true
|
||||
@ -27,8 +50,9 @@ SplitView {
|
||||
MintedTokensView {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 50
|
||||
model: MintedTokensModel.mintedTokensModel
|
||||
onItemClicked: logs.logEvent("MintedTokensView::itemClicked --> " + tokenKey)
|
||||
model: filteredTokensModel
|
||||
onItemClicked: logs.logEvent("MintedTokensView::itemClicked",
|
||||
["tokenKey"], [tokenKey])
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,22 +66,28 @@ SplitView {
|
||||
|
||||
RowLayout {
|
||||
RadioButton {
|
||||
text: "Assets and collectibles"
|
||||
checked: true
|
||||
onCheckedChanged: if(checked) MintedTokensModel.buildMintedTokensModel(true, true)
|
||||
id: allTokensRadioButton
|
||||
|
||||
text: "Assets and collectibles"
|
||||
checked: true
|
||||
}
|
||||
|
||||
RadioButton {
|
||||
text: "Only assets"
|
||||
onCheckedChanged: if(checked) MintedTokensModel.buildMintedTokensModel(true, false)
|
||||
id: onlyAssetsRadioButton
|
||||
|
||||
text: "Only assets"
|
||||
}
|
||||
|
||||
RadioButton {
|
||||
text: "Only collectibles"
|
||||
onCheckedChanged: if(checked) MintedTokensModel.buildMintedTokensModel(false, true)
|
||||
text: "Only collectibles"
|
||||
}
|
||||
|
||||
RadioButton {
|
||||
id: nothingRadioButton
|
||||
|
||||
text: "Nothing"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,159 +1,128 @@
|
||||
pragma Singleton
|
||||
import QtQuick 2.15
|
||||
|
||||
QtObject {
|
||||
ListModel {
|
||||
id: root
|
||||
|
||||
function changeMintingState(index, deployState) {
|
||||
model.get(index).deployState = deployState
|
||||
}
|
||||
|
||||
function changeAllMintingStates(deployState) {
|
||||
for(var i = 0; i < model.count; i++) {
|
||||
changeMintingState(i, deployState)
|
||||
}
|
||||
}
|
||||
|
||||
function buildMintedTokensModel(isAssets, isCollectibles) {
|
||||
model.clear()
|
||||
|
||||
if(isAssets) {
|
||||
for(var i = 0; i < mintedAssetsModel.count; i++)
|
||||
model.append(mintedAssetsModel.get(i))
|
||||
}
|
||||
|
||||
if(isCollectibles) {
|
||||
for(var j = 0; j < collectiblesModel.count; j++)
|
||||
model.append(collectiblesModel.get(j))
|
||||
}
|
||||
}
|
||||
|
||||
readonly property ListModel tokenOwnersModel: TokenHoldersModel {}
|
||||
|
||||
readonly property ListModel mintedCollectiblesModel: ListModel {
|
||||
id: collectiblesModel
|
||||
readonly property var data: [
|
||||
{
|
||||
contractUniqueKey: "0x1726362343",
|
||||
tokenType: 2,
|
||||
name: "SuperRare artwork",
|
||||
image: ModelsData.banners.superRare,
|
||||
deployState: 0,
|
||||
symbol: "SRW",
|
||||
description: "Desc",
|
||||
supply: 1,
|
||||
remainingSupply: 1,
|
||||
infiniteSupply: true,
|
||||
transferable: false,
|
||||
remoteSelfDestruct: true,
|
||||
chainId: 1,
|
||||
chainName: "Testnet",
|
||||
chainIcon: ModelsData.networks.testnet,
|
||||
accountName: "Status Account"
|
||||
},
|
||||
{
|
||||
contractUniqueKey: "0x847843",
|
||||
tokenType: 2,
|
||||
name: "Kitty artwork",
|
||||
image: ModelsData.collectibles.kitty1Big,
|
||||
deployState: 0,
|
||||
symbol: "KAT",
|
||||
description: "Desc",
|
||||
supply: 10,
|
||||
remainingSupply: 5,
|
||||
infiniteSupply: false,
|
||||
transferable: false,
|
||||
remoteSelfDestruct: true,
|
||||
chainId: 2,
|
||||
chainName: "Optimism",
|
||||
chainIcon: ModelsData.networks.optimism,
|
||||
accountName: "Status New Account"
|
||||
},
|
||||
{
|
||||
contractUniqueKey: "0x1234525",
|
||||
tokenType: 2,
|
||||
name: "More artwork",
|
||||
image: ModelsData.banners.status,
|
||||
deployState: 1,
|
||||
symbol: "MMM",
|
||||
description: "Desc",
|
||||
supply: 1,
|
||||
remainingSupply: 0,
|
||||
infiniteSupply: true,
|
||||
transferable: false,
|
||||
remoteSelfDestruct: true,
|
||||
chainId: 5,
|
||||
chainName: "Custom",
|
||||
chainIcon: ModelsData.networks.custom,
|
||||
accountName: "Other Account"
|
||||
},
|
||||
{
|
||||
contractUniqueKey: "0x38576852",
|
||||
tokenType: 2,
|
||||
name: "Crypto Punks artwork",
|
||||
image: ModelsData.banners.cryptPunks,
|
||||
deployState: 2,
|
||||
symbol: "CPA",
|
||||
description: "Desc",
|
||||
supply: 5,
|
||||
remainingSupply: 0,
|
||||
infiniteSupply: false,
|
||||
transferable: false,
|
||||
remoteSelfDestruct: true,
|
||||
chainId: 1,
|
||||
chainName: "Hermez",
|
||||
chainIcon: ModelsData.networks.hermez,
|
||||
accountName: "Account",
|
||||
tokenOwnersModel: root.tokenOwnersModel
|
||||
},
|
||||
{
|
||||
contractUniqueKey: "0x38745623865",
|
||||
tokenType: 1,
|
||||
name: "Unisocks",
|
||||
image: ModelsData.assets.socks,
|
||||
deployState: 2,
|
||||
symbol: "SOCKS",
|
||||
description: "Socks description",
|
||||
supply: 14,
|
||||
remainingSupply: 2,
|
||||
infiniteSupply: false,
|
||||
decimals: 2,
|
||||
chainId: 2,
|
||||
chainName: "Optimism",
|
||||
chainIcon: ModelsData.networks.optimism,
|
||||
accountName: "Status SNT Account"
|
||||
},
|
||||
{
|
||||
contractUniqueKey: "0x872364871623",
|
||||
tokenType: 1,
|
||||
name: "Dai",
|
||||
image: ModelsData.assets.dai,
|
||||
deployState: 0,
|
||||
symbol: "DAI",
|
||||
description: "Desc",
|
||||
supply: 1,
|
||||
remainingSupply: 1,
|
||||
infiniteSupply: true,
|
||||
decimals: 1,
|
||||
chainId: 1,
|
||||
chainName: "Testnet",
|
||||
chainIcon: ModelsData.networks.testnet,
|
||||
accountName: "Status Account"
|
||||
}
|
||||
]
|
||||
|
||||
Component.onCompleted: append([
|
||||
{
|
||||
contractUniqueKey: "0x1726362343",
|
||||
tokenType: 2,
|
||||
name: "SuperRare artwork",
|
||||
image: ModelsData.banners.superRare,
|
||||
deployState: 0,
|
||||
symbol: "SRW",
|
||||
description: "Desc",
|
||||
supply: 1,
|
||||
remainingSupply: 1,
|
||||
infiniteSupply: true,
|
||||
transferable: false,
|
||||
remoteSelfDestruct: true,
|
||||
chainId: 1,
|
||||
chainName: "Testnet",
|
||||
chainIcon: ModelsData.networks.testnet,
|
||||
accountName: "Status Account"
|
||||
},
|
||||
{
|
||||
contractUniqueKey: "0x847843",
|
||||
tokenType: 2,
|
||||
name: "Kitty artwork",
|
||||
image: ModelsData.collectibles.kitty1Big,
|
||||
deployState: 0,
|
||||
symbol: "KAT",
|
||||
description: "Desc",
|
||||
supply: 10,
|
||||
remainingSupply: 5,
|
||||
infiniteSupply: false,
|
||||
transferable: false,
|
||||
remoteSelfDestruct: true,
|
||||
chainId: 2,
|
||||
chainName: "Optimism",
|
||||
chainIcon: ModelsData.networks.optimism,
|
||||
accountName: "Status New Account"
|
||||
},
|
||||
{
|
||||
contractUniqueKey: "0x1234525",
|
||||
tokenType: 2,
|
||||
name: "More artwork",
|
||||
image: ModelsData.banners.status,
|
||||
deployState: 1,
|
||||
symbol: "MMM",
|
||||
description: "Desc",
|
||||
supply: 1,
|
||||
remainingSupply: 0,
|
||||
infiniteSupply: true,
|
||||
transferable: false,
|
||||
remoteSelfDestruct: true,
|
||||
chainId: 5,
|
||||
chainName: "Custom",
|
||||
chainIcon: ModelsData.networks.custom,
|
||||
accountName: "Other Account"
|
||||
},
|
||||
{
|
||||
contractUniqueKey: "0x38576852",
|
||||
tokenType: 2,
|
||||
name: "Crypto Punks artwork",
|
||||
image: ModelsData.banners.cryptPunks,
|
||||
deployState: 2,
|
||||
symbol: "CPA",
|
||||
description: "Desc",
|
||||
supply: 5,
|
||||
remainingSupply: 0,
|
||||
infiniteSupply: false,
|
||||
transferable: false,
|
||||
remoteSelfDestruct: true,
|
||||
chainId: 1,
|
||||
chainName: "Hermez",
|
||||
chainIcon: ModelsData.networks.hermez,
|
||||
accountName: "Account",
|
||||
tokenOwnersModel: root.tokenOwnersModel
|
||||
}
|
||||
])
|
||||
function changeMintingState(index, deployState) {
|
||||
get(index).deployState = deployState
|
||||
}
|
||||
|
||||
readonly property ListModel mintedAssetsModel: ListModel {
|
||||
id: assetsModel
|
||||
|
||||
Component.onCompleted: append([
|
||||
{
|
||||
contractUniqueKey: "0x38745623865",
|
||||
tokenType: 1,
|
||||
name: "Unisocks",
|
||||
image: ModelsData.assets.socks,
|
||||
deployState: 2,
|
||||
symbol: "SOCKS",
|
||||
description: "Socks description",
|
||||
supply: 14,
|
||||
remainingSupply: 2,
|
||||
infiniteSupply: false,
|
||||
decimals: 2,
|
||||
chainId: 2,
|
||||
chainName: "Optimism",
|
||||
chainIcon: ModelsData.networks.optimism,
|
||||
accountName: "Status SNT Account"
|
||||
},
|
||||
{
|
||||
contractUniqueKey: "0x872364871623",
|
||||
tokenType: 1,
|
||||
name: "Dai",
|
||||
image: ModelsData.assets.dai,
|
||||
deployState: 0,
|
||||
symbol: "DAI",
|
||||
description: "Desc",
|
||||
supply: 1,
|
||||
remainingSupply: 1,
|
||||
infiniteSupply: true,
|
||||
decimals: 1,
|
||||
chainId: 1,
|
||||
chainName: "Testnet",
|
||||
chainIcon: ModelsData.networks.testnet,
|
||||
accountName: "Status Account"
|
||||
}
|
||||
])
|
||||
function changeAllMintingStates(deployState) {
|
||||
for(let i = 0; i < count; i++)
|
||||
changeMintingState(i, deployState)
|
||||
}
|
||||
|
||||
readonly property ListModel mintedTokensModel: ListModel {
|
||||
id: model
|
||||
|
||||
Component.onCompleted: buildMintedTokensModel(true, true)
|
||||
}
|
||||
Component.onCompleted: append(data)
|
||||
}
|
||||
|
@ -5,13 +5,13 @@ BannerModel 1.0 BannerModel.qml
|
||||
ChannelsModel 1.0 ChannelsModel.qml
|
||||
CollectiblesModel 1.0 CollectiblesModel.qml
|
||||
IconModel 1.0 IconModel.qml
|
||||
MintedTokensModel 1.0 MintedTokensModel.qml
|
||||
RecipientModel 1.0 RecipientModel.qml
|
||||
TokenHoldersModel 1.0 TokenHoldersModel.qml
|
||||
UsersModel 1.0 UsersModel.qml
|
||||
WalletAccountsModel 1.0 WalletAccountsModel.qml
|
||||
WalletAssetsModel 1.0 WalletAssetsModel.qml
|
||||
singleton MintedTokensModel 1.0 MintedTokensModel.qml
|
||||
WalletKeyPairModel 1.0 WalletKeyPairModel.qml
|
||||
singleton ModelsData 1.0 ModelsData.qml
|
||||
singleton NetworksModel 1.0 NetworksModel.qml
|
||||
singleton PermissionsModel 1.0 PermissionsModel.qml
|
||||
RecipientModel 1.0 RecipientModel.qml
|
||||
WalletKeyPairModel 1.0 WalletKeyPairModel.qml
|
||||
|
Loading…
x
Reference in New Issue
Block a user