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

View File

@ -24,6 +24,7 @@ StackView {
// General properties:
property int viewWidth: 560 // by design
property string previousPageName: depth > 1 ? qsTr("Back") : ""
required property string communityName
required property string communityLogo
required property color communityColor
@ -39,6 +40,7 @@ StackView {
readonly property bool arePrivilegedTokensDeployed: root.isOwnerTokenDeployed && root.isTMasterTokenDeployed
property bool isOwnerTokenDeployed: 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
property bool ownerOrTMasterTokenItemsExist: false
@ -97,21 +99,21 @@ StackView {
return
}
if(root.arePrivilegedTokensInProgress || root.arePrivilegedTokensFailed) {
// If Owner and TMaster tokens deployment action has been started at least ones, but still without success
root.push(mintedTokensViewComponent, StackView.Immediate)
return
}
if(root.ownerOrTMasterTokenItemsExist) {
// Regular minting flow, selecting the specific tab
if(root.arePrivilegedTokensDeployed) {
// Regular minting flow for Owner and TMaster owner, selecting the specific tab
const properties = { isAssetView }
root.push(newTokenViewComponent, properties, StackView.Immediate)
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) {
// Owner and TMaster tokens to be deployed.
// Owner and TMaster tokens to be deployed. Never tried.
root.push(ownerTokenViewComponent, StackView.Immediate)
return
}
@ -120,7 +122,23 @@ StackView {
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
@ -178,9 +196,11 @@ StackView {
isOwner: root.isOwner
isAdmin: root.isAdmin
communityName: root.communityName
anyPrivilegedTokenFailed: root.anyPrivilegedTokenFailed
onItemClicked: root.push(tokenViewComponent, { tokenKey }, 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())
}
// 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")
visible: (tokenViewPage.isPrivilegedTokenItem && root.isOwner && tokenViewPage.deploymentFailed) ||
@ -517,7 +525,7 @@ StackView {
onClicked: {
if(tokenViewPage.isPrivilegedTokenItem) {
retryPrivilegedToken()
d.retryPrivilegedToken(view.token.key, view.token.chainId, view.token.accountName, view.token.accountAddress)
} else {
retryAssetOrCollectible()
}

View File

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

View File

@ -336,6 +336,7 @@ StatusSectionLayout {
// Owner and TMaster properties
isOwnerTokenDeployed: tokensModelChangesTracker.isOwnerTokenDeployed
isTMasterTokenDeployed: tokensModelChangesTracker.isTMasterTokenDeployed
anyPrivilegedTokenFailed: tokensModelChangesTracker.isOwnerTokenFailed || tokensModelChangesTracker.isTMasterTokenFailed
// Models
tokensModel: root.community.communityTokens
@ -613,21 +614,23 @@ StatusSectionLayout {
// Owner and TMaster token deployment states
property bool isOwnerTokenDeployed: 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
property bool ownerOrTMasterTokenItemsExist: false
function checkIfPrivilegedTokenItemsExist() {
return SQUtils.ModelUtils.contains(model, "name", PermissionsHelpers.ownerTokenNameTag + root.communityName) ||
SQUtils.ModelUtils.contains(model, "name", PermissionsHelpers.tMasterTokenNameTag + root.communityName)
return StatusQUtils.ModelUtils.contains(model, "name", PermissionsHelpers.ownerTokenNameTag + root.communityName) ||
StatusQUtils.ModelUtils.contains(model, "name", PermissionsHelpers.tMasterTokenNameTag + root.communityName)
}
function reviewTokenDeployState(tagType, isOwner) {
const index = SQUtils.ModelUtils.indexOf(model, "name", tagType + root.communityName)
function reviewTokenDeployState(tagType, isOwner, deployState) {
const index = StatusQUtils.ModelUtils.indexOf(model, "name", tagType + root.communityName)
if(index === -1)
return false
const token = SQUtils.ModelUtils.get(model, index)
const token = StatusQUtils.ModelUtils.get(model, index)
// Some assertions:
if(!token.isPrivilegedToken)
@ -637,11 +640,7 @@ StatusSectionLayout {
return false
// Deploy state check:
if(token.deployState !== Constants.ContractTransactionStatus.Completed)
return false
// Token deployed!!
return true
return token.deployState !== deployState
}
model: root.community.communityTokens
@ -653,11 +652,15 @@ StatusSectionLayout {
return
// It monitors the deployment:
if(!isOwnerTokenDeployed)
isOwnerTokenDeployed = reviewTokenDeployState(PermissionsHelpers.ownerTokenNameTag, true)
if(!isOwnerTokenDeployed) {
isOwnerTokenDeployed = reviewTokenDeployState(PermissionsHelpers.ownerTokenNameTag, true, Constants.ContractTransactionStatus.Completed)
isOwnerTokenFailed = reviewTokenDeployState(PermissionsHelpers.ownerTokenNameTag, true, Constants.ContractTransactionStatus.Failed)
}
if(!isTMasterTokenDeployed)
isTMasterTokenDeployed = reviewTokenDeployState(PermissionsHelpers.tMasterTokenNameTag, false)
if(!isTMasterTokenDeployed) {
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.
if(isOwnerTokenDeployed && isTMasterTokenDeployed)

View File

@ -1,9 +1,11 @@
import QtQuick 2.0
import QtQuick.Layouts 1.14
import StatusQ.Controls 0.1
import StatusQ.Core 0.1
import StatusQ.Components 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Core.Utils 0.1 as StatusQUtils
import SortFilterProxyModel 0.2
import utils 1.0
@ -24,6 +26,7 @@ StatusScrollView {
property int viewWidth: 560 // by design
property var model
property string communityName
property bool anyPrivilegedTokenFailed: false
readonly property int count: assetsModel.count + collectiblesModel.count
signal itemClicked(string tokenKey,
@ -32,7 +35,11 @@ StatusScrollView {
string accountName,
string accountAddress)
signal mintOwnerTokenClicked
signal mintOwnerTokenClicked()
signal retryOwnerTokenClicked(string tokenKey,
int chainId,
string accountName,
string accountAddress)
padding: 0
@ -256,6 +263,27 @@ StatusScrollView {
visible: collectiblesGrid.count === 0
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)
}
}
}
}
}