feat(community): make on request comm a check box and remove ensOnly

Fixes #5660
This commit is contained in:
Jonathan Rainville 2022-05-06 11:52:08 -04:00 committed by Iuri Matias
parent a5ad2550f2
commit 0358b6bf80
15 changed files with 34 additions and 288 deletions

View File

@ -378,7 +378,6 @@ proc editCommunity*(
name: string,
description: string,
access: int,
ensOnly: bool,
color: string,
imageUrl: string,
aX: int, aY: int, bX: int, bY: int,
@ -388,7 +387,6 @@ proc editCommunity*(
name,
description,
access,
ensOnly,
color,
imageUrl,
aX, aY, bX, bY,

View File

@ -241,7 +241,7 @@ method removeUserFromCommunity*(self: AccessInterface, pubKey: string) {.base.}
method banUserFromCommunity*(self: AccessInterface, pubKey: string) {.base.} =
raise newException(ValueError, "No implementation available")
method editCommunity*(self: AccessInterface, name: string, description: string, access: int, ensOnly: bool, color: string, imagePath: string, aX: int, aY: int, bX: int, bY: int, historyArchiveSupportEnabled: bool) {.base.} =
method editCommunity*(self: AccessInterface, name: string, description: string, access: int, color: string, imagePath: string, aX: int, aY: int, bX: int, bY: int, historyArchiveSupportEnabled: bool) {.base.} =
raise newException(ValueError, "No implementation available")
method exportCommunity*(self: AccessInterface): string {.base.} =

View File

@ -728,10 +728,10 @@ method banUserFromCommunity*(self: Module, pubKey: string) =
self.controller.banUserFromCommunity(pubkey)
method editCommunity*(self: Module, name: string, description: string,
access: int, ensOnly: bool, color: string,
access: int, color: string,
imagePath: string,
aX: int, aY: int, bX: int, bY: int, historyArchiveSupportEnabled: bool) =
self.controller.editCommunity(name, description, access, ensOnly, color, imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled)
self.controller.editCommunity(name, description, access, color, imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled)
method exportCommunity*(self: Module): string =
self.controller.exportCommunity()

View File

@ -244,8 +244,8 @@ QtObject:
proc banUserFromCommunity*(self: View, pubKey: string) {.slot.} =
self.delegate.banUserFromCommunity(pubKey)
proc editCommunity*(self: View, name: string, description: string, access: int, ensOnly: bool, color: string, imagePath: string, aX: int, aY: int, bX: int, bY: int, historyArchiveSupportEnabled: bool) {.slot.} =
self.delegate.editCommunity(name, description, access, ensOnly, color, imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled)
proc editCommunity*(self: View, name: string, description: string, access: int, color: string, imagePath: string, aX: int, aY: int, bX: int, bY: int, historyArchiveSupportEnabled: bool) {.slot.} =
self.delegate.editCommunity(name, description, access, color, imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled)
proc exportCommunity*(self: View): string {.slot.} =
self.delegate.exportCommunity()

View File

@ -67,7 +67,6 @@ proc createCommunity*(
name: string,
description: string,
access: int,
ensOnly: bool,
color: string,
imageUrl: string,
aX: int, aY: int, bX: int, bY: int,
@ -76,7 +75,6 @@ proc createCommunity*(
name,
description,
access,
ensOnly,
color,
imageUrl,
aX, aY, bX, bY,

View File

@ -22,7 +22,7 @@ method getCommunityItem*(self: AccessInterface, community: CommunityDto): Sectio
method joinCommunity*(self: AccessInterface, communityId: string): string {.base.} =
raise newException(ValueError, "No implementation available")
method createCommunity*(self: AccessInterface, name: string, description: string, access: int, ensOnly: bool, color: string, imagePath: string, aX: int, aY: int, bX: int, bY: int, historyArchiveSupportEnabled: bool) {.base.} =
method createCommunity*(self: AccessInterface, name: string, description: string, access: int, color: string, imagePath: string, aX: int, aY: int, bX: int, bY: int, historyArchiveSupportEnabled: bool) {.base.} =
raise newException(ValueError, "No implementation available")
method deleteCommunityCategory*(self: AccessInterface, communityId: string, categoryId: string) {.base.} =

View File

@ -146,11 +146,11 @@ method communityCategoryDeleted*(self: Module) =
discard
method createCommunity*(self: Module, name: string, description: string,
access: int, ensOnly: bool, color: string,
access: int, color: string,
imagePath: string,
aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool) =
self.controller.createCommunity(name, description, access, ensOnly, color, imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled)
self.controller.createCommunity(name, description, access, color, imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled)
method deleteCommunityCategory*(self: Module, communityId: string, categoryId: string) =
self.controller.deleteCommunityCategory(communityId, categoryId)

View File

@ -66,11 +66,11 @@ QtObject:
result = self.delegate.joinCommunity(communityId)
proc createCommunity*(self: View, name: string, description: string,
access: int, ensOnly: bool, color: string,
access: int, color: string,
imagePath: string,
aX: int, aY: int, bX: int, bY: int,
historyArchiveSupportEnabled: bool) {.slot.} =
self.delegate.createCommunity(name, description, access, ensOnly, color, imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled)
self.delegate.createCommunity(name, description, access, color, imagePath, aX, aY, bX, bY, historyArchiveSupportEnabled)
proc deleteCommunityCategory*(self: View, communityId: string, categoryId: string): string {.slot.} =
self.delegate.deleteCommunityCategory(communityId, categoryId)

View File

@ -528,7 +528,6 @@ QtObject:
name: string,
description: string,
access: int,
ensOnly: bool,
color: string,
imageUrl: string,
aX: int, aY: int, bX: int, bY: int,
@ -539,7 +538,6 @@ QtObject:
name,
description,
access,
ensOnly,
color,
image,
aX, aY, bX, bY,
@ -568,7 +566,6 @@ QtObject:
name: string,
description: string,
access: int,
ensOnly: bool,
color: string,
imageUrl: string,
aX: int, aY: int, bX: int, bY: int,
@ -580,7 +577,6 @@ QtObject:
name,
description,
access,
ensOnly,
color,
image,
aX, aY, bX, bY,

View File

@ -33,7 +33,6 @@ proc createCommunity*(
name: string,
description: string,
access: int,
ensOnly: bool,
color: string,
imageUrl: string,
aX: int, aY: int, bX: int, bY: int,
@ -44,7 +43,7 @@ proc createCommunity*(
"Membership": access,
"name": name,
"description": description,
"ensOnly": ensOnly,
"ensOnly": false, # TODO ensOnly is no longer supported. Remove this when we remove it in status-go
"color": color,
"image": imageUrl,
"imageAx": aX,
@ -59,7 +58,6 @@ proc editCommunity*(
name: string,
description: string,
access: int,
ensOnly: bool,
color: string,
imageUrl: string,
aX: int,
@ -74,7 +72,7 @@ proc editCommunity*(
"Membership": access,
"name": name,
"description": description,
"ensOnly": ensOnly,
"ensOnly": false, # TODO ensOnly is no longer supported. Remove this when we remove it in status-go
"color": color,
"image": imageUrl,
"imageAx": aX,

View File

@ -37,9 +37,9 @@ StatusModal {
if (community.largeImage) {
contentItem.communityImage.selectedImage = community.largeImage
}
membershipRequirementSettingPopup.checkedMembership = community.access
requestToJoinCheckbox.checked = community.access === Constants.communityChatOnRequestAccess
}
contentItem.communityName.input.forceActiveFocus(Qt.MouseFocusReason)
contentItem.communityName.input.edit.forceActiveFocus()
}
onClosed: destroy()
@ -298,56 +298,17 @@ StatusModal {
visible: !isEdit
}
StatusListItem {
anchors.horizontalCenter: parent.horizontalCenter
visible: !isEdit
//% "Membership requirement"
title: qsTrId("membership-title")
label: {
switch (membershipRequirementSettingPopup.checkedMembership) {
//% "Require invite from another member"
case Constants.communityChatInvitationOnlyAccess: return qsTrId("membership-invite")
//% "Require approval"
case Constants.communityChatOnRequestAccess: return qsTrId("membership-approval")
//% "No requirement"
default: return qsTrId("membership-free")
}
}
sensor.onClicked: membershipRequirementSettingPopup.open()
components: [
StatusIcon {
icon: "chevron-down"
rotation: 270
color: Theme.palette.baseColor1
}
]
}
StatusBaseText {
visible: !isEdit
height: visible ? implicitHeight : 0
wrapMode: Text.WordWrap
font.pixelSize: 13
color: Theme.palette.baseColor1
width: parent.width * 0.78
//% "You can require new members to meet certain criteria before they can join. This can be changed at any time"
text: qsTrId("membership-none-placeholder")
anchors.left: parent.left
anchors.leftMargin: 16
}
StatusListItem {
anchors.horizontalCenter: parent.horizontalCenter
visible: popup.store.isCommunityHistoryArchiveSupportEnabled
//% "Membership requirement"
title: qsTrId("History Archive Support")
title: qsTr("Community history service")
sensor.onClicked: {
if (popup.store.isCommunityHistoryArchiveSupportEnabled) {
historyArchiveSupportToggle.checked = !historyArchiveSupportToggle.checked
}
}
components: [
StatusSwitch {
StatusCheckBox {
id: historyArchiveSupportToggle
enabled: popup.store.isCommunityHistoryArchiveSupportEnabled
checked: isEdit ? community.historyArchiveSupportEnabled : false
@ -355,49 +316,19 @@ StatusModal {
]
}
// Feature commented temporarily
/*
StatusSettingsLineButton {
id: ensOnlySwitch
anchors.top: privateExplanation.bottom
anchors.topMargin: Style.current.padding
isEnabled: profileModel.profile.ensVerified
//% "Require ENS username"
text: qsTrId("membership-ens")
isSwitch: true
onClicked: switchChecked = checked
StatusToolTip {
visible: !ensOnlySwitch.isEnabled && ensMouseArea.isHovered
//% "You can only enable this setting if you have an ENS name"
text: qsTrId("you-can-only-enable-this-setting-if-you-have-an-ens-name")
StatusListItem {
anchors.horizontalCenter: parent.horizontalCenter
title: qsTr("Request to join required")
sensor.onClicked: {
requestToJoinCheckbox.checked = !requestToJoinCheckbox.checked
}
MouseArea {
property bool isHovered: false
id: ensMouseArea
enabled: !ensOnlySwitch.isEnabled
visible: enabled
anchors.fill: parent
hoverEnabled: true
onEntered: isHovered = true
onExited: isHovered = false
components: [
StatusCheckBox {
id: requestToJoinCheckbox
checked: false
}
]
}
StyledText {
visible: !isEdit
height: visible ? implicitHeight : 0
id: ensExplanation
anchors.top: ensOnlySwitch.bottom
wrapMode: Text.WordWrap
anchors.topMargin: isEdit ? 0 : Style.current.halfPadding
width: parent.width
//% "Your community requires an ENS username to be able to join"
text: qsTrId("membership-ens-description")
}
*/
}
}
@ -434,8 +365,7 @@ StatusModal {
error = communitySectionModule.editCommunity(
Utils.filterXSS(popup.contentItem.communityName.input.text),
Utils.filterXSS(popup.contentItem.communityDescription.input.text),
membershipRequirementSettingPopup.checkedMembership,
false,
requestToJoinCheckbox.checked ? Constants.communityChatOnRequestAccess : Constants.communityChatPublicAccess,
popup.contentItem.communityColor.color.toString().toUpperCase(),
// to retain the existing image, pass "" for the image path
popup.contentItem.communityImage.selectedImage === community.largeImage ? "" :
@ -450,8 +380,7 @@ StatusModal {
error = popup.store.createCommunity(
Utils.filterXSS(popup.contentItem.communityName.input.text),
Utils.filterXSS(popup.contentItem.communityDescription.input.text),
membershipRequirementSettingPopup.checkedMembership,
false, // ensOnlySwitch.switchChecked, // TODO:
requestToJoinCheckbox.checked ? Constants.communityChatOnRequestAccess : Constants.communityChatPublicAccess,
popup.contentItem.communityColor.color.toString().toUpperCase(),
popup.contentItem.communityImage.selectedImage,
popup.contentItem.imageCropperModal.aX,
@ -479,10 +408,5 @@ StatusModal {
icon: StandardIcon.Critical
standardButtons: StandardButton.Ok
}
MembershipRequirementPopup {
anchors.centerIn: parent
id: membershipRequirementSettingPopup
}
}

View File

@ -1,167 +0,0 @@
import QtQuick 2.12
import QtQuick.Controls 2.3
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Components 0.1
import StatusQ.Controls 0.1
import StatusQ.Popups 0.1
import utils 1.0
StatusModal {
property int checkedMembership: Constants.communityChatPublicAccess
id: popup
//% "Membership requirement"
header.title: qsTrId("membership-title")
ButtonGroup {
id: membershipRequirementGroup
}
contentItem: Column {
width: popup.width
spacing: 8
Item {
width: parent.width
height: parent.spacing
}
StatusListItem {
anchors.horizontalCenter: parent.horizontalCenter
//% "Require approval"
title: qsTrId("membership-approval")
sensor.onClicked: requestAccessRadio.checked = true
components: [
StatusRadioButton {
id: requestAccessRadio
checked: popup.checkedMembership === Constants.communityChatOnRequestAccess
ButtonGroup.group: membershipRequirementGroup
onCheckedChanged: {
if (checked) {
popup.checkedMembership = Constants.communityChatOnRequestAccess
}
}
}
]
}
StatusBaseText {
wrapMode: Text.WordWrap
font.pixelSize: 13
color: Theme.palette.baseColor1
width: parent.width * 0.78
//% "Your community is free to join, but new members are required to be approved by the community creator first"
text: qsTrId("membership-approval-description")
anchors.left: parent.left
anchors.leftMargin: 32
}
// TODO: uncomment this when we want to re-enable requiring invite from another member
// for community creation
// StatusListItem {
// anchors.horizontalCenter: parent.horizontalCenter
// //% "Require invite from another member"
// title: qsTrId("membership-invite")
// sensor.onClicked: inviteOnlyRadio.checked = true
// components: [
// StatusRadioButton {
// id: inviteOnlyRadio
// checked: popup.checkedMembership === Constants.communityChatInvitationOnlyAccess
// ButtonGroup.group: membershipRequirementGroup
// onCheckedChanged: {
// if (checked) {
// popup.checkedMembership = Constants.communityChatInvitationOnlyAccess
// }
// }
// }
// ]
// }
StatusBaseText {
wrapMode: Text.WordWrap
font.pixelSize: 13
color: Theme.palette.baseColor1
width: parent.width * 0.78
//% "Your community can only be joined by an invitation from existing community members"
text: qsTrId("membership-invite-description")
anchors.left: parent.left
anchors.leftMargin: 32
}
/* TODO: add functionality to configure this setting */
/* StatusListItem { */
/* anchors.horizontalCenter: parent.horizontalCenter */
//% "Require ENS username"
/* title: qsTrId("membership-ens") */
/* components: [ */
/* StatusRadioButton { */
/* checked: //... */
/* ButtonGroup.group: membershipRequirementGroup */
/* onCheckedChanged: { */
/* // ... */
/* } */
/* } */
/* ] */
/* } */
/* StatusBaseText { */
/* wrapMode: Text.WordWrap */
/* font.pixelSize: 13 */
/* color: Theme.palette.baseColor1 */
/* width: parent.width * 0.78 */
//% "Your community requires an ENS username to be able to join"
/* text: qsTrId("membership-ens-description") */
/* anchors.left: parent.left */
/* anchors.leftMargin: 32 */
/* } */
StatusListItem {
anchors.horizontalCenter: parent.horizontalCenter
//% "No requirement"
title: qsTrId("membership-free")
sensor.onClicked: publicRadio.checked = true
components: [
StatusRadioButton {
id: publicRadio
checked: popup.checkedMembership === Constants.communityChatPublicAccess
ButtonGroup.group: membershipRequirementGroup
onCheckedChanged: {
if (checked) {
popup.checkedMembership = Constants.communityChatPublicAccess
}
}
}
]
}
StatusBaseText {
wrapMode: Text.WordWrap
font.pixelSize: 13
color: Theme.palette.baseColor1
width: parent.width * 0.78
//% "Your community is free for anyone to join"
text: qsTrId("membership-free-description")
anchors.left: parent.left
anchors.leftMargin: 32
}
Item {
width: parent.width
height: parent.spacing
}
}
leftButtons: [
StatusRoundButton {
icon.name: "arrow-right"
icon.width: 20
icon.height: 16
rotation: 180
onClicked: popup.close()
}
]
}

View File

@ -230,8 +230,8 @@ QtObject {
// Not Refactored Yet
property var activeCommunityChatsModel: "" //chatsModelInst.communities.activeCommunity.chats
function createCommunity(communityName, communityDescription, checkedMembership, ensOnlySwitchChecked, communityColor, communityImage, imageCropperModalaX, imageCropperModalaY, imageCropperModalbX, imageCropperModalbY, historyArchiveSupportEnabled) {
communitiesModuleInst.createCommunity(communityName, communityDescription, checkedMembership, ensOnlySwitchChecked, communityColor, communityImage, imageCropperModalaX, imageCropperModalaY, imageCropperModalbX, imageCropperModalbY, historyArchiveSupportEnabled);
function createCommunity(communityName, communityDescription, checkedMembership, communityColor, communityImage, imageCropperModalaX, imageCropperModalaY, imageCropperModalbX, imageCropperModalbY, historyArchiveSupportEnabled) {
communitiesModuleInst.createCommunity(communityName, communityDescription, checkedMembership, communityColor, communityImage, imageCropperModalaX, imageCropperModalaY, imageCropperModalbX, imageCropperModalbY, historyArchiveSupportEnabled);
}
function importCommunity(communityKey) {

View File

@ -125,7 +125,6 @@ StatusAppTwoPanelLayout {
Utils.filterXSS(item.name),
Utils.filterXSS(item.description),
root.community.access,
false, // FIXME
item.color.toString().toUpperCase(),
item.image === root.community.image ? "" : item.image,
item.imageAx,

View File

@ -60,8 +60,8 @@ QtObject {
return profileSectionModule.ensUsernamesModule.getEtherscanLink()
}
function createCommunity(communityName, communityDescription, checkedMembership, ensOnlySwitchChecked, communityColor, communityImage, imageCropperModalaX, imageCropperModalaY, imageCropperModalbX, imageCropperModalbY) {
communitiesModuleInst.createCommunity(communityName, communityDescription, checkedMembership, ensOnlySwitchChecked, communityColor, communityImage, imageCropperModalaX, imageCropperModalaY, imageCropperModalbX, imageCropperModalbY);
function createCommunity(communityName, communityDescription, checkedMembership, communityColor, communityImage, imageCropperModalaX, imageCropperModalaY, imageCropperModalbX, imageCropperModalbY) {
communitiesModuleInst.createCommunity(communityName, communityDescription, checkedMembership, communityColor, communityImage, imageCropperModalaX, imageCropperModalaY, imageCropperModalbX, imageCropperModalbY);
}
function copyToClipboard(text) {