Skip to content

Commit

Permalink
feat(@desktop/wallet): Adding feature flag for Simple Send until it i…
Browse files Browse the repository at this point in the history
…s ready for release

fixes #16710
  • Loading branch information
Khushboo-dev-cpp committed Dec 3, 2024
1 parent bfd8434 commit c52e770
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 7 deletions.
9 changes: 9 additions & 0 deletions src/app/global/feature_flags.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const DEFAULT_FLAG_DAPPS_ENABLED = true
const DEFAULT_FLAG_SWAP_ENABLED = true
const DEFAULT_FLAG_CONNECTOR_ENABLED* = true
const DEFAULT_FLAG_SEND_VIA_PERSONAL_CHAT_ENABLED = true
const DEFAULT_FLAG_SIMPLE_SEND_ENABLED = false

proc boolToEnv*(defaultValue: bool): string =
return if defaultValue: "1" else: "0"
Expand All @@ -15,13 +16,15 @@ QtObject:
swapEnabled: bool
connectorEnabled: bool
sendViaPersonalChatEnabled: bool
simpleSendEnabled: bool

proc setup(self: FeatureFlags) =
self.QObject.setup()
self.dappsEnabled = getEnv("FLAG_DAPPS_ENABLED", boolToEnv(DEFAULT_FLAG_DAPPS_ENABLED)) != "0"
self.swapEnabled = getEnv("FLAG_SWAP_ENABLED", boolToEnv(DEFAULT_FLAG_SWAP_ENABLED)) != "0"
self.connectorEnabled = getEnv("FLAG_CONNECTOR_ENABLED", boolToEnv(DEFAULT_FLAG_CONNECTOR_ENABLED)) != "0"
self.sendViaPersonalChatEnabled = getEnv("FLAG_SEND_VIA_PERSONAL_CHAT_ENABLED", boolToEnv(DEFAULT_FLAG_SEND_VIA_PERSONAL_CHAT_ENABLED)) != "0"
self.simpleSendEnabled = getEnv("FLAG_SIMPLE_SEND_ENABLED", boolToEnv(DEFAULT_FLAG_SIMPLE_SEND_ENABLED)) != "0"

proc delete*(self: FeatureFlags) =
self.QObject.delete()
Expand Down Expand Up @@ -53,3 +56,9 @@ QtObject:

QtProperty[bool] sendViaPersonalChatEnabled:
read = getSendViaPersonalChatEnabled

proc getSimpleSendEnabled*(self: FeatureFlags): bool {.slot.} =
return self.simpleSendEnabled

QtProperty[bool] simpleSendEnabled:
read = getSimpleSendEnabled
52 changes: 52 additions & 0 deletions storybook/pages/SimpleSendModalPage.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15

import Storybook 1.0

import AppLayouts.Wallet.popups.simpleSend 1.0

SplitView {
id: root

orientation: Qt.Horizontal

function launchPopup() {
simpleSend.createObject(root)
}

PopupBackground {
id: popupBg

SplitView.fillWidth: true
SplitView.fillHeight: true

Button {
id: reopenButton
anchors.centerIn: parent
text: "Reopen"
enabled: !simpleSend.visible

onClicked: launchPopup()
}

Component.onCompleted: launchPopup()
}

Component {
id: simpleSend
SimpleSendModal {
visible: true
modal: false
closePolicy: Popup.NoAutoClose
}
}

LogsAndControlsPanel {
SplitView.minimumHeight: 100
SplitView.preferredHeight: 100

}
}

// category: Popups
17 changes: 17 additions & 0 deletions ui/app/AppLayouts/Wallet/popups/simpleSend/SimpleSendModal.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import QtQuick 2.15

import StatusQ.Core.Theme 0.1
import StatusQ.Popups.Dialog 0.1

StatusDialog {
id: popup

title: qsTr("Send")

padding: 0
background: StatusDialogBackground {
implicitHeight: 846
implicitWidth: 556
color: Theme.palette.baseColor3
}
}
1 change: 1 addition & 0 deletions ui/app/AppLayouts/Wallet/popups/simpleSend/qmldir
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SimpleSendModal 1.0 SimpleSendModal.qml
1 change: 1 addition & 0 deletions ui/app/AppLayouts/stores/FeatureFlagsStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ QtObject {
property bool dappsEnabled
property bool swapEnabled
property bool sendViaPersonalChatEnabled
property bool simpleSendEnabled
}
3 changes: 3 additions & 0 deletions ui/app/mainui/AppMain.qml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ Item {
dappsEnabled: featureFlags ? featureFlags.dappsEnabled : false
swapEnabled: featureFlags ? featureFlags.swapEnabled : false
sendViaPersonalChatEnabled: featureFlags ? featureFlags.sendViaPersonalChatEnabled : false
simpleSendEnabled: featureFlags ? featureFlags.simpleSendEnabled : false
}

required property bool isCentralizedMetricsEnabled
Expand Down Expand Up @@ -656,6 +657,8 @@ Item {
stickersMarketAddress: appMain.rootChatStore.stickersStore.getStickersMarketAddress()
stickersNetworkId: appMain.rootChatStore.appNetworkId

simpleSendEnabled: appMain.featureFlagsStore.simpleSendEnabled

Component.onCompleted: {
// It's requested from many nested places, so as a workaround we use
// Global to shorten the path via global signal.
Expand Down
20 changes: 13 additions & 7 deletions ui/app/mainui/SendModalHandler.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import StatusQ.Core 0.1
import StatusQ.Core.Utils 0.1 as SQUtils

import AppLayouts.Wallet.stores 1.0 as WalletStores
import AppLayouts.Wallet.popups.simpleSend 1.0

import shared.popups.send 1.0
import shared.stores.send 1.0
Expand All @@ -28,12 +29,14 @@ QtObject {
required property string stickersMarketAddress
required property string stickersNetworkId

// Feature flag for single network send until its feature complete
required property bool simpleSendEnabled

function openSend(params = {}) {
if (!!root._sendModalInstance) {
return
}
_sendModalInstance = sendModalComponent.createObject(popupParent, params)
_sendModalInstance.open()
// TODO remove once simple send is feature complete
let sendModalCmp = root.simpleSendEnabled ? simpleSendModalComponent: sendModalComponent
let sendModalInst = sendModalCmp.createObject(popupParent, params)
sendModalInst.open()
}

function connectUsername(ensName) {
Expand Down Expand Up @@ -150,6 +153,9 @@ QtObject {
}
}

// internally used to handle the instance thats launched
property var _sendModalInstance
readonly property Component simpleSendModalComponent: Component {
SimpleSendModal {
onClosed: destroy()
}
}
}

0 comments on commit c52e770

Please sign in to comment.