Skip to content

Commit

Permalink
chore: hide create community button behind advanced setting
Browse files Browse the repository at this point in the history
Fixes #14530

(includes a revert of the previous hide that wasn't exactly what we wanted)
  • Loading branch information
jrainville committed May 2, 2024
1 parent 2972531 commit bfb5065
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 8 deletions.
15 changes: 15 additions & 0 deletions src/app/global/local_app_settings.nim
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ const LAS_KEY_CUSTOM_MOUSE_SCROLLING_ENABLED = "global/custom_mouse_scroll_enabl
const DEFAULT_CUSTOM_MOUSE_SCROLLING_ENABLED = false
const DEFAULT_VISIBILITY = 2 #windowed visibility, from qml
const LAS_KEY_FAKE_LOADING_SCREEN_ENABLED = "global/fake_loading_screen"
const LAS_KEY_CREATE_COMMUNITIES_ENABLED = "global/create_communities"
let DEFAULT_FAKE_LOADING_SCREEN_ENABLED = defined(production) and not TEST_MODE_ENABLED #enabled in production, disabled in development and e2e tests
const LAS_KEY_SHARDED_COMMUNITIES_ENABLED = "global/sharded_communities"
const DEFAULT_LAS_KEY_SHARDED_COMMUNITIES_ENABLED = false
const LAS_KEY_TRANSLATIONS_ENABLED = "global/translations_enabled"
const DEFAULT_LAS_KEY_TRANSLATIONS_ENABLED = false
const DEFAULT_LAS_KEY_CREATE_COMMUNITIES_ENABLED = false

QtObject:
type LocalAppSettings* = ref object of QObject
Expand Down Expand Up @@ -148,6 +150,19 @@ QtObject:
write = setFakeLoadingScreenEnabled
notify = fakeLoadingScreenEnabledChanged

proc createCommunityEnabledChanged*(self: LocalAppSettings) {.signal.}
proc getCreateCommunityEnabled*(self: LocalAppSettings): bool {.slot.} =
self.settings.value(LAS_KEY_CREATE_COMMUNITIES_ENABLED, newQVariant(DEFAULT_LAS_KEY_CREATE_COMMUNITIES_ENABLED)).boolVal

proc setCreateCommunityEnabled*(self: LocalAppSettings, enabled: bool) {.slot.} =
self.settings.setValue(LAS_KEY_CREATE_COMMUNITIES_ENABLED, newQVariant(enabled))
self.createCommunityEnabledChanged()

QtProperty[bool] createCommunityEnabled:
read = getCreateCommunityEnabled
write = setCreateCommunityEnabled
notify = createCommunityEnabledChanged

proc wakuV2ShardedCommunitiesEnabledChanged*(self: LocalAppSettings) {.signal.}
proc getWakuV2ShardedCommunitiesEnabled*(self: LocalAppSettings): bool {.slot.} =
self.settings.value(LAS_KEY_SHARDED_COMMUNITIES_ENABLED, newQVariant(DEFAULT_LAS_KEY_SHARDED_COMMUNITIES_ENABLED)).boolVal
Expand Down
20 changes: 12 additions & 8 deletions ui/app/AppLayouts/Communities/CommunitiesPortalLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,18 @@ StatusSectionLayout {
onClicked: Global.importCommunityPopupRequested()
}

StatusButton {
id: createBtn
objectName: "createCommunityButton"
Layout.preferredHeight: 38
verticalPadding: 0
text: qsTr("Create community")
onClicked: {
Global.openPopup(chooseCommunityCreationTypePopupComponent)
Loader {
Layout.preferredHeight: active ? 38 : 0
active: communitiesStore.createCommunityEnabled || communitiesStore.testEnvironment
sourceComponent: StatusButton {
id: createBtn
objectName: "createCommunityButton"
height: parent.height
verticalPadding: 0
text: qsTr("Create community")
onClicked: {
Global.openPopup(chooseCommunityCreationTypePopupComponent)
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions ui/app/AppLayouts/Communities/stores/CommunitiesStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ QtObject {
property bool downloadingCommunityHistoryArchives: root.communitiesModuleInst.downloadingCommunityHistoryArchives
property var advancedModule: profileSectionModule.advancedModule

readonly property bool createCommunityEnabled: localAppSettings.createCommunityEnabled ?? false
readonly property bool testEnvironment: localAppSettings.testEnvironment ?? false

// TODO: Could the backend provide directly 2 filtered models??
//property var featuredCommunitiesModel: root.communitiesModuleInst.curatedFeaturedCommunities
//property var popularCommunitiesModel: root.communitiesModuleInst.curatedPopularCommunities
Expand Down
8 changes: 8 additions & 0 deletions ui/app/AppLayouts/Profile/stores/AdvancedStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ QtObject {
property var customNetworksModel: advancedModule? advancedModule.customNetworksModel : []

readonly property bool isFakeLoadingScreenEnabled: localAppSettings.fakeLoadingScreenEnabled ?? false
readonly property bool createCommunityEnabled: localAppSettings.createCommunityEnabled ?? false
property bool isManageCommunityOnTestModeEnabled: false
readonly property QtObject experimentalFeatures: QtObject {
readonly property string browser: "browser"
Expand Down Expand Up @@ -142,6 +143,13 @@ QtObject {
localAppSettings.fakeLoadingScreenEnabled = !localAppSettings.fakeLoadingScreenEnabled
}

function toggleCreateCommunityEnabled() {
if(!localAppSettings)
return

localAppSettings.createCommunityEnabled = !localAppSettings.createCommunityEnabled
}

function toggleManageCommunityOnTestnet() {
root.isManageCommunityOnTestModeEnabled = !root.isManageCommunityOnTestModeEnabled
}
Expand Down
11 changes: 11 additions & 0 deletions ui/app/AppLayouts/Profile/views/AdvancedView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@ SettingsContentBase {

/////////////////////////////////////////////////////
// WalletConnect POC - to remove
StatusSettingsLineButton {
anchors.leftMargin: 0
anchors.rightMargin: 0
text: qsTr("Enable Community Creation")
isSwitch: true
switchChecked: root.advancedStore.createCommunityEnabled
onClicked: {
root.advancedStore.toggleCreateCommunityEnabled()
}
}

StatusSettingsLineButton {
anchors.leftMargin: 0
anchors.rightMargin: 0
Expand Down

0 comments on commit bfb5065

Please sign in to comment.