feat: Add feature flag

This commit is contained in:
Emil Sawicki 2024-11-11 15:14:32 +01:00
parent ccad5cfed9
commit 5b15300f3d
8 changed files with 24 additions and 2 deletions

View File

@ -5,6 +5,7 @@ const DEFAULT_FLAG_DAPPS_ENABLED = false
const DEFAULT_FLAG_SWAP_ENABLED = true
const DEFAULT_FLAG_CONNECTOR_ENABLED* = false
const DEFAULT_FLAG_SEND_VIA_PERSONAL_CHAT_ENABLED = true
const DEFAULT_FLAG_REQUEST_PAYMENT_ENABLED = true
proc boolToEnv*(defaultValue: bool): string =
return if defaultValue: "1" else: "0"
@ -22,6 +23,7 @@ QtObject:
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.requestPaymentEnabled = getEnv("FLAG_REQUEST_PAYMENT_ENABLED", boolToEnv(DEFAULT_FLAG_REQUEST_PAYMENT_ENABLED)) != "0"
proc delete*(self: FeatureFlags) =
self.QObject.delete()
@ -53,3 +55,9 @@ QtObject:
QtProperty[bool] sendViaPersonalChatEnabled:
read = getSendViaPersonalChatEnabled
proc getRequestPaymentEnabled*(self: FeatureFlags): bool {.slot.} =
return self.requestPaymentEnabled
QtProperty[bool] requestPaymentEnabled:
read = getRequestPaymentEnabled

View File

@ -101,6 +101,7 @@ SplitView {
}
requestPaymentStore: d.requestPaymentStore
requestPaymentEnabled: true
onSendMessage: {
logs.logEvent("StatusChatInput::sendMessage", ["MessageWithPk"], [chatInput.getTextWithPublicKeys()])

View File

@ -37,6 +37,7 @@ StackLayout {
required property WalletStore.WalletAssetsStore walletAssetsStore
required property SharedStores.CurrenciesStore currencyStore
property bool areTestNetworksEnabled
property bool requestPaymentEnabled
property var sectionItemModel
@ -168,12 +169,14 @@ StackLayout {
sendModalPopup: root.sendModalPopup
sectionItemModel: root.sectionItemModel
joinedMembersCount: membersModelAdaptor.joinedMembers.ModelCount.count
areTestNetworksEnabled: root.areTestNetworksEnabled
amIMember: sectionItem.amIMember
amISectionAdmin: root.sectionItemModel.memberRole === Constants.memberRole.owner ||
root.sectionItemModel.memberRole === Constants.memberRole.admin ||
root.sectionItemModel.memberRole === Constants.memberRole.tokenMaster
hasViewOnlyPermissions: root.permissionsStore.viewOnlyPermissionsModel.count > 0
sendViaPersonalChatEnabled: root.sendViaPersonalChatEnabled
requestPaymentEnabled: root.requestPaymentEnabled
hasUnrestrictedViewOnlyPermission: {
viewOnlyUnrestrictedPermissionHelper.revision

View File

@ -60,6 +60,7 @@ Item {
property bool amISectionAdmin: false
property bool sendViaPersonalChatEnabled
property bool requestPaymentEnabled
signal openStickerPackPopup(string stickerPackId)
@ -329,6 +330,7 @@ Item {
stickersPopup: root.stickersPopup
chatType: root.activeChatType
areTestNetworksEnabled: root.areTestNetworksEnabled
requestPaymentEnabled: root.requestPaymentEnabled
textInput.onTextChanged: {
if (!!d.activeChatContentModule && textInput.text !== d.activeChatContentModule.inputAreaModule.preservedProperties.text) {

View File

@ -78,6 +78,7 @@ StatusSectionLayout {
property var collectiblesModel
property bool sendViaPersonalChatEnabled
property bool requestPaymentEnabled
readonly property bool contentLocked: {
if (!rootStore.chatCommunitySectionModule.isCommunity()) {
@ -253,6 +254,7 @@ StatusSectionLayout {
canPost: !root.rootStore.chatCommunitySectionModule.isCommunity() || root.canPost
amISectionAdmin: root.amISectionAdmin
sendViaPersonalChatEnabled: root.sendViaPersonalChatEnabled
requestPaymentEnabled: root.requestPaymentEnabled
onOpenStickerPackPopup: {
Global.openPopup(statusStickerPackClickPopup, {packId: stickerPackId, store: root.stickersPopup.store} )
}

View File

@ -5,4 +5,5 @@ QtObject {
property bool dappsEnabled
property bool swapEnabled
property bool sendViaPersonalChatEnabled
property bool requestPaymentEnabled
}

View File

@ -97,6 +97,7 @@ Item {
dappsEnabled: featureFlags ? featureFlags.dappsEnabled : false
swapEnabled: featureFlags ? featureFlags.swapEnabled : false
sendViaPersonalChatEnabled: featureFlags ? featureFlags.sendViaPersonalChatEnabled : false
requestPaymentEnabled: featureFlags ? featureFlags.requestPaymentEnabled : false
}
required property bool isCentralizedMetricsEnabled
@ -1535,6 +1536,7 @@ Item {
stickersPopup: statusStickersPopupLoader.item
sectionItemModel: model
createChatPropertiesStore: appMain.createChatPropertiesStore
areTestNetworksEnabled: appMain.rootStore.profileSectionStore.walletStore.areTestNetworksEnabled
communitiesStore: appMain.communitiesStore
communitySettingsDisabled: !chatLayoutComponent.isManageCommunityEnabledInAdvanced &&
(production && appMain.rootStore.profileSectionStore.walletStore.areTestNetworksEnabled)

View File

@ -49,6 +49,7 @@ Rectangle {
// Use this to only enable the Connections only when this Input opens the Emoji popup
property bool closeGifPopupAfterSelection: true
property bool areTestNetworksEnabled
property bool requestPaymentEnabled: false
property bool emojiEvent: false
property bool isColonPressed: false
@ -962,6 +963,8 @@ Rectangle {
}
function openPaymentRequestPopup() {
if (!control.requestPaymentEnabled)
return
d.requestPaymentPopup = requestPaymentPopupComponent.createObject(control)
d.requestPaymentPopup.open()
}
@ -1035,8 +1038,8 @@ Rectangle {
StatusAction {
text: qsTr("Add payment request")
icon.name: "wallet"
visibleOnDisabled: true
enabled: !root.areTestNetworksEnabled
visibleOnDisabled: control.requestPaymentEnabled
enabled: control.requestPaymentEnabled && !root.areTestNetworksEnabled
onTriggered: control.openPaymentRequestPopup()
}