Skip to content

Commit

Permalink
feat(@desktop/wallet): Collectible Details balance tag
Browse files Browse the repository at this point in the history
fixes #13809
  • Loading branch information
Khushboo-dev-cpp committed Apr 3, 2024
1 parent d86be3a commit 5424eda
Show file tree
Hide file tree
Showing 9 changed files with 484 additions and 379 deletions.
62 changes: 61 additions & 1 deletion storybook/pages/CollectibleDetailViewPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,23 @@ import utils 1.0
SplitView {
id: root

QtObject {
function isValidURL(url) {
return true
}

Component.onCompleted: {
Utils.globalUtilsInst = this
}
Component.onDestruction: {
Utils.globalUtilsInst = {}
}
}

QtObject {
id: d

readonly property QtObject collectiblesModel: WalletCollectiblesModel {
readonly property QtObject collectiblesModel: ManageCollectiblesModel {
Component.onCompleted: {
d.refreshCurrentCollectible()
}
Expand All @@ -34,6 +47,15 @@ SplitView {
}

readonly property QtObject transactionsModel: WalletTransactionsModel{}

readonly property string addressesSelected: {
let supportedAddresses = ""
for (let i =0; i< accountsRepeater.count; i++) {
if (accountsRepeater.itemAt(i).checked && accountsRepeater.itemAt(i).visible)
supportedAddresses += accountsRepeater.itemAt(i).address + ":"
}
return supportedAddresses
}
}

SplitView {
Expand Down Expand Up @@ -62,6 +84,7 @@ SplitView {
collectible: d.currentCollectible
isCollectibleLoading: isLoadingCheckbox.checked
activityModel: d.transactionsModel
addressFilters: d.addressesSelected
rootStore: QtObject {
readonly property string currentCurrency: "EUR"

Expand All @@ -83,6 +106,26 @@ SplitView {
}

readonly property bool showAllAccounts: true

function getExplorerUrl(networkShortName, contractAddress, tokenId) {
let link = Constants.networkExplorerLinks.etherscan
if (networkShortName === Constants.networkShortChainNames.mainnet) {
return "%1/nft/%2/%3".arg(link).arg(contractAddress).arg(tokenId)
}
else {
return "%1/token/%2?a=%3".arg(link).arg(contractAddress).arg(tokenId)
}
}

function getOpenSeaCollectionUrl(networkShortName, contractAddress) {
let baseLink = root.areTestNetworksEnabled ? Constants.openseaExplorerLinks.testnetLink : Constants.openseaExplorerLinks.mainnetLink
return "%1/assets/%2/%3".arg(baseLink).arg(networkShortName).arg(contractAddress)
}

function getOpenSeaCollectibleUrl(networkShortName, contractAddress, tokenId) {
let baseLink = root.areTestNetworksEnabled ? Constants.openseaExplorerLinks.testnetLink : Constants.openseaExplorerLinks.mainnetLink
return "%1/assets/%2/%3/%4".arg(baseLink).arg(networkShortName).arg(contractAddress).arg(tokenId)
}
}
communitiesStore: QtObject {
function getCommunityDetailsAsJson(communityId) {
Expand Down Expand Up @@ -130,6 +173,23 @@ SplitView {
text: "isLoading"
checked: false
}
ColumnLayout {
Layout.fillWidth: true
Text {
text: "select account(s)"
}
Repeater {
id: accountsRepeater
model: WalletAccountsModel {}
delegate: CheckBox {
property string address: model.address
checked: true
visible: index<2
width: parent.width
text: name
}
}
}
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions storybook/qmlTests/tests/tst_ManageCollectiblesPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Item {
const lvOther = findChild(controlUnderTest, "otherTokensListView")
verify(!!lvOther)

tryCompare(lvOther, "count", 7)
tryCompare(lvOther, "count", 9)
const delegate0 = findChild(lvOther, "manageTokensDelegate-0")
verify(!!delegate0)
const title = delegate0.title
Expand All @@ -127,7 +127,7 @@ Item {
tryCompare(notificationSpy, "count", 1)

// verify we now have -1 regular tokens after the "hide" operation
tryCompare(lvOther, "count", 6)
tryCompare(lvOther, "count", 8)
}

function test_showHideCommunityGroup() {
Expand All @@ -149,15 +149,15 @@ Item {
verify(!!lvCommunity)

// verify we have 2 community collectible groups
tryCompare(lvCommunity, "count", 4)
tryCompare(lvCommunity, "count", 6)
tryCompare(notificationSpy, "count", 0)
triggerDelegateMenuAction(lvCommunity, 0, "miHideTokenGroup", true)
// verify the signal to show the notification toast got fired
tryCompare(notificationSpy, "count", 1)

// verify we have one less group
waitForItemPolished(lvCommunity)
tryCompare(lvCommunity, "count", 3)
tryCompare(lvCommunity, "count", 5)
}

function test_dnd() {
Expand Down Expand Up @@ -200,7 +200,7 @@ Item {
const lvCommunity = findChild(controlUnderTest, "communityTokensListView")
verify(!!lvCommunity)
waitForItemPolished(lvCommunity)
tryCompare(lvCommunity, "count", 4)
tryCompare(lvCommunity, "count", 6)

const group0 = findChild(lvCommunity, "manageTokensGroupDelegate-0")
const title0 = group0.title
Expand Down Expand Up @@ -235,7 +235,7 @@ Item {
const lvCommunity = findChild(controlUnderTest, "communityTokensListView")
verify(!!lvCommunity)
waitForItemPolished(lvCommunity)
tryCompare(lvCommunity, "count", 4)
tryCompare(lvCommunity, "count", 6)

// get the "Bearz" group at index 1
var bearzGroupTokenDelegate = findChild(lvCommunity, "manageTokensGroupDelegate-1")
Expand Down
Loading

0 comments on commit 5424eda

Please sign in to comment.