fix(JoinCommunity): Add missing state ONLY private permissions and NOT MET (#14164)

* fix(JoinCommunity): Add missing state ONLY private permissions and NOT MET

- Modified `becomeMemberModel` in store to provide all member permissions.
- Modified permissions model filter to only discard  permissions that are private and NOT met.
- Updated `storybook/PermissionsModel` with new only private permissions and added new model option in corresponding pages.

Closes #14104

* fix(JoinCommunity): Text position when all channels hidden

Updated text position when `allChannelsAreHiddenBecauseNotPermitted` in community join process
This commit is contained in:
Noelia 2024-03-27 13:36:00 +01:00 committed by Jonathan Rainville
parent 7804d4ca39
commit 4144e374a6
6 changed files with 117 additions and 56 deletions

View File

@ -125,6 +125,16 @@ ColumnLayout {
text: "Long model"
onCheckedChanged: if(checked) root.communityHoldingsModel = PermissionsModel.longPermissionsModel
}
RadioButton {
text: "Private met model"
onCheckedChanged: if(checked) root.communityHoldingsModel = PermissionsModel.privatePermissionsModel
}
RadioButton {
text: "Private not met model"
onCheckedChanged: if(checked) root.communityHoldingsModel = PermissionsModel.privatePermissionsNotMetModel
}
}
ColumnLayout {

View File

@ -47,13 +47,52 @@ QtObject {
}
]
readonly property var shortPermissionsModelData: [
readonly property var privatePermissionsModelData: [
{
holdingsListModel: root.createHoldingsModel4(),
holdingsListModel: root.createHoldingsModel1(),
channelsListModel: root.createChannelsModel1(),
permissionType: PermissionTypes.Type.Admin,
permissionState: PermissionTypes.State.Approved,
isPrivate: true
isPrivate: true,
tokenCriteriaMet: false
},
{
holdingsListModel: root.createHoldingsModel2(),
channelsListModel: root.createChannelsModel2(),
permissionType: PermissionTypes.Type.Admin,
permissionState: PermissionTypes.State.Approved,
isPrivate: true,
tokenCriteriaMet: true
}
]
readonly property var privatePermissionsModelNotMetData: [
{
holdingsListModel: root.createHoldingsModel1(),
channelsListModel: root.createChannelsModel1(),
permissionType: PermissionTypes.Type.Admin,
permissionState: PermissionTypes.State.Approved,
isPrivate: true,
tokenCriteriaMet: false
},
{
holdingsListModel: root.createHoldingsModel2(),
channelsListModel: root.createChannelsModel2(),
permissionType: PermissionTypes.Type.Admin,
permissionState: PermissionTypes.State.Approved,
isPrivate: true,
tokenCriteriaMet: false
}
]
readonly property var shortPermissionsModelData: [
{
holdingsListModel: root.createHoldingsModel1(),
channelsListModel: root.createChannelsModel2(),
permissionType: PermissionTypes.Type.Member,
permissionState: PermissionTypes.State.Approved,
isPrivate: false
}
]
@ -69,13 +108,6 @@ QtObject {
]
readonly property var longPermissionsModelData: [
{
holdingsListModel: root.createHoldingsModel4(),
channelsListModel: root.createChannelsModel1(),
permissionType: PermissionTypes.Type.Admin,
permissionState: PermissionTypes.State.Approved,
isPrivate: true
},
{
holdingsListModel: root.createHoldingsModel3(),
channelsListModel: root.createChannelsModel2(),
@ -460,6 +492,28 @@ QtObject {
}
}
readonly property ListModel privatePermissionsModel: ListModel {
readonly property ModelChangeGuard guard: ModelChangeGuard {
model: root.privatePermissionsModel
}
Component.onCompleted: {
append(privatePermissionsModelData)
guard.enabled = true
}
}
readonly property ListModel privatePermissionsNotMetModel: ListModel {
readonly property ModelChangeGuard guard: ModelChangeGuard {
model: root.privatePermissionsNotMetModel
}
Component.onCompleted: {
append(privatePermissionsModelNotMetData)
guard.enabled = true
}
}
readonly property var shortPermissionsModel: ListModel {
readonly property ModelChangeGuard guard: ModelChangeGuard {
model: root.shortPermissionsModel
@ -663,12 +717,6 @@ QtObject {
function createHoldingsModel3() {
return [
{
type: Constants.TokenType.ERC20,
key: "eth",
amount: 15,
available: true
},
{
type: Constants.TokenType.ERC721,
key: "Kitty4",

View File

@ -157,8 +157,8 @@ StatusSectionLayout {
centerPanel: Loader {
anchors.fill: parent
sourceComponent: root.allChannelsAreHiddenBecauseNotPermitted ? allChatsAreHiddenComponent :
(root.contentLocked ? joinCommunityCenterPanelComponent : chatColumnViewComponent)
sourceComponent: (root.allChannelsAreHiddenBecauseNotPermitted || root.contentLocked) ?
joinCommunityCenterPanelComponent : chatColumnViewComponent
}
showRightPanel: {
@ -251,6 +251,7 @@ StatusSectionLayout {
JoinCommunityCenterPanel {
joinCommunity: false
allChannelsAreHiddenBecauseNotPermitted: root.allChannelsAreHiddenBecauseNotPermitted
name: sectionItemModel.name
channelName: root.chatContentModule.chatDetails.name
viewOnlyHoldingsModel: root.viewOnlyPermissionsModel
@ -267,18 +268,6 @@ StatusSectionLayout {
}
}
Component {
id: allChatsAreHiddenComponent
StatusBaseText {
Layout.fillWidth: true
Layout.fillHeight: true
visible: root.allChannelsAreHiddenBecauseNotPermitted
text: qsTr("Sorry, you don't hodl the necessary tokens to view or post in any of <b>%1</b> channels").arg(sectionItemModel.name)
color: Theme.palette.dangerColor1
}
}
Component {
id: contactsColumnComponent
ContactsColumnView {

View File

@ -12,6 +12,7 @@ ColumnLayout {
id: root
property bool joinCommunity: true // Otherwise it means join channel action
property bool allChannelsAreHiddenBecauseNotPermitted: false
property string name
property string channelName
@ -139,6 +140,7 @@ ColumnLayout {
topPadding: 2 * bottomPadding
joinCommunity: root.joinCommunity
allChannelsAreHiddenBecauseNotPermitted: root.allChannelsAreHiddenBecauseNotPermitted
requirementsMet: root.requirementsMet
requirementsCheckPending: root.requirementsCheckPending
isInvitationPending: root.isInvitationPending

View File

@ -2,6 +2,7 @@ import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14
import StatusQ 0.1
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Components 0.1
@ -18,6 +19,7 @@ Control {
id: root
property bool joinCommunity: true // Otherwise it means join channel action
property bool allChannelsAreHiddenBecauseNotPermitted: false
property bool requirementsMet: false
property bool requirementsCheckPending: false
property bool requiresRequest: false
@ -46,16 +48,18 @@ Control {
readonly property string channelRequirementsNotMetText: qsTr("Channel requirements not met")
readonly property string channelMembershipRequestPendingText: qsTr("Channel Membership Request Pending...")
readonly property string memberchipRequestRejectedText: qsTr("Membership Request Rejected")
readonly property string allChannelsAreHiddenBecauseNotPermittedText: qsTr("Sorry, you don't hodl the necessary tokens to view or post in any of <b>%1</b> channels").arg(root.communityName)
function filterPermissions(model) {
return !!model && (model.tokenCriteriaMet || !model.isPrivate)
}
readonly property bool onlyPrivateNotMetPermissions: (d.visiblePermissionsModel.count === 0) && root.communityHoldingsModel.count > 0
readonly property var communityPermissionsModel: SortFilterProxyModel {
readonly property var visiblePermissionsModel: SortFilterProxyModel {
sourceModel: root.communityHoldingsModel
filters: [
ExpressionFilter {
expression: d.filterPermissions(model)
// The only permissions to be discarded are if they are private and NOT met
FastExpressionFilter {
expression: { return !!model && !(!model.tokenCriteriaMet && model.isPrivate) }
expectedRoles: ["tokenCriteriaMet", "isPrivate"]
}
]
}
@ -108,10 +112,10 @@ Control {
id: communityRequirements
visible: root.joinCommunity
introText: d.communityPermissionsModel.count > 0 ?
introText: !d.onlyPrivateNotMetPermissions ?
qsTr("To join <b>%1</b> you need to prove that you hold").arg(root.communityName) :
qsTr("Sorry, you can't join <b>%1</b> because it's a private, closed community").arg(root.communityName)
model: d.communityPermissionsModel
model: d.visiblePermissionsModel
}
CustomHoldingsListPanel {
@ -123,10 +127,10 @@ Control {
}
CustomHoldingsListPanel {
visible: !root.joinCommunity && d.viewAndPostPermissionsModel.count > 0
introText: root.requiresRequest ?
qsTr("To view and post in the <b>#%1</b> channel you need to join <b>%2</b> and prove that you hold").arg(root.channelName).arg(root.communityName) :
qsTr("To view and post in the <b>#%1</b> channel you need to hold").arg(root.channelName)
visible: (!root.joinCommunity && d.viewAndPostPermissionsModel.count > 0) || root.allChannelsAreHiddenBecauseNotPermitted
introText: root.allChannelsAreHiddenBecauseNotPermitted ? d.allChannelsAreHiddenBecauseNotPermittedText :
root.requiresRequest ? qsTr("To view and post in the <b>#%1</b> channel you need to join <b>%2</b> and prove that you hold").arg(root.channelName).arg(root.communityName) :
qsTr("To view and post in the <b>#%1</b> channel you need to hold").arg(root.channelName)
model: d.viewAndPostPermissionsModel
}
@ -138,17 +142,26 @@ Control {
StatusButton {
Layout.alignment: Qt.AlignHCenter
visible: !root.showOnlyPanels && !root.isJoinRequestRejected && root.requiresRequest
text: root.isInvitationPending ? (root.joinCommunity ? d.communityMembershipRequestPendingText : d.channelMembershipRequestPendingText)
: d.communityRequestToJoinText
font.pixelSize: 13
enabled: root.requirementsMet || (joinCommunity && d.communityPermissionsModel.count === 0)
onClicked: root.isInvitationPending ? root.invitationPendingClicked() : root.requestToJoinClicked()
visible: !root.showOnlyPanels
&& !root.isJoinRequestRejected
&& root.requiresRequest
&& !d.onlyPrivateNotMetPermissions
&& !root.allChannelsAreHiddenBecauseNotPermitted
text: root.isInvitationPending ? (root.joinCommunity ? d.communityMembershipRequestPendingText : d.channelMembershipRequestPendingText)
: d.communityRequestToJoinText
font.pixelSize: 13
enabled: root.requirementsMet || (root.joinCommunity && d.visiblePermissionsModel.count === 0)
onClicked: root.isInvitationPending ? root.invitationPendingClicked() : root.requestToJoinClicked()
}
StatusBaseText {
Layout.alignment: Qt.AlignHCenter
visible: !root.showOnlyPanels && !root.requirementsCheckPending && (root.isJoinRequestRejected || !root.requirementsMet)
visible: !root.showOnlyPanels
&& !root.requirementsCheckPending
&& (root.isJoinRequestRejected || !root.requirementsMet)
&& !d.onlyPrivateNotMetPermissions
&& !root.allChannelsAreHiddenBecauseNotPermitted
text: root.isJoinRequestRejected ? d.memberchipRequestRejectedText :
(root.joinCommunity ? d.communityRequirementsNotMetText : d.channelRequirementsNotMetText)
color: Theme.palette.dangerColor1

View File

@ -96,16 +96,15 @@ QtObject {
readonly property var becomeMemberPermissionsModel: SortFilterProxyModel {
id: becomeMemberPermissionsModel
sourceModel: root.permissionsModel
function filterPredicate(modelData) {
return (modelData.permissionType === Constants.permissionType.member ||
modelData.permissionType === Constants.permissionType.admin ||
modelData.permissionType === Constants.permissionType.becomeTokenMaster) &&
(modelData.tokenCriteriaMet || !modelData.isPrivate)
function filterPredicate(permissionType) {
return (permissionType === Constants.permissionType.member ||
permissionType === Constants.permissionType.admin ||
permissionType === Constants.permissionType.becomeTokenMaster)
}
filters: [
FastExpressionFilter {
expression: becomeMemberPermissionsModel.filterPredicate(model)
expectedRoles: ["permissionType", "tokenCriteriaMet", "isPrivate"]
expression: { return becomeMemberPermissionsModel.filterPredicate(model.permissionType) }
expectedRoles: ["permissionType"]
}
]
}