feat(CommunityPemissions): Added chat input post rights panel

Closes #9436
This commit is contained in:
Alexandra Betouni 2023-06-06 18:42:42 +03:00 committed by Follow the white rabbit
parent 5b5361c9b0
commit 3e0a01883f
6 changed files with 250 additions and 86 deletions

View File

@ -161,6 +161,10 @@ ListModel {
title: "FeesPanel" title: "FeesPanel"
section: "Panels" section: "Panels"
} }
ListElement {
title: "ChatPermissionQualificationPanel"
section: "Panels"
}
ListElement { ListElement {
title: "BurnTokensPopup" title: "BurnTokensPopup"
section: "Popups" section: "Popups"

View File

@ -75,6 +75,9 @@
"CommunityPermissionsView": [ "CommunityPermissionsView": [
"https://www.figma.com/file/17fc13UBFvInrLgNUKJJg5/Kuba%E2%8E%9CDesktop?node-id=22813%3A497277&t=7gqqAFbdG5KrPOmn-0" "https://www.figma.com/file/17fc13UBFvInrLgNUKJJg5/Kuba%E2%8E%9CDesktop?node-id=22813%3A497277&t=7gqqAFbdG5KrPOmn-0"
], ],
"ChatPermissionQualificationPanel": [
"https://www.figma.com/file/17fc13UBFvInrLgNUKJJg5/Kuba%E2%8E%9CDesktop?node-id=2698%3A375926&t=iIeFeGOBx5BbbYJa-0"
],
"CommunityProfilePopupInviteFriendsPanel": [ "CommunityProfilePopupInviteFriendsPanel": [
"https://www.figma.com/file/17fc13UBFvInrLgNUKJJg5/Kuba%E2%8E%9CDesktop?node-id=2927%3A343592", "https://www.figma.com/file/17fc13UBFvInrLgNUKJJg5/Kuba%E2%8E%9CDesktop?node-id=2927%3A343592",
"https://www.figma.com/file/17fc13UBFvInrLgNUKJJg5/Kuba%E2%8E%9CDesktop?node-id=2990%3A353179", "https://www.figma.com/file/17fc13UBFvInrLgNUKJJg5/Kuba%E2%8E%9CDesktop?node-id=2990%3A353179",

View File

@ -0,0 +1,38 @@
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14
import Models 1.0
import Storybook 1.0
import utils 1.0
import AppLayouts.Chat.popups.community 1.0
import AppLayouts.Chat.panels.communities 1.0
SplitView {
id: root
Logs { id: logs }
Item {
SplitView.fillWidth: true
SplitView.fillHeight: true
ChatPermissionQualificationPanel {
anchors.centerIn: parent
width: 500
height: 40
holdingsModel: PermissionsModel.longPermissionsModel
assetsModel: AssetsModel {}
collectiblesModel: CollectiblesModel {}
}
}
LogsAndControlsPanel {
id: logsAndControlsPanel
SplitView.minimumHeight: 100
SplitView.preferredHeight: 200
logsView.logText: logs.logText
}
}

View File

@ -0,0 +1,89 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import utils 1.0
import StatusQ.Core 0.1
import StatusQ.Components 0.1
import StatusQ.Core.Theme 0.1
import AppLayouts.Chat.views.communities 1.0
Item {
id: root
property var holdingsModel
property var assetsModel
property var collectiblesModel
QtObject {
id: d
property int panelRowSpacing: 4 // by design
}
RowLayout {
anchors.fill: parent
spacing: d.panelRowSpacing
StatusBaseText {
text: qsTr("To post, hold")
font.pixelSize: Style.current.primaryTextFontSize
color: Style.current.secondaryText
}
StatusScrollView {
Layout.fillWidth: true
Layout.preferredHeight: 20
contentWidth: tokenRow.implicitWidth
padding: 0
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
Row {
id: tokenRow
Repeater {
id: repeater
model: root.holdingsModel
Row {
spacing: d.panelRowSpacing
Row {
spacing: d.panelRowSpacing
Repeater {
model: HoldingsSelectionModel {
sourceModel: holdingsListModel
assetsModel: root.assetsModel
collectiblesModel: root.collectiblesModel
}
StatusListItemTag {
height: 20
enabled: false
leftPadding: 2
title: model.text
asset.name: model.imageSource
asset.isImage: true
asset.bgColor: "transparent"
asset.height: 16
asset.width: asset.height
asset.bgWidth: asset.height
asset.bgHeight: asset.height
asset.color: asset.isImage ? "transparent" : titleText.color
closeButtonVisible: false
titleText.color: model.available ? Theme.palette.primaryColor1 : Theme.palette.dangerColor1
bgColor: model.available ? Theme.palette.primaryColor2 :Theme.palette.dangerColor2
titleText.font.pixelSize: 12
}
}
}
StatusBaseText {
height: parent.height
visible: (index !== (repeater.count - 1))
verticalAlignment: Text.AlignVCenter
font.pixelSize: Style.current.primaryTextFontSize
rightPadding: d.panelRowSpacing
color: Style.current.secondaryText
text: qsTr("or")
}
}
}
}
}
Item { Layout.fillWidth: true }
}
}

View File

@ -15,3 +15,4 @@ SortableTokenHoldersPanel 1.0 SortableTokenHoldersPanel.qml
TokenHoldersPanel 1.0 TokenHoldersPanel.qml TokenHoldersPanel 1.0 TokenHoldersPanel.qml
TokenHoldersProxyModel 1.0 TokenHoldersProxyModel.qml TokenHoldersProxyModel 1.0 TokenHoldersProxyModel.qml
WarningPanel 1.0 WarningPanel.qml WarningPanel 1.0 WarningPanel.qml
ChatPermissionQualificationPanel 1.0 ChatPermissionQualificationPanel.qml

View File

@ -6,6 +6,7 @@ import QtQml 2.15
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
import StatusQ.Components 0.1 import StatusQ.Components 0.1
import StatusQ.Controls 0.1 import StatusQ.Controls 0.1
import StatusQ.Core.Utils 0.1
import utils 1.0 import utils 1.0
import shared 1.0 import shared 1.0
@ -13,6 +14,9 @@ import shared.popups 1.0
import shared.status 1.0 import shared.status 1.0
import shared.controls 1.0 import shared.controls 1.0
import shared.views.chat 1.0 import shared.views.chat 1.0
import SortFilterProxyModel 0.2
import AppLayouts.Chat.popups.community 1.0
import "../helpers" import "../helpers"
import "../controls" import "../controls"
@ -20,6 +24,7 @@ import "../popups"
import "../panels" import "../panels"
import "../../Wallet" import "../../Wallet"
import "../stores" import "../stores"
import "../panels/communities"
Item { Item {
id: root id: root
@ -38,6 +43,8 @@ Item {
property int chatsCount: parentModule && parentModule.model ? parentModule.model.count : 0 property int chatsCount: parentModule && parentModule.model ? parentModule.model.count : 0
property int activeChatType: parentModule && parentModule.activeItem.type property int activeChatType: parentModule && parentModule.activeItem.type
property bool stickersLoaded: false property bool stickersLoaded: false
property bool viewAndPostPermissionsSatisfied: true
property var viewAndPostPermissionsModel
readonly property var contactDetails: rootStore ? rootStore.oneToOneChatContact : null readonly property var contactDetails: rootStore ? rootStore.oneToOneChatContact : null
readonly property bool isUserAdded: !!root.contactDetails && root.contactDetails.isAdded readonly property bool isUserAdded: !!root.contactDetails && root.contactDetails.isAdded
@ -101,7 +108,6 @@ Item {
QtObject { QtObject {
id: d id: d
readonly property var activeChatContentModule: d.getChatContentModule(root.activeChatId) readonly property var activeChatContentModule: d.getChatContentModule(root.activeChatId)
readonly property UsersStore activeUsersStore: UsersStore { readonly property UsersStore activeUsersStore: UsersStore {
@ -234,11 +240,16 @@ Item {
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Layout.margins: Style.current.smallPadding Layout.margins: Style.current.smallPadding
Layout.preferredHeight: chatInputItem.height
Item {
id: chatInputItem
Layout.fillWidth: true
Layout.preferredHeight: chatInput.height
StatusChatInput { StatusChatInput {
id: chatInput id: chatInput
width: parent.width
Layout.fillWidth: true
visible: !!d.activeChatContentModule visible: !!d.activeChatContentModule
enabled: !!d.activeChatContentModule enabled: !!d.activeChatContentModule
@ -246,18 +257,25 @@ Item {
&& root.rootStore.sectionDetails.joined && root.rootStore.sectionDetails.joined
&& !root.rootStore.sectionDetails.amIBanned && !root.rootStore.sectionDetails.amIBanned
&& root.rootStore.isUserAllowedToSendMessage && root.rootStore.isUserAllowedToSendMessage
&& !channelPostRestrictions.visible
&& root.viewAndPostPermissionsSatisfied
store: root.rootStore store: root.rootStore
usersStore: d.activeUsersStore usersStore: d.activeUsersStore
textInput.placeholderText: { textInput.placeholderText: {
if (!d.activeChatContentModule) if (!channelPostRestrictions.visible) {
return
if (d.activeChatContentModule.chatDetails.blocked) if (d.activeChatContentModule.chatDetails.blocked)
return qsTr("This user has been blocked.") return qsTr("This user has been blocked.")
if (!root.rootStore.sectionDetails.joined || root.rootStore.sectionDetails.amIBanned) if (!root.rootStore.sectionDetails.joined || root.rootStore.sectionDetails.amIBanned)
return qsTr("You need to join this community to send messages") return qsTr("You need to join this community to send messages")
if (!root.viewAndPostPermissionsSatisfied) {
return qsTr("Sorry, you don't have the tokens needed to post in this channel.")
}
return root.rootStore.chatInputPlaceHolderText return root.rootStore.chatInputPlaceHolderText
} else {
return "";
}
} }
emojiPopup: root.emojiPopup emojiPopup: root.emojiPopup
@ -298,7 +316,6 @@ Item {
} }
onStickerSelected: { onStickerSelected: {
if (!!d.activeChatContentModule)
root.rootStore.sendSticker(d.activeChatContentModule.getMyChatId(), root.rootStore.sendSticker(d.activeChatContentModule.getMyChatId(),
hashId, hashId,
chatInput.isReply ? chatInput.replyMessageId : "", chatInput.isReply ? chatInput.replyMessageId : "",
@ -306,7 +323,6 @@ Item {
url) url)
} }
onSendMessage: { onSendMessage: {
if (!d.activeChatContentModule) { if (!d.activeChatContentModule) {
console.debug("error on sending message - chat content module is not set") console.debug("error on sending message - chat content module is not set")
@ -333,6 +349,20 @@ Item {
} }
} }
ChatPermissionQualificationPanel {
id: channelPostRestrictions
width: chatInput.textInput.width
height: chatInput.textInput.height
anchors.left: parent.left
anchors.leftMargin: (2*Style.current.bigPadding)
visible: (!!root.viewAndPostPermissionsModel && (root.viewAndPostPermissionsModel.count > 0)
&& !root.amISectionAdmin)
assetsModel: root.rootStore.assetsModel
collectiblesModel: root.rootStore.collectiblesModel
holdingsModel: root.viewAndPostHoldingsModel
}
}
StatusButton { StatusButton {
Layout.fillHeight: true Layout.fillHeight: true
Layout.maximumHeight: chatInput.implicitHeight Layout.maximumHeight: chatInput.implicitHeight
@ -348,7 +378,6 @@ Item {
} }
} }
Component { Component {
id: cmpSendTransactionNoEns id: cmpSendTransactionNoEns
ChatCommandModal { ChatCommandModal {