feat(FinaliseOwnershipPopup): Moved to Popups

- Moved finalise ownership and decline ownership popups from `ChatLayout` to `Popups`.
- Removed instance from `ChatLayout`.

Part of #12175
This commit is contained in:
Noelia 2023-10-23 13:32:50 +02:00 committed by Michał Iskierko
parent fa3be8623b
commit f1d4462f69
12 changed files with 215 additions and 121 deletions

View File

@ -44,8 +44,7 @@ StackLayout {
// Community transfer ownership related props/signals:
// TODO: Backend integrations:
property bool isPendingOwnershipRequest: false
signal ownershipDeclined()
property bool isPendingOwnershipRequest: sectionItemModel.isPendingOwnershipRequest
onCurrentIndexChanged: {
Global.closeCreateChatView()
@ -153,9 +152,9 @@ StackLayout {
collectiblesModel: root.rootStore.collectiblesModel
isInvitationPending: root.rootStore.isCommunityRequestPending(chatView.communityId)
finaliseOwnershipTransferPopup: finaliseOwnershipPopup
isPendingOwnershipRequest: root.isPendingOwnershipRequest
onFinaliseOwnershipClicked: Global.openFinaliseOwnershipPopup(communityId)
onCommunityInfoButtonClicked: root.currentIndex = 1
onCommunityManageButtonClicked: root.currentIndex = 1
@ -192,7 +191,6 @@ StackLayout {
walletAccountsModel: WalletStore.RootStore.nonWatchAccounts
sendModalPopup: root.sendModalPopup
finaliseOwnershipTransferPopup: finaliseOwnershipPopup
isPendingOwnershipRequest: root.isPendingOwnershipRequest
chatCommunitySectionModule: root.rootStore.chatCommunitySectionModule
@ -201,6 +199,7 @@ StackLayout {
onCommunitySettingsDisabledChanged: if (communitySettingsDisabled) goTo(Constants.CommunitySettingsSections.Overview)
onBackToCommunityClicked: root.currentIndex = 0
onFinaliseOwnershipClicked: Global.openFinaliseOwnershipPopup(community.id)
Connections {
target: root.rootStore
@ -272,113 +271,6 @@ StackLayout {
}
}
// Components related to transfer community ownership flow:
Component {
id: finaliseOwnershipPopup
FinaliseOwnershipPopup {
id: finalisePopup
readonly property var communityData: root.sectionItemModel
readonly property var ownerToken: ModelUtils.getByKey(communityData.communityTokens,
"privilegesLevel",
Constants.TokenPrivilegesLevel.Owner)
communityName: communityData.name
communityLogo: communityData.image
communityColor: communityData.color
tokenSymbol: ownerToken.symbol
tokenChainName: ownerToken.chainName
accounts: WalletStore.RootStore.nonWatchAccounts
feeText: feeSubscriber.feeText
feeErrorText: feeSubscriber.feeErrorText
isFeeLoading: !feeSubscriber.feesResponse
onRejectClicked: Global.openPopup(declineOwnershipPopup)
onFinaliseOwnershipClicked: signPopup.open()
onVisitCommunityClicked: rootStore.setActiveCommunity(communityData.id)
onOpenControlNodeDocClicked: Global.openLink(link)
DeployFeesSubscriber {
id: feeSubscriber
readonly property TransactionFeesBroker feesBroker: TransactionFeesBroker {
communityTokensStore: root.rootStore.communityTokensStore
}
chainId: finalisePopup.ownerToken.chainId
tokenType: finalisePopup.ownerToken.type
isOwnerDeployment: true
accountAddress: finalisePopup.ownerToken.accountAddress
enabled: finalisePopup.visible || signPopup.visible
Component.onCompleted: feesBroker.registerDeployFeesSubscriber(feeSubscriber)
}
SignTransactionsPopup {
id: signPopup
title: qsTr("Sign transaction - update %1 smart contract").arg(finalisePopup.communityData.name)
totalFeeText: finalisePopup.isFeeLoading ? "" : finalisePopup.feeText
errorText: finalisePopup.feeErrorText
accountName: finalisePopup.ownerToken.accountName
model: QtObject {
readonly property string title: finalisePopup.feeLabel
readonly property string feeText: signPopup.totalFeeText
readonly property bool error: finalisePopup.feeErrorText !== ""
}
onSignTransactionClicked: {
root.rootStore.communityTokensStore.updateSmartContract(finalisePopup.communityData.id, finalisePopup.ownerToken)
close()
}
}
Connections {
target: root
onOwnershipDeclined: finalisePopup.close()
}
}
}
Component {
id: declineOwnershipPopup
FinaliseOwnershipDeclinePopup {
readonly property var communityData: root.sectionItemModel
communityName: communityData.name
onDeclineClicked: {
console.warn("TODO: Backend update notification center and display a toast: Ownership Declined!")
root.ownershipDeclined()
}
}
}
Component {
id: controlNodeOfflineComponent
ControlNodeOfflineCommunityView {
id: controlNodeOfflineView
readonly property var communityData: sectionItemModel
readonly property string communityId: communityData.id
name: communityData.name
communityDesc: communityData.description
color: communityData.color
image: communityData.image
membersCount: communityData.members.count
communityItemsModel: root.rootStore.communityItemsModel
notificationCount: activityCenterStore.unreadNotificationsCount
hasUnseenNotifications: activityCenterStore.hasUnseenNotifications
onNotificationButtonClicked: Global.openActivityCenterPopup()
onAdHocChatButtonClicked: rootStore.openCloseCreateChatView()
}
}
// End of components related to transfer community ownership flow.
Connections {
target: root.rootStore
enabled: mainViewLoader.item

View File

@ -75,8 +75,8 @@ StatusSectionLayout {
}
// Community transfer ownership related props:
required property var finaliseOwnershipTransferPopup
required property bool isPendingOwnershipRequest
signal finaliseOwnershipClicked
signal communityInfoButtonClicked()
signal communityManageButtonClicked()
@ -246,10 +246,10 @@ StatusSectionLayout {
communitiesStore: root.communitiesStore
emojiPopup: root.emojiPopup
hasAddedContacts: root.hasAddedContacts
finaliseOwnershipTransferPopup: root.finaliseOwnershipTransferPopup
isPendingOwnershipRequest: root.isPendingOwnershipRequest
onInfoButtonClicked: root.communityInfoButtonClicked()
onManageButtonClicked: root.communityManageButtonClicked()
onFinaliseOwnershipClicked: root.finaliseOwnershipClicked()
}
}

View File

@ -0,0 +1,14 @@
import QtQuick 2.15
/*!
\qmltype SetSignerFeesSubscriber
\inherits QtObject
\brief Helper object that holds the subscriber properties and the published properties for the fee computation.
*/
SingleFeeSubscriber {
id: root
required property string tokenKey
required property string accountAddress
required property bool enabled
}

View File

@ -12,7 +12,8 @@ QtObject {
Airdrop,
Deploy,
SelfDestruct,
Burn
Burn,
SetSigner
}
property CommunityTokensStore communityTokensStore
@ -97,10 +98,26 @@ QtObject {
onResponseChanged: subscriber.feesResponse = response
}
component SetSignerFeeSubscription: Subscription {
required property SetSignerFeesSubscriber subscriber
readonly property var requestArgs: ({
type: TransactionFeesBroker.FeeType.SetSigner,
tokenKey: subscriber.tokenKey,
accountAddress: subscriber.accountAddress
})
isReady: !!subscriber.tokenKey &&
!!subscriber.accountAddress &&
subscriber.enabled
topic: isReady ? JSON.stringify(requestArgs) : ""
onResponseChanged: subscriber.feesResponse = response
}
readonly property Component airdropFeeSubscriptionComponent: AirdropFeeSubscription {}
readonly property Component deployFeeSubscriptionComponent: DeployFeeSubscription {}
readonly property Component selfDestructFeeSubscriptionComponent: SelfDestructFeeSubscription {}
readonly property Component burnFeeSubscriptionComponent: BurnTokenFeeSubscription {}
readonly property Component setSignerFeeSubscriptionComponent: SetSignerFeeSubscription {}
readonly property SubscriptionBroker feesBroker: SubscriptionBroker {
active: Global.applicationWindow.active
@ -142,6 +159,9 @@ QtObject {
case TransactionFeesBroker.FeeType.Burn:
computeBurnFee(args, topic)
break
case TransactionFeesBroker.FeeType.SetSigner:
computeSetSignerFee(args, topic)
break
default:
console.error("Unknown fee type: " + args.type)
}
@ -168,6 +188,10 @@ QtObject {
console.assert(typeof args.amount === "string")
communityTokensStore.computeBurnFee(args.tokenKey, args.amount, args.accountAddress, topic)
}
function computeSetSignerFee(args, topic) {
communityTokensStore.computeSetSignerFee(args.tokenKey, args.accountAddress, topic)
}
}
function registerAirdropFeesSubscriber(subscriberObj) {
@ -189,4 +213,9 @@ QtObject {
const subscription = d.burnFeeSubscriptionComponent.createObject(subscriberObj, { subscriber: subscriberObj })
d.feesBroker.subscribe(subscription)
}
function registerSetSignerFeesSubscriber(subscriberObj) {
const subscription = d.setSignerFeeSubscriptionComponent.createObject(subscriberObj, { subscriber: subscriberObj })
d.feesBroker.subscribe(subscription)
}
}

View File

@ -3,6 +3,7 @@ AirdropFeesSubscriber 1.0 AirdropFeesSubscriber.qml
BurnTokenFeesSubscriber 1.0 BurnTokenFeesSubscriber.qml
DeployFeesSubscriber 1.0 DeployFeesSubscriber.qml
SelfDestructFeesSubscriber 1.0 SelfDestructFeesSubscriber.qml
SetSignerFeesSubscriber 1.0 SetSignerFeesSubscriber.qml
SingleFeeSubscriber 1.0 SingleFeeSubscriber.qml
TokenObject 1.0 TokenObject.qml
TransactionFeesBroker 1.0 TransactionFeesBroker.qml

View File

@ -57,8 +57,8 @@ StackLayout {
property string pubsubTopicKey
// Community transfer ownership related props:
required property var finaliseOwnershipTransferPopup
required property bool isPendingOwnershipRequest
signal finaliseOwnershipClicked
function navigateBack() {
if (editSettingsPanelLoader.item.dirty)
@ -204,7 +204,7 @@ StackLayout {
}
}
onImportControlNodeClicked: root.importControlNodeClicked()
onFinaliseOwnershipTransferClicked: Global.openPopup(root.finaliseOwnershipTransferPopup)
onFinaliseOwnershipTransferClicked: root.finaliseOwnershipClicked()
//TODO update once the domain changes
onLearnMoreClicked: Global.openLink(Constants.statusHelpLinkPrefix + "status-communities/about-the-control-node-in-status-communities")
}

View File

@ -41,8 +41,8 @@ Item {
property var communityData
// Community transfer ownership related props:
required property var finaliseOwnershipTransferPopup
required property bool isPendingOwnershipRequest
signal finaliseOwnershipClicked
readonly property bool isSectionAdmin:
communityData.memberRole === Constants.memberRole.owner ||
@ -586,7 +586,7 @@ Item {
text: communityData.joined ? qsTr("Finalise community ownership") : qsTr("To join, finalise community ownership")
onClicked: Global.openPopup(root.finaliseOwnershipTransferPopup)
onClicked: root.finaliseOwnershipClicked()
}
}

View File

@ -45,8 +45,8 @@ StatusSectionLayout {
readonly property bool isControlNode: community.isControlNode
// Community transfer ownership related props:
required property var finaliseOwnershipTransferPopup
required property bool isPendingOwnershipRequest
signal finaliseOwnershipClicked
readonly property string filteredSelectedTags: {
let tagsArray = []
@ -194,9 +194,10 @@ StatusSectionLayout {
tokensModel: root.community.communityTokens
accounts: root.walletAccountsModel
finaliseOwnershipTransferPopup: root.finaliseOwnershipTransferPopup
isPendingOwnershipRequest: root.isPendingOwnershipRequest
onFinaliseOwnershipClicked: root.finaliseOwnershipClicked()
onCollectCommunityMetricsMessagesCount: {
rootStore.collectCommunityMetricsMessagesCount(intervals)
}
@ -800,6 +801,28 @@ StatusSectionLayout {
Global.displayToastMessage(title1, url, "", true, type, url)
Global.displayToastMessage(title2, url, "", true, type, url)
}
function onSetSignerStateChanged(communityId, communityName, status, url) {
if (root.community.id !== communityId)
return
if (status === Constants.ContractTransactionStatus.Completed) {
Global.displayToastMessage(qsTr("%1 smart contract amended").arg(communityName),
qsTr("View on etherscan"), "", false,
Constants.ephemeralNotificationType.success, url)
Global.displayToastMessage(qsTr("Your device is now the control node for %1. You now have full Community admin rights.").arg(communityName),
qsTr("%1 Community admin"), "", false,
Constants.ephemeralNotificationType.success, "" /*TODO internal link*/)
} else if (status === Constants.ContractTransactionStatus.Failed) {
Global.displayToastMessage(qsTr("%1 smart contract update failed").arg(communityName),
qsTr("View on etherscan"), "", false,
Constants.ephemeralNotificationType.normal, url)
} else if (status === Constants.ContractTransactionStatus.InProgress) {
Global.displayToastMessage(qsTr("Updating %1 smart contract").arg(communityName),
qsTr("View on etherscan"), "", true,
Constants.ephemeralNotificationType.normal, url)
}
}
}
Connections {

View File

@ -218,6 +218,7 @@ Item {
id: popups
popupParent: appMain
rootStore: appMain.rootStore
communityTokensStore: appMain.communityTokensStore
communitiesStore: appMain.communitiesStore
devicesStore: appMain.rootStore.profileSectionStore.devicesStore
isDevBuild: !production

View File

@ -9,10 +9,12 @@ import StatusQ.Controls 0.1
import StatusQ.Components 0.1
import StatusQ.Popups 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Core.Utils 0.1 as SQUtils
import AppLayouts.Chat.popups 1.0
import AppLayouts.Profile.popups 1.0
import AppLayouts.Communities.popups 1.0
import AppLayouts.Communities.helpers 1.0
import AppLayouts.Wallet.stores 1.0 as WalletStore
import AppLayouts.Chat.stores 1.0 as ChatStore
@ -27,12 +29,14 @@ QtObject {
required property var popupParent
required property var rootStore
required property var communityTokensStore
property var communitiesStore
property var devicesStore
property bool isDevBuild
signal openExternalLink(string link)
signal saveDomainToUnfurledWhitelist(string domain)
signal ownershipDeclined
property var activePopupComponents: []
@ -68,6 +72,8 @@ QtObject {
Global.openImportControlNodePopup.connect(openImportControlNodePopup)
Global.openEditSharedAddressesFlow.connect(openEditSharedAddressesPopup)
Global.openTransferOwnershipPopup.connect(openTransferOwnershipPopup)
Global.openFinaliseOwnershipPopup.connect(openFinaliseOwnershipPopup)
Global.openDeclineOwnershipPopup.connect(openDeclineOwnershipPopup)
}
property var currentPopup
@ -288,6 +294,14 @@ QtObject {
openPopup(confirmExternalLinkPopup, {link, domain})
}
function openFinaliseOwnershipPopup(communityId) {
openPopup(finaliseOwnershipPopup, { communityId: communityId })
}
function openDeclineOwnershipPopup(communityName) {
openPopup(declineOwnershipPopup, { communityName: communityName })
}
readonly property list<Component> _components: [
Component {
id: removeContactConfirmationDialog
@ -806,6 +820,92 @@ QtObject {
onOpenExternalLink: root.openExternalLink(link)
onSaveDomainToUnfurledWhitelist: root.saveDomainToUnfurledWhitelist(domain)
}
},
// Components related to transfer community ownership flow:
Component {
id: finaliseOwnershipPopup
FinaliseOwnershipPopup {
id: finalisePopup
property string communityId
readonly property var ownerToken: {
let jsonObj = root.rootStore.mainModuleInst.getOwnerTokenAsJson(finalisePopup.communityId)
return JSON.parse(jsonObj)
}
readonly property var communityData : root.communitiesStore.getCommunityDetailsAsJson(communityId)
communityName: communityData.name
communityLogo: communityData.image
communityColor: communityData.color
tokenSymbol: ownerToken.symbol
tokenChainName: ownerToken.chainName
feeText: feeSubscriber.feeText
feeErrorText: feeSubscriber.feeErrorText
isFeeLoading: !feeSubscriber.feesResponse
accounts: WalletStore.RootStore.nonWatchAccounts
destroyOnClose: true
onRejectClicked: Global.openDeclineOwnershipPopup(communityData.name)
onFinaliseOwnershipClicked: signPopup.open()
onVisitCommunityClicked: rootStore.setActiveCommunity(communityData.id)
onOpenControlNodeDocClicked: Global.openLink(link)
SetSignerFeesSubscriber {
id: feeSubscriber
readonly property TransactionFeesBroker feesBroker: TransactionFeesBroker {
communityTokensStore: root.communityTokensStore
}
tokenKey: finalisePopup.ownerToken.contractUniqueKey
accountAddress: finalisePopup.ownerToken.accountAddress
enabled: finalisePopup.visible || signPopup.visible
Component.onCompleted: feesBroker.registerSetSignerFeesSubscriber(feeSubscriber)
}
SignTransactionsPopup {
id: signPopup
title: qsTr("Sign transaction - update %1 smart contract").arg(finalisePopup.communityName)
totalFeeText: finalisePopup.isFeeLoading ? "" : finalisePopup.feeText
errorText: finalisePopup.feeErrorText
accountName: finalisePopup.ownerToken.accountName
model: QtObject {
readonly property string title: finalisePopup.feeLabel
readonly property string feeText: signPopup.totalFeeText
readonly property bool error: finalisePopup.feeErrorText !== ""
}
onSignTransactionClicked: {
root.communityTokensStore.updateSmartContract(finalisePopup.communityId, finalisePopup.ownerToken.contractUniqueKey)
close()
}
}
Connections {
target: root
onOwnershipDeclined: {
finalisePopup.close()
root.communityTokensStore.ownershipDeclined()
}
}
}
},
Component {
id: declineOwnershipPopup
FinaliseOwnershipDeclinePopup {
destroyOnClose: true
onDeclineClicked: root.ownershipDeclined()
}
}
// End of components related to transfer community ownership flow.
]
}

View File

@ -16,6 +16,7 @@ QtObject {
signal selfDestructFeeUpdated(var ethCurrency, var fiatCurrency, int error, string responseId)
signal airdropFeeUpdated(var airdropFees)
signal burnFeeUpdated(var ethCurrency, var fiatCurrency, int error, string responseId)
signal setSignerFeeUpdated(var ethCurrency, var fiatCurrency, int error, string responseId)
signal deploymentStateChanged(string communityId, int status, string url)
signal ownerTokenDeploymentStateChanged(string communityId, int status, string url)
@ -23,6 +24,7 @@ QtObject {
signal burnStateChanged(string communityId, string tokenName, int status, string url)
signal airdropStateChanged(string communityId, string tokenName, string chainName, int status, string url)
signal ownerTokenDeploymentStarted(string communityId, string url)
signal setSignerStateChanged(string communityId, string communityName, int status, string url)
// Minting tokens:
function deployCollectible(communityId, collectibleItem)
@ -60,8 +62,13 @@ QtObject {
communityTokensModuleInst.removeCommunityToken(communityId, parts[0], parts[1])
}
function updateSmartContract(communityId, collectibleItem) {
function updateSmartContract(tokenKey, accountAddress) {
console.warn("TODO: Backend to update smart contract and finalise community transfer ownership! The token owner is: " + collectibleItem.symbol)
//communityTokensModuleInst.setSigner(tokenKey, accountAddress)
}
function ownershipDeclined() {
console.warn("TODO: Backend update notification center and display a toast: Ownership Declined!")
}
readonly property Connections connections: Connections {
@ -83,6 +90,11 @@ QtObject {
root.burnFeeUpdated(ethCurrency, fiatCurrency, errorCode, responseId)
}
function onSetSignerFeeUpdated(ethCurrency, fiatCurrency, errorCode, responseId) {
console.warn("TODO: Backend")
//root.setSignerFeeUpdated(ethCurrency, fiatCurrency, errorCode, responseId)
}
function onDeploymentStateChanged(communityId, status, url) {
root.deploymentStateChanged(communityId, status, url)
}
@ -106,6 +118,21 @@ QtObject {
function onBurnStateChanged(communityId, tokenName, status, url) {
root.burnStateChanged(communityId, tokenName, status, url)
}
function onOwnerTokenReceived(communityId, communityName, chainId, communityAddress) {
console.warn("TODO: Backend")
// Global.displayToastMessage(qsTr("You received the Owner token for %1. To finalize ownership, make your device the control node.").arg(communityName),
// qsTr("Finalise ownership"),
// "",
// false,
// Constants.ephemeralNotificationType.normal,
// "")
}
function onSetSignerStateChanged(communityId, communityName, status, url) {
console.warn("TODO: Backend")
//root.setSignerStateChanged(communityId, communityName, status, url)
}
}
// Burn:
@ -124,6 +151,11 @@ QtObject {
communityTokensModuleInst.computeDeployFee(communityId, chainId, accountAddress, tokenType, isOwnerDeployment, requestId)
}
function computeSetSignerFee(tokenKey, accountAddress, requestId) {
console.warn("TODO: Backend!")
//communityTokensModuleInst.computeSetSignerFee(tokenKey, accountAddress, requestId)
}
/**
* walletsAndAmounts - array of following structure is expected:
* [

View File

@ -52,6 +52,8 @@ QtObject {
var token,
var accounts,
var sendModalPopup)
signal openFinaliseOwnershipPopup(string communityId)
signal openDeclineOwnershipPopup(string communityName)
signal openLink(string link)
signal openLinkWithConfirmation(string link, string domain)