refactor(OwnerToken): Refactored UI roles `isPrivilegedToken` and `isOwner`

Refactored UI expecting backend role: `privilegesLevel`.
Added privileges level possibilities into `Constants`.
Updated storybook accordingly.
This commit is contained in:
Noelia 2023-08-04 18:41:21 +02:00 committed by Michał Iskierko
parent 603d4dd4d8
commit 6b8ef1411b
10 changed files with 61 additions and 59 deletions

View File

@ -12,7 +12,7 @@ import SortFilterProxyModel 0.2
import Storybook 1.0
import Models 1.0
import utils 1.0
SplitView {
orientation: Qt.Vertical
@ -43,7 +43,7 @@ SplitView {
Rectangle {
SplitView.fillWidth: true
SplitView.fillHeight: true
color: Theme.palette.statusAppLayout.rightPanelBackgroundColor
color: Theme.palette.statusAppLayout.rightPanelBackgroundColor
MintTokensSettingsPanel {
id: panel
@ -57,10 +57,17 @@ SplitView {
sourceModel: mintedTokensModel
filters: ValueFilter {
roleName: "isPrivilegedToken"
value: true
}
filters: [
ExpressionFilter {
readonly property int ownerLevel: Constants.TokenPrivilegesLevel.Owner
readonly property int tMasterLevel: Constants.TokenPrivilegesLevel.TMaster
expression: {
return ((model.privilegesLevel === ownerLevel) ||
(model.privilegesLevel === tMasterLevel))
}
}
]
}
anchors.fill: parent

View File

@ -1,5 +1,7 @@
import QtQuick 2.15
import utils 1.0
ListModel {
id: root
@ -8,8 +10,7 @@ ListModel {
readonly property var data: [
{
isPrivilegedToken: true,
isOwner: true,
privilegesLevel: Constants.TokenPrivilegesLevel.Owner,
contractUniqueKey: "0x15a23414a3",
tokenType: 2,
name: "Owner-Doodles",
@ -29,8 +30,7 @@ ListModel {
tokenOwnersModel: root.emptyModel
},
{
isPrivilegedToken: true,
isOwner: false,
privilegesLevel: Constants.TokenPrivilegesLevel.TMaster,
contractUniqueKey: "0x23124443",
tokenType: 2,
name: "TMaster-Doodles",
@ -50,8 +50,7 @@ ListModel {
tokenOwnersModel: root.tokenOwnersModel
},
{
isPrivilegedToken: false,
isOwner: false,
privilegesLevel: Constants.TokenPrivilegesLevel.Community,
contractUniqueKey: "0x1726362343",
tokenType: 2,
name: "SuperRare artwork",
@ -71,8 +70,7 @@ ListModel {
tokenOwnersModel: root.emptyModel
},
{
isPrivilegedToken: false,
isOwner: false,
privilegesLevel: Constants.TokenPrivilegesLevel.Community,
contractUniqueKey: "0x847843",
tokenType: 2,
name: "Kitty artwork",
@ -92,8 +90,7 @@ ListModel {
tokenOwnersModel: root.emptyModel
},
{
isPrivilegedToken: false,
isOwner: false,
privilegesLevel: Constants.TokenPrivilegesLevel.Community,
contractUniqueKey: "0x1234525",
tokenType: 2,
name: "More artwork",
@ -113,8 +110,7 @@ ListModel {
tokenOwnersModel: root.emptyModel
},
{
isPrivilegedToken: false,
isOwner: false,
privilegesLevel: Constants.TokenPrivilegesLevel.Community,
contractUniqueKey: "0x38576852",
tokenType: 2,
name: "Crypto Punks artwork",
@ -134,8 +130,7 @@ ListModel {
tokenOwnersModel: root.tokenOwnersModel
},
{
isPrivilegedToken: false,
isOwner: false,
privilegesLevel: Constants.TokenPrivilegesLevel.Community,
contractUniqueKey: "0x38745623865",
tokenType: 1,
name: "Unisocks",
@ -154,8 +149,7 @@ ListModel {
tokenOwnersModel: root.emptyModel
},
{
isPrivilegedToken: false,
isOwner: false,
privilegesLevel: Constants.TokenPrivilegesLevel.Community,
contractUniqueKey: "0x872364871623",
tokenType: 1,
name: "Dai",

View File

@ -9,11 +9,10 @@ import utils 1.0
*/
QtObject {
property int type: Constants.TokenType.ERC20
// Special token (Owner and TMaster tokens):
property bool isPrivilegedToken: false
property bool isOwner: false
property color color
property int privilegesLevel: Constants.TokenPrivilegesLevel.Community
readonly property bool isPrivilegedToken: (privilegesLevel === Constants.TokenPrivilegesLevel.Owner) ||
(privilegesLevel === Constants.TokenPrivilegesLevel.TMaster)
property color color // Owner and TMaster icon color
// Unique identifier:
property string key

View File

@ -470,9 +470,9 @@ StackView {
property alias airdropKey: view.airdropKey
// Owner and TMaster related props
readonly property bool isPrivilegedTokenItem: token.isPrivilegedToken
readonly property bool isOwnerTokenItem: token.isPrivilegedToken && token.isOwner
readonly property bool isTMasterTokenItem: token.isPrivilegedToken && !token.isOwner
readonly property bool isPrivilegedTokenItem: isOwnerTokenItem || isTMasterTokenItem
readonly property bool isOwnerTokenItem: token.privilegesLevel === Constants.TokenPrivilegesLevel.Owner
readonly property bool isTMasterTokenItem: token.privilegesLevel === Constants.TokenPrivilegesLevel.TMaster
title: view.name
subtitle: view.symbol
@ -771,8 +771,7 @@ StackView {
tokenOwnersModel: model.tokenOwnersModel
airdropKey: model.symbol // TO BE REMOVED: When airdrop backend is ready to use token key instead of symbol
token.isPrivilegedToken: model.isPrivilegedToken
token.isOwner: model.isOwner
token.privilegesLevel: model.privilegesLevel
token.color: root.communityColor
token.accountName: model.accountName
token.artworkSource: model.image

View File

@ -84,7 +84,7 @@ Control {
size: PrivilegedTokenArtworkPanel.Size.Large
artwork: token.artworkSource
color: token.color
isOwner: token.isOwner
isOwner: token.privilegesLevel === Constants.TokenPrivilegesLevel.Owner
}
Flow {

View File

@ -609,8 +609,8 @@ StatusSectionLayout {
property bool ownerOrTMasterTokenItemsExist: false
function checkIfPrivilegedTokenItemsExist() {
return StatusQUtils.ModelUtils.contains(model, "name", PermissionsHelpers.ownerTokenNameTag + root.communityName) ||
StatusQUtils.ModelUtils.contains(model, "name", PermissionsHelpers.tMasterTokenNameTag + root.communityName)
return StatusQUtils.ModelUtils.contains(model, "privilegesLevel", Constants.TokenPrivilegesLevel.Owner) ||
StatusQUtils.ModelUtils.contains(model, "privilegesLevel", Constants.TokenPrivilegesLevel.TMaster)
}
function reviewTokenDeployState(isOwner, deployState) {
@ -626,9 +626,6 @@ StatusSectionLayout {
if(!isOwner && token.privilegesLevel !== Constants.TokenPrivilegesLevel.TMaster)
return false
if(token.isOwner !== isOwner)
return false
// Deploy state check:
return token.deployState === deployState
}
@ -643,13 +640,13 @@ StatusSectionLayout {
// It monitors the deployment:
if(!isOwnerTokenDeployed) {
isOwnerTokenDeployed = reviewTokenDeployState(PermissionsHelpers.ownerTokenNameTag, true, Constants.ContractTransactionStatus.Completed)
isOwnerTokenFailed = reviewTokenDeployState(PermissionsHelpers.ownerTokenNameTag, true, Constants.ContractTransactionStatus.Failed)
isOwnerTokenDeployed = reviewTokenDeployState(true, Constants.ContractTransactionStatus.Completed)
isOwnerTokenFailed = reviewTokenDeployState(true, Constants.ContractTransactionStatus.Failed)
}
if(!isTMasterTokenDeployed) {
isTMasterTokenDeployed = reviewTokenDeployState(PermissionsHelpers.tMasterTokenNameTag, false, Constants.ContractTransactionStatus.Completed)
isTMasterTokenFailed = reviewTokenDeployState(PermissionsHelpers.tMasterTokenNameTag, false, Constants.ContractTransactionStatus.Failed)
isTMasterTokenDeployed = reviewTokenDeployState(false, Constants.ContractTransactionStatus.Completed)
isTMasterTokenFailed = reviewTokenDeployState(false, Constants.ContractTransactionStatus.Failed)
}
// Not necessary to track more changes since privileged tokens have been correctly deployed.

View File

@ -42,12 +42,12 @@ StatusScrollView {
// Privileged tokens:
readonly property TokenObject ownerToken: TokenObject {
name: PermissionsHelpers.ownerTokenNameTag + root.communityName
type: Constants.TokenType.ERC721
isPrivilegedToken: true
isOwner: true
privilegesLevel: Constants.TokenPrivilegesLevel.Owner
artworkSource: root.communityLogo
color: root.communityColor
symbol: PermissionsHelpers.communityNameToSymbol(isOwner, root.communityName)
symbol: PermissionsHelpers.communityNameToSymbol(true, root.communityName)
transferable: true
remotelyDestruct: false
supply: 1
@ -55,11 +55,12 @@ StatusScrollView {
description: qsTr("This is the %1 Owner token. The hodler of this collectible has ultimate control over %1 Community token administration.").arg(root.communityName)
}
readonly property TokenObject tMasterToken: TokenObject {
name: PermissionsHelpers.tMasterTokenNameTag + root.communityName
type: Constants.TokenType.ERC721
isPrivilegedToken: true
privilegesLevel: Constants.TokenPrivilegesLevel.TMaster
artworkSource: root.communityLogo
color: root.communityColor
symbol: PermissionsHelpers.communityNameToSymbol(isOwner, root.communityName)
symbol: PermissionsHelpers.communityNameToSymbol(false, root.communityName)
remotelyDestruct: true
description: qsTr("This is the %1 TokenMaster token. The hodler of this collectible has full admin rights for the %1 Community in Status and can mint and airdrop %1 Community tokens.").arg(root.communityName)
}
@ -98,7 +99,7 @@ StatusScrollView {
font.pixelSize: d.titleSize
font.bold: true
text: PermissionsHelpers.ownerTokenNameTag + root.communityName
text: ownerToken.name
}
TokenInfoPanel {
@ -124,7 +125,7 @@ StatusScrollView {
font.pixelSize: d.titleSize
font.bold: true
text: PermissionsHelpers.tMasterTokenNameTag + root.communityName
text: tMasterToken.name
}
TokenInfoPanel {

View File

@ -58,14 +58,14 @@ StatusScrollView {
return ""
}
function getRemainingInfo(isOwnerToken, isPrivilegedToken,
function getRemainingInfo(isOwnerToken, isTMasterToken,
remainingSupply, supply, isInfiniteSupply) {
// Owner token use case:
if(isOwnerToken)
return qsTr("1 of 1 (you hodl)")
// TMaster token use case:
if(isPrivilegedToken)
if(isTMasterToken)
return "∞"
// Rest of collectible cases:
@ -233,8 +233,8 @@ StatusScrollView {
width: collectiblesGrid.cellWidth
title: model.name ? model.name : "..."
subTitle: deployState === Constants.ContractTransactionStatus.Completed ?
d.getRemainingInfo(model.isOwner,
model.isPrivilegedToken,
d.getRemainingInfo(model.privilegesLevel === Constants.TokenPrivilegesLevel.Owner,
model.privilegesLevel === Constants.TokenPrivilegesLevel.TMaster,
model.remainingSupply,
model.supply,
model.infiniteSupply) :
@ -245,8 +245,7 @@ StatusScrollView {
backgroundColor: "transparent"
isLoading: false
navigationIconVisible: false
isPrivilegedToken: model.isPrivilegedToken
isOwner: model.isOwner
privilegesLevel: model.privilegesLevel
ornamentColor: model.color
onClicked: root.itemClicked(model.contractUniqueKey,

View File

@ -25,8 +25,9 @@ Control {
property bool navigationIconVisible: false
// Special Owner and TMaster token properties
property bool isPrivilegedToken: false // Owner or TMaster tokens
property bool isOwner: false // Owner token
property int privilegesLevel: Constants.TokenPrivilegesLevel.Community
readonly property bool isPrivilegedToken: (privilegesLevel === Constants.TokenPrivilegesLevel.Owner) ||
(privilegesLevel === Constants.TokenPrivilegesLevel.TMaster)
property color ornamentColor // Relevant color for these special tokens (community color)
signal clicked
@ -78,7 +79,7 @@ Control {
size: PrivilegedTokenArtworkPanel.Size.Medium
artwork: root.fallbackImageUrl
color: root.ornamentColor
isOwner: root.isOwner
isOwner: root.privilegesLevel === Constants.TokenPrivilegesLevel.Owner
Loader {
anchors.fill: parent

View File

@ -1019,7 +1019,6 @@ QtObject {
Dismissed = 4
}
enum TokenType {
Unknown = 0,
ERC20 = 1, // Asset
@ -1027,6 +1026,12 @@ QtObject {
ENS = 3
}
enum TokenPrivilegesLevel {
Owner = 0,
TMaster = 1,
Community = 2
}
// Mirrors src/backend/activity.nim ActivityStatus
enum TransactionStatus {
Failed,