Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHERRY-PICK]: Wallet: swap/bridge buttons visibility adjusted #16039

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions storybook/pages/AssetsViewPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ SplitView {
sendEnabled: sendEnabledCheckBox.checked
swapEnabled: swapEnabledCheckBox.checked
swapVisible: swapVisibleCheckBox.checked
communitySwapVisible: communitySwapVisibleCheckBox.checked

balanceError: balanceErrorCheckBox.checked
? "Balance error!" : ""
Expand Down Expand Up @@ -243,6 +244,11 @@ SplitView {

text: "swap visible"
}
CheckBox {
id: communitySwapVisibleCheckBox

text: "community swap visible"
}
CheckBox {
id: balanceErrorCheckBox

Expand Down
16 changes: 12 additions & 4 deletions ui/app/AppLayouts/Wallet/panels/WalletFooter.qml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ Rectangle {
readonly property bool isCollectibleViewed: !!walletStore.currentViewedHoldingID &&
(walletStore.currentViewedHoldingType === Constants.TokenType.ERC721 ||
walletStore.currentViewedHoldingType === Constants.TokenType.ERC1155)

readonly property bool isCommunityAsset: !d.isCollectibleViewed && walletStore.currentViewedHoldingCommunityId !== ""

readonly property bool isCollectibleSoulbound: isCollectibleViewed && !!walletStore.currentViewedCollectible && walletStore.currentViewedCollectible.soulbound

readonly property var collectibleOwnership: isCollectibleViewed && walletStore.currentViewedCollectible ?
Expand All @@ -67,11 +70,16 @@ Rectangle {
&& !root.isCommunityOwnershipTransfer
&& walletStore.overview.canSend
&& !root.walletStore.showAllAccounts
&& !d.hideCollectibleTransferActions
&& !d.isCollectibleViewed
&& !d.isCommunityAsset

readonly property bool buyActionAvailable: !isCollectibleViewed

readonly property bool swapActionAvailable: Global.featureFlags.swapEnabled && !walletStore.overview.isWatchOnlyAccount && walletStore.overview.canSend && !d.hideCollectibleTransferActions
readonly property bool swapActionAvailable: Global.featureFlags.swapEnabled
&& !walletStore.overview.isWatchOnlyAccount
&& walletStore.overview.canSend
&& !d.isCollectibleViewed
&& !d.isCommunityAsset

function getFirstUserOwnedAddress(ownershipModel, accountsModel) {
if (!ownershipModel) return ""
Expand Down Expand Up @@ -144,9 +152,9 @@ Rectangle {
StatusFlatButton {
id: swap

interactive: !d.isCollectibleViewed && networkConnectionStore.sendBuyBridgeEnabled
interactive: networkConnectionStore.sendBuyBridgeEnabled
visible: d.swapActionAvailable
tooltip.text: d.isCollectibleViewed ? qsTr("Collectibles cannot be swapped") : networkConnectionStore.sendBuyBridgeToolTipText
tooltip.text: networkConnectionStore.sendBuyBridgeToolTipText
icon.name: "swap"
text: qsTr("Swap")
onClicked: root.launchSwapModal()
Expand Down
6 changes: 5 additions & 1 deletion ui/app/AppLayouts/Wallet/stores/RootStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -177,26 +177,30 @@ QtObject {
function resetCurrentViewedHolding(type) {
currentViewedHoldingTokensKey = ""
currentViewedHoldingID = ""
currentViewedHoldingCommunityId = ""
currentViewedHoldingType = type
}

function setCurrentViewedHoldingType(type) {
currentViewedHoldingTokensKey = ""
currentViewedHoldingID = ""
currentViewedHoldingCommunityId = ""
currentViewedHoldingType = type
}

function setCurrentViewedHolding(id, tokensKey, type) {
function setCurrentViewedHolding(id, tokensKey, type, communityId) {
currentViewedHoldingTokensKey = tokensKey
currentViewedHoldingID = id
currentViewedHoldingType = type
currentViewedHoldingCommunityId = communityId
}

property string currentViewedHoldingTokensKey: ""
/* TODO: should get rid if this eventually, we shouldnt be using token symbols
everywhere. Adding a new one currentViewedHoldingTokensKey aboce to not impact send/bridge flows */
property string currentViewedHoldingID: ""
property int currentViewedHoldingType
property string currentViewedHoldingCommunityId: ""
readonly property var currentViewedCollectible: collectiblesStore.detailedCollectible

function canProfileProveOwnershipOfProvidedAddresses(addresses) {
Expand Down
4 changes: 2 additions & 2 deletions ui/app/AppLayouts/Wallet/views/CollectiblesView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ColumnLayout {
property bool isUpdating: false // Indicates if the collectibles list is being updated
property bool isError: false // Indicates an error occurred while updating/fetching the collectibles list

signal collectibleClicked(int chainId, string contractAddress, string tokenId, string uid, int tokenType)
signal collectibleClicked(int chainId, string contractAddress, string tokenId, string uid, int tokenType, string communityId)
signal sendRequested(string symbol, int tokenType, string fromAddress)
signal receiveRequested(string symbol)
signal switchToCommunityRequested(string communityId)
Expand Down Expand Up @@ -476,7 +476,7 @@ ColumnLayout {
communityImage: model.communityImage ?? ""
balance: model.balance ?? 1

onClicked: root.collectibleClicked(model.chainId, model.contractAddress, model.tokenId, model.symbol, model.tokenType)
onClicked: root.collectibleClicked(model.chainId, model.contractAddress, model.tokenId, model.symbol, model.tokenType, model.communityId ?? "")
onRightClicked: {
const userOwnedAddress = d.getFirstUserOwnedAddress(model.ownership)
Global.openMenu(tokenContextMenu, this,
Expand Down
6 changes: 4 additions & 2 deletions ui/app/AppLayouts/Wallet/views/RightTabView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ RightTabBaseView {

sendEnabled: root.networkConnectionStore.sendBuyBridgeEnabled &&
!RootStore.overview.isWatchOnlyAccount && RootStore.overview.canSend
communitySendEnabled: RootStore.tokensStore.showCommunityAssetsInSend
swapEnabled: !RootStore.overview.isWatchOnlyAccount
swapVisible: Global.featureFlags.swapEnabled

Expand Down Expand Up @@ -266,7 +267,8 @@ RightTabBaseView {
token.symbol, RootStore.currencyStore.currentCurrency)

assetDetailView.token = token
RootStore.setCurrentViewedHolding(token.symbol, token.key, Constants.TokenType.ERC20)
RootStore.setCurrentViewedHolding(
token.symbol, token.key, Constants.TokenType.ERC20, token.communityId ?? "")
stack.currentIndex = 2
}
}
Expand All @@ -283,7 +285,7 @@ RightTabBaseView {
filterVisible: filterButton.checked
onCollectibleClicked: {
RootStore.collectiblesStore.getDetailedCollectible(chainId, contractAddress, tokenId)
RootStore.setCurrentViewedHolding(uid, uid, tokenType)
RootStore.setCurrentViewedHolding(uid, uid, tokenType, communityId)
d.detailedCollectibleActivityController.resetFilter()
d.detailedCollectibleActivityController.setFilterAddressesJson(JSON.stringify(RootStore.addressFilters.split(":")))
d.detailedCollectibleActivityController.setFilterChainsJson(JSON.stringify([chainId]), false)
Expand Down
9 changes: 7 additions & 2 deletions ui/imports/shared/views/AssetsView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ Control {

// switches configuring right click menu
property bool sendEnabled: true
property bool communitySendEnabled: false
property bool swapEnabled: true
property bool swapVisible: true
property bool communitySwapVisible: false

property string balanceError

Expand Down Expand Up @@ -267,13 +269,16 @@ Control {
readonly property string key: model.key
readonly property string communityKey: model.communityId

readonly property bool isCommunity: !!model.isCommunity

onClosed: destroy()

sendEnabled: root.sendEnabled
&& (!isCommunity || root.communitySendEnabled)
swapEnabled: root.swapEnabled
swapVisible: root.swapVisible
swapVisible: root.swapVisible && (!isCommunity || root.communitySwapVisible)
hideVisible: model.canBeHidden
communityHideVisible: !!model.isCommunity
communityHideVisible: isCommunity

onSendRequested: root.sendRequested(key)
onReceiveRequested: root.receiveRequested(key)
Expand Down