feat(OwnerToken): Add `Retry` button

- In case of `Owner` and `TMaster` token deployment failed, a `Retry` button must be shown in minted tokens pages and it will navigate to the `Edit page` the same way it's done by using `Retry` button inside the item selected.
- Updated storybook accordingly.

Closes #11613
This commit is contained in:
Noelia 2023-08-01 12:31:50 +02:00 committed by Noelia
parent 3d2deb5335
commit 939dc03728
5 changed files with 84 additions and 40 deletions

View File

@ -77,6 +77,7 @@ SplitView {
// Owner and TMaster related props: // Owner and TMaster related props:
isOwnerTokenDeployed: deployCheck.checked isOwnerTokenDeployed: deployCheck.checked
isTMasterTokenDeployed: deployCheck.checked isTMasterTokenDeployed: deployCheck.checked
anyPrivilegedTokenFailed: failedCheck.checked
// Models: // Models:
tokensModel: editorModelChecked.checked ? emptyModel : tokensModel: editorModelChecked.checked ? emptyModel :
@ -148,6 +149,7 @@ SplitView {
id: privilegedModelChecked id: privilegedModelChecked
text: "Owner token and TMaster token only" text: "Owner token and TMaster token only"
} }
RadioButton { RadioButton {
id: completeModelChecked id: completeModelChecked
@ -165,7 +167,10 @@ SplitView {
} }
RadioButton { RadioButton {
id: failedCheck
text: "Set all to 'Error'" text: "Set all to 'Error'"
checked: true
onClicked: mintedTokensModel.changeAllMintingStates(0) onClicked: mintedTokensModel.changeAllMintingStates(0)
} }

View File

@ -24,6 +24,7 @@ StackView {
// General properties: // General properties:
property int viewWidth: 560 // by design property int viewWidth: 560 // by design
property string previousPageName: depth > 1 ? qsTr("Back") : ""
required property string communityName required property string communityName
required property string communityLogo required property string communityLogo
required property color communityColor required property color communityColor
@ -39,6 +40,7 @@ StackView {
readonly property bool arePrivilegedTokensDeployed: root.isOwnerTokenDeployed && root.isTMasterTokenDeployed readonly property bool arePrivilegedTokensDeployed: root.isOwnerTokenDeployed && root.isTMasterTokenDeployed
property bool isOwnerTokenDeployed: false property bool isOwnerTokenDeployed: false
property bool isTMasterTokenDeployed: false property bool isTMasterTokenDeployed: false
property bool anyPrivilegedTokenFailed: false
// It will monitorize if Owner and/or TMaster token items are included in the `tokensModel` despite the deployment state // It will monitorize if Owner and/or TMaster token items are included in the `tokensModel` despite the deployment state
property bool ownerOrTMasterTokenItemsExist: false property bool ownerOrTMasterTokenItemsExist: false
@ -97,21 +99,21 @@ StackView {
return return
} }
if(root.arePrivilegedTokensInProgress || root.arePrivilegedTokensFailed) { if(root.arePrivilegedTokensDeployed) {
// If Owner and TMaster tokens deployment action has been started at least ones, but still without success // Regular minting flow for Owner and TMaster owner, selecting the specific tab
root.push(mintedTokensViewComponent, StackView.Immediate)
return
}
if(root.ownerOrTMasterTokenItemsExist) {
// Regular minting flow, selecting the specific tab
const properties = { isAssetView } const properties = { isAssetView }
root.push(newTokenViewComponent, properties, StackView.Immediate) root.push(newTokenViewComponent, properties, StackView.Immediate)
return return
} }
if(root.ownerOrTMasterTokenItemsExist) {
// Owner and TMaster tokens deployment action has been started at least ones but still without success
root.push(mintedTokensViewComponent, StackView.Immediate)
return
}
if(root.isOwner) { if(root.isOwner) {
// Owner and TMaster tokens to be deployed. // Owner and TMaster tokens to be deployed. Never tried.
root.push(ownerTokenViewComponent, StackView.Immediate) root.push(ownerTokenViewComponent, StackView.Immediate)
return return
} }
@ -120,7 +122,23 @@ StackView {
root.push(mintedTokensViewComponent, StackView.Immediate) root.push(mintedTokensViewComponent, StackView.Immediate)
} }
property string previousPageName: depth > 1 ? qsTr("Back") : "" QtObject {
id: d
// Owner or TMaster token retry navigation
function retryPrivilegedToken(key, chainId, accountName, accountAddress) {
var properties = {
key: key,
chainId: chainId,
accountName: accountName,
accountAddress: accountAddress,
}
root.push(ownerTokenEditViewComponent, properties,
StackView.Immediate)
}
}
initialItem: mintedTokensViewComponent initialItem: mintedTokensViewComponent
@ -178,9 +196,11 @@ StackView {
isOwner: root.isOwner isOwner: root.isOwner
isAdmin: root.isAdmin isAdmin: root.isAdmin
communityName: root.communityName communityName: root.communityName
anyPrivilegedTokenFailed: root.anyPrivilegedTokenFailed
onItemClicked: root.push(tokenViewComponent, { tokenKey }, StackView.Immediate) onItemClicked: root.push(tokenViewComponent, { tokenKey }, StackView.Immediate)
onMintOwnerTokenClicked: root.push(ownerTokenViewComponent, StackView.Immediate) onMintOwnerTokenClicked: root.push(ownerTokenViewComponent, StackView.Immediate)
onRetryOwnerTokenClicked: d.retryPrivilegedToken(tokenKey, chainId, accountName, accountAddress)
} }
} }
} }
@ -498,18 +518,6 @@ StackView {
tokenView.Component.destruction.connect(() => tokenObject.destroy()) tokenView.Component.destruction.connect(() => tokenObject.destroy())
} }
// Owner or TMaster token
function retryPrivilegedToken() {
var properties = {
chainId: view.token.chainId,
accountName: view.token.accountName,
accountAddress: view.token.accountAddress,
}
root.push(ownerTokenEditViewComponent, properties,
StackView.Immediate)
}
text: qsTr("Retry mint") text: qsTr("Retry mint")
visible: (tokenViewPage.isPrivilegedTokenItem && root.isOwner && tokenViewPage.deploymentFailed) || visible: (tokenViewPage.isPrivilegedTokenItem && root.isOwner && tokenViewPage.deploymentFailed) ||
@ -517,7 +525,7 @@ StackView {
onClicked: { onClicked: {
if(tokenViewPage.isPrivilegedTokenItem) { if(tokenViewPage.isPrivilegedTokenItem) {
retryPrivilegedToken() d.retryPrivilegedToken(view.token.key, view.token.chainId, view.token.accountName, view.token.accountAddress)
} else { } else {
retryAssetOrCollectible() retryAssetOrCollectible()
} }

View File

@ -37,13 +37,13 @@ Control {
readonly property int iconSize: ({ readonly property int iconSize: ({
[PrivilegedTokenArtworkPanel.Size.Small]: 14, [PrivilegedTokenArtworkPanel.Size.Small]: 14,
[PrivilegedTokenArtworkPanel.Size.Medium]: 16, [PrivilegedTokenArtworkPanel.Size.Medium]: 24,
[PrivilegedTokenArtworkPanel.Size.Large]: 38 [PrivilegedTokenArtworkPanel.Size.Large]: 38
}[size]) }[size])
readonly property int iconMargins: ({ readonly property int iconMargins: ({
[PrivilegedTokenArtworkPanel.Size.Small]: 8, [PrivilegedTokenArtworkPanel.Size.Small]: 8,
[PrivilegedTokenArtworkPanel.Size.Medium]: 12, [PrivilegedTokenArtworkPanel.Size.Medium]: 10,
[PrivilegedTokenArtworkPanel.Size.Large]: 16 [PrivilegedTokenArtworkPanel.Size.Large]: 16
}[size]) }[size])
} }

View File

@ -336,6 +336,7 @@ StatusSectionLayout {
// Owner and TMaster properties // Owner and TMaster properties
isOwnerTokenDeployed: tokensModelChangesTracker.isOwnerTokenDeployed isOwnerTokenDeployed: tokensModelChangesTracker.isOwnerTokenDeployed
isTMasterTokenDeployed: tokensModelChangesTracker.isTMasterTokenDeployed isTMasterTokenDeployed: tokensModelChangesTracker.isTMasterTokenDeployed
anyPrivilegedTokenFailed: tokensModelChangesTracker.isOwnerTokenFailed || tokensModelChangesTracker.isTMasterTokenFailed
// Models // Models
tokensModel: root.community.communityTokens tokensModel: root.community.communityTokens
@ -613,21 +614,23 @@ StatusSectionLayout {
// Owner and TMaster token deployment states // Owner and TMaster token deployment states
property bool isOwnerTokenDeployed: false property bool isOwnerTokenDeployed: false
property bool isTMasterTokenDeployed: false property bool isTMasterTokenDeployed: false
property bool isOwnerTokenFailed: false
property bool isTMasterTokenFailed: false
// It will monitorize if Owner and/or TMaster token items are included in the `model` despite the deployment state // It will monitorize if Owner and/or TMaster token items are included in the `model` despite the deployment state
property bool ownerOrTMasterTokenItemsExist: false property bool ownerOrTMasterTokenItemsExist: false
function checkIfPrivilegedTokenItemsExist() { function checkIfPrivilegedTokenItemsExist() {
return SQUtils.ModelUtils.contains(model, "name", PermissionsHelpers.ownerTokenNameTag + root.communityName) || return StatusQUtils.ModelUtils.contains(model, "name", PermissionsHelpers.ownerTokenNameTag + root.communityName) ||
SQUtils.ModelUtils.contains(model, "name", PermissionsHelpers.tMasterTokenNameTag + root.communityName) StatusQUtils.ModelUtils.contains(model, "name", PermissionsHelpers.tMasterTokenNameTag + root.communityName)
} }
function reviewTokenDeployState(tagType, isOwner) { function reviewTokenDeployState(tagType, isOwner, deployState) {
const index = SQUtils.ModelUtils.indexOf(model, "name", tagType + root.communityName) const index = StatusQUtils.ModelUtils.indexOf(model, "name", tagType + root.communityName)
if(index === -1) if(index === -1)
return false return false
const token = SQUtils.ModelUtils.get(model, index) const token = StatusQUtils.ModelUtils.get(model, index)
// Some assertions: // Some assertions:
if(!token.isPrivilegedToken) if(!token.isPrivilegedToken)
@ -637,11 +640,7 @@ StatusSectionLayout {
return false return false
// Deploy state check: // Deploy state check:
if(token.deployState !== Constants.ContractTransactionStatus.Completed) return token.deployState !== deployState
return false
// Token deployed!!
return true
} }
model: root.community.communityTokens model: root.community.communityTokens
@ -653,11 +652,15 @@ StatusSectionLayout {
return return
// It monitors the deployment: // It monitors the deployment:
if(!isOwnerTokenDeployed) if(!isOwnerTokenDeployed) {
isOwnerTokenDeployed = reviewTokenDeployState(PermissionsHelpers.ownerTokenNameTag, true) isOwnerTokenDeployed = reviewTokenDeployState(PermissionsHelpers.ownerTokenNameTag, true, Constants.ContractTransactionStatus.Completed)
isOwnerTokenFailed = reviewTokenDeployState(PermissionsHelpers.ownerTokenNameTag, true, Constants.ContractTransactionStatus.Failed)
}
if(!isTMasterTokenDeployed) if(!isTMasterTokenDeployed) {
isTMasterTokenDeployed = reviewTokenDeployState(PermissionsHelpers.tMasterTokenNameTag, false) isTMasterTokenDeployed = reviewTokenDeployState(PermissionsHelpers.tMasterTokenNameTag, false, Constants.ContractTransactionStatus.Completed)
isTMasterTokenFailed = reviewTokenDeployState(PermissionsHelpers.tMasterTokenNameTag, false, Constants.ContractTransactionStatus.Failed)
}
// Not necessary to track more changes since privileged tokens have been correctly deployed. // Not necessary to track more changes since privileged tokens have been correctly deployed.
if(isOwnerTokenDeployed && isTMasterTokenDeployed) if(isOwnerTokenDeployed && isTMasterTokenDeployed)

View File

@ -1,9 +1,11 @@
import QtQuick 2.0 import QtQuick 2.0
import QtQuick.Layouts 1.14 import QtQuick.Layouts 1.14
import StatusQ.Controls 0.1
import StatusQ.Core 0.1 import StatusQ.Core 0.1
import StatusQ.Components 0.1 import StatusQ.Components 0.1
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
import StatusQ.Core.Utils 0.1 as StatusQUtils
import SortFilterProxyModel 0.2 import SortFilterProxyModel 0.2
import utils 1.0 import utils 1.0
@ -24,6 +26,7 @@ StatusScrollView {
property int viewWidth: 560 // by design property int viewWidth: 560 // by design
property var model property var model
property string communityName property string communityName
property bool anyPrivilegedTokenFailed: false
readonly property int count: assetsModel.count + collectiblesModel.count readonly property int count: assetsModel.count + collectiblesModel.count
signal itemClicked(string tokenKey, signal itemClicked(string tokenKey,
@ -32,7 +35,11 @@ StatusScrollView {
string accountName, string accountName,
string accountAddress) string accountAddress)
signal mintOwnerTokenClicked signal mintOwnerTokenClicked()
signal retryOwnerTokenClicked(string tokenKey,
int chainId,
string accountName,
string accountAddress)
padding: 0 padding: 0
@ -256,6 +263,27 @@ StatusScrollView {
visible: collectiblesGrid.count === 0 visible: collectiblesGrid.count === 0
text: qsTr("You currently have no minted collectibles") text: qsTr("You currently have no minted collectibles")
} }
// Retry button, only in case of Owner or TMaster tokens failure
StatusButton {
Layout.preferredWidth: 336
Layout.preferredHeight: 44
Layout.alignment: Qt.AlignLeft
Layout.leftMargin: 24
visible: root.anyPrivilegedTokenFailed
text: qsTr("Retry mint")
onClicked: {
// Get owner token item:
const index = StatusQUtils.ModelUtils.indexOf(root.model, "name", PermissionsHelpers.ownerTokenNameTag + root.communityName)
if(index === -1)
return console.warn("Trying to get Owner Token item but it's not part of the provided model.")
const token = StatusQUtils.ModelUtils.get(root.model, index)
root.retryOwnerTokenClicked(token.contractUniqueKey, token.chainId, token.accountName, token.accountAddress)
}
}
} }
} }
} }