feat(Mint/Airdrop Collectible): Implement Airdrop footer option
It enables navigation from mint token page to airdrop page selecting a specific collectible to be airdropped. It is now used `symbol` property as the identifier for a collectible but will be needed to update it to `key` once this key property is build in backend by hash(chainId + contractAddress). Closes #10047
This commit is contained in:
parent
4e5f7763db
commit
73b2ec2903
|
@ -22,11 +22,15 @@ SettingsPageLayout {
|
||||||
signal airdropClicked(var airdropTokens, var addresses)
|
signal airdropClicked(var airdropTokens, var addresses)
|
||||||
signal navigateToMintTokenSettings
|
signal navigateToMintTokenSettings
|
||||||
|
|
||||||
// TODO: Update with stackmanager when #8736 is integrated
|
|
||||||
function navigateBack() {
|
function navigateBack() {
|
||||||
stackManager.pop(StackView.Immediate)
|
stackManager.pop(StackView.Immediate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectCollectible(key, amount) {
|
||||||
|
d.selectCollectible(key, amount)
|
||||||
|
}
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: d
|
id: d
|
||||||
|
|
||||||
|
@ -35,6 +39,8 @@ SettingsPageLayout {
|
||||||
|
|
||||||
readonly property string welcomePageTitle: qsTr("Airdrops")
|
readonly property string welcomePageTitle: qsTr("Airdrops")
|
||||||
readonly property string newAirdropViewPageTitle: qsTr("New airdrop")
|
readonly property string newAirdropViewPageTitle: qsTr("New airdrop")
|
||||||
|
|
||||||
|
signal selectCollectible(string key, int amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
content: StackView {
|
content: StackView {
|
||||||
|
@ -92,6 +98,8 @@ SettingsPageLayout {
|
||||||
id: newAirdropView
|
id: newAirdropView
|
||||||
|
|
||||||
CommunityNewAirdropView {
|
CommunityNewAirdropView {
|
||||||
|
id: view
|
||||||
|
|
||||||
assetsModel: root.assetsModel
|
assetsModel: root.assetsModel
|
||||||
collectiblesModel: root.collectiblesModel
|
collectiblesModel: root.collectiblesModel
|
||||||
|
|
||||||
|
@ -100,6 +108,8 @@ SettingsPageLayout {
|
||||||
stackManager.clear(d.welcomeViewState, StackView.Immediate)
|
stackManager.clear(d.welcomeViewState, StackView.Immediate)
|
||||||
}
|
}
|
||||||
onNavigateToMintTokenSettings: root.navigateToMintTokenSettings()
|
onNavigateToMintTokenSettings: root.navigateToMintTokenSettings()
|
||||||
|
|
||||||
|
Component.onCompleted: d.selectCollectible.connect(view.selectCollectible)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,12 +51,6 @@ SettingsPageLayout {
|
||||||
|
|
||||||
signal signMintTransactionOpened(int chainId, string accountAddress)
|
signal signMintTransactionOpened(int chainId, string accountAddress)
|
||||||
|
|
||||||
function setFeeLoading() {
|
|
||||||
root.isFeeLoading = true
|
|
||||||
root.feeText = ""
|
|
||||||
root.errorText = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
signal remoteSelfDestructCollectibles(var holdersModel,
|
signal remoteSelfDestructCollectibles(var holdersModel,
|
||||||
int chainId,
|
int chainId,
|
||||||
string accountName,
|
string accountName,
|
||||||
|
@ -64,6 +58,14 @@ SettingsPageLayout {
|
||||||
|
|
||||||
signal signSelfDestructTransactionOpened(int chainId)
|
signal signSelfDestructTransactionOpened(int chainId)
|
||||||
|
|
||||||
|
signal airdropCollectible(string key)
|
||||||
|
|
||||||
|
function setFeeLoading() {
|
||||||
|
root.isFeeLoading = true
|
||||||
|
root.feeText = ""
|
||||||
|
root.errorText = ""
|
||||||
|
}
|
||||||
|
|
||||||
function navigateBack() {
|
function navigateBack() {
|
||||||
stackManager.pop(StackView.Immediate)
|
stackManager.pop(StackView.Immediate)
|
||||||
}
|
}
|
||||||
|
@ -90,6 +92,8 @@ SettingsPageLayout {
|
||||||
readonly property var initialItem: (root.tokensModel && root.tokensModel.count > 0) ? mintedTokensView : welcomeView
|
readonly property var initialItem: (root.tokensModel && root.tokensModel.count > 0) ? mintedTokensView : welcomeView
|
||||||
onInitialItemChanged: updateInitialStackView()
|
onInitialItemChanged: updateInitialStackView()
|
||||||
|
|
||||||
|
signal airdropClicked()
|
||||||
|
|
||||||
function updateInitialStackView() {
|
function updateInitialStackView() {
|
||||||
if(stackManager.stackView) {
|
if(stackManager.stackView) {
|
||||||
if(initialItem === welcomeView)
|
if(initialItem === welcomeView)
|
||||||
|
@ -267,11 +271,12 @@ SettingsPageLayout {
|
||||||
signSelfDestructPopup.close()
|
signSelfDestructPopup.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
airdropEnabled: false
|
airdropEnabled: true
|
||||||
retailEnabled: false
|
retailEnabled: false
|
||||||
remotelySelfDestructEnabled: true
|
remotelySelfDestructEnabled: true
|
||||||
burnEnabled: false
|
burnEnabled: false
|
||||||
|
|
||||||
|
onAirdropClicked: d.airdropClicked()
|
||||||
onRemotelySelfDestructClicked: remoteSelfdestructPopup.open()
|
onRemotelySelfDestructClicked: remoteSelfdestructPopup.open()
|
||||||
|
|
||||||
RemoteSelfDestructPopup {
|
RemoteSelfDestructPopup {
|
||||||
|
@ -387,6 +392,14 @@ SettingsPageLayout {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: d
|
||||||
|
|
||||||
|
function onAirdropClicked() {
|
||||||
|
root.airdropCollectible(view.symbol) // TODO: Backend. It should just be the key (hash(chainId + contractAddress)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,6 +332,7 @@ StatusSectionLayout {
|
||||||
accountName,
|
accountName,
|
||||||
accountAddress)
|
accountAddress)
|
||||||
}
|
}
|
||||||
|
onAirdropCollectible: root.goTo(Constants.CommunitySettingsSections.Airdrops)
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: rootStore.communityTokensStore
|
target: rootStore.communityTokensStore
|
||||||
|
@ -385,6 +386,8 @@ StatusSectionLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
CommunityAirdropsSettingsPanel {
|
CommunityAirdropsSettingsPanel {
|
||||||
|
id: airdropPanel
|
||||||
|
|
||||||
readonly property CommunityTokensStore communityTokensStore:
|
readonly property CommunityTokensStore communityTokensStore:
|
||||||
rootStore.communityTokensStore
|
rootStore.communityTokensStore
|
||||||
|
|
||||||
|
@ -394,6 +397,18 @@ StatusSectionLayout {
|
||||||
onPreviousPageNameChanged: root.backButtonName = previousPageName
|
onPreviousPageNameChanged: root.backButtonName = previousPageName
|
||||||
onAirdropClicked: communityTokensStore.airdrop(root.community.id, airdropTokens, addresses)
|
onAirdropClicked: communityTokensStore.airdrop(root.community.id, airdropTokens, addresses)
|
||||||
onNavigateToMintTokenSettings: root.goTo(Constants.CommunitySettingsSections.MintTokens)
|
onNavigateToMintTokenSettings: root.goTo(Constants.CommunitySettingsSections.MintTokens)
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: mintPanel
|
||||||
|
|
||||||
|
function onAirdropCollectible(key) {
|
||||||
|
// Here it is forced a navigation to the new airdrop form, like if it was clicked the header button
|
||||||
|
airdropPanel.headerButtonClicked()
|
||||||
|
|
||||||
|
// Force a token selection to be airdroped with default amount 1
|
||||||
|
airdropPanel.selectCollectible(key, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onCurrentIndexChanged: root.backButtonName = centerPanelContentLoader.item.children[d.currentIndex].previousPageName
|
onCurrentIndexChanged: root.backButtonName = centerPanelContentLoader.item.children[d.currentIndex].previousPageName
|
||||||
|
@ -412,8 +427,8 @@ StatusSectionLayout {
|
||||||
|
|
||||||
function goTo(section: int, subSection: int) {
|
function goTo(section: int, subSection: int) {
|
||||||
//find and enable section
|
//find and enable section
|
||||||
const matchingIndex = listView.model.findIndex((modelItem, index) => modelItem.id == section && modelItem.enabled)
|
const matchingIndex = listView.model.findIndex((modelItem, index) => modelItem.id === section && modelItem.enabled)
|
||||||
if(matchingIndex != -1) {
|
if(matchingIndex !== -1) {
|
||||||
d.currentIndex = matchingIndex
|
d.currentIndex = matchingIndex
|
||||||
//find and enable subsection if subSection navigation is available
|
//find and enable subsection if subSection navigation is available
|
||||||
if(d.currentItem && d.currentItem.goTo) {
|
if(d.currentItem && d.currentItem.goTo) {
|
||||||
|
|
|
@ -34,12 +34,24 @@ StatusScrollView {
|
||||||
signal airdropClicked(var airdropTokens, var addresses)
|
signal airdropClicked(var airdropTokens, var addresses)
|
||||||
signal navigateToMintTokenSettings
|
signal navigateToMintTokenSettings
|
||||||
|
|
||||||
|
function selectCollectible(key, amount) {
|
||||||
|
const modelItem = CommunityPermissionsHelpers.getTokenByKey(
|
||||||
|
root.collectiblesModel, key)
|
||||||
|
d.addItem(HoldingTypes.Type.Collectible, modelItem, amount)
|
||||||
|
}
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: d
|
id: d
|
||||||
|
|
||||||
readonly property int maxAirdropTokens: 5
|
readonly property int maxAirdropTokens: 5
|
||||||
readonly property int dropdownHorizontalOffset: 4
|
readonly property int dropdownHorizontalOffset: 4
|
||||||
readonly property int dropdownVerticalOffset: 1
|
readonly property int dropdownVerticalOffset: 1
|
||||||
|
|
||||||
|
function addItem(type, item, amount) {
|
||||||
|
const key = item.key
|
||||||
|
|
||||||
|
root.selectedHoldingsModel.append({ type, key, amount })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contentWidth: mainLayout.width
|
contentWidth: mainLayout.width
|
||||||
|
@ -81,13 +93,6 @@ StatusScrollView {
|
||||||
isCollectiblesOnly: true
|
isCollectiblesOnly: true
|
||||||
noDataText: qsTr("First you need to mint or import a collectible before you can perform an airdrop")
|
noDataText: qsTr("First you need to mint or import a collectible before you can perform an airdrop")
|
||||||
|
|
||||||
function addItem(type, item, amount) {
|
|
||||||
const key = item.key
|
|
||||||
|
|
||||||
root.selectedHoldingsModel.append(
|
|
||||||
{ type, key, amount })
|
|
||||||
}
|
|
||||||
|
|
||||||
function getHoldingIndex(key) {
|
function getHoldingIndex(key) {
|
||||||
return ModelUtils.indexOf(root.selectedHoldingsModel, "key", key)
|
return ModelUtils.indexOf(root.selectedHoldingsModel, "key", key)
|
||||||
}
|
}
|
||||||
|
@ -112,14 +117,14 @@ StatusScrollView {
|
||||||
onAddAsset: {
|
onAddAsset: {
|
||||||
const modelItem = CommunityPermissionsHelpers.getTokenByKey(
|
const modelItem = CommunityPermissionsHelpers.getTokenByKey(
|
||||||
root.assetsModel, key)
|
root.assetsModel, key)
|
||||||
addItem(HoldingTypes.Type.Asset, modelItem, amount)
|
d.addItem(HoldingTypes.Type.Asset, modelItem, amount)
|
||||||
dropdown.close()
|
dropdown.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
onAddCollectible: {
|
onAddCollectible: {
|
||||||
const modelItem = CommunityPermissionsHelpers.getTokenByKey(
|
const modelItem = CommunityPermissionsHelpers.getTokenByKey(
|
||||||
root.collectiblesModel, key)
|
root.collectiblesModel, key)
|
||||||
addItem(HoldingTypes.Type.Collectible, modelItem, amount)
|
d.addItem(HoldingTypes.Type.Collectible, modelItem, amount)
|
||||||
dropdown.close()
|
dropdown.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue