2022-03-23 15:38:23 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Dialogs 1.3
|
|
|
|
import QtGraphicalEffects 1.13
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.popups 1.0
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2022-07-05 10:12:27 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
2022-03-23 15:38:23 +00:00
|
|
|
import StatusQ.Layout 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Controls.Validators 0.1
|
|
|
|
|
|
|
|
import "../panels/communities"
|
2022-06-06 15:23:24 +00:00
|
|
|
import "../popups/community"
|
2022-03-23 15:38:23 +00:00
|
|
|
import "../layouts"
|
|
|
|
|
2022-08-09 15:08:39 +00:00
|
|
|
StatusSectionLayout {
|
2022-03-23 15:38:23 +00:00
|
|
|
id: root
|
|
|
|
|
2022-08-09 15:08:39 +00:00
|
|
|
notificationCount: root.rootStore.unreadNotificationsCount
|
|
|
|
onNotificationButtonClicked: Global.openActivityCenterPopup()
|
2022-03-23 15:38:23 +00:00
|
|
|
// TODO: get this model from backend?
|
2022-10-05 12:14:29 +00:00
|
|
|
property var settingsMenuModel: root.rootStore.communityPermissionsEnabled ? [{name: qsTr("Overview"), icon: "show"},
|
2022-06-09 15:27:14 +00:00
|
|
|
{name: qsTr("Members"), icon: "group-chat"},
|
|
|
|
{name: qsTr("Permissions"), icon: "objects"}] :
|
2022-10-05 12:14:29 +00:00
|
|
|
[{name: qsTr("Overview"), icon: "show"},
|
2022-06-09 15:27:14 +00:00
|
|
|
{name: qsTr("Members"), icon: "group-chat"}]
|
|
|
|
// TODO: Next community settings options:
|
|
|
|
// {name: qsTr("Tokens"), icon: "token"},
|
|
|
|
// {name: qsTr("Airdrops"), icon: "airdrop"},
|
|
|
|
// {name: qsTr("Token sales"), icon: "token-sale"},
|
|
|
|
// {name: qsTr("Subscriptions"), icon: "subscription"},
|
|
|
|
|
2022-09-27 12:16:03 +00:00
|
|
|
property var rootStore
|
2022-03-23 15:38:23 +00:00
|
|
|
property var community
|
|
|
|
property var chatCommunitySectionModule
|
2022-06-06 15:23:24 +00:00
|
|
|
property bool hasAddedContacts: false
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2022-07-01 11:58:56 +00:00
|
|
|
readonly property string filteredSelectedTags: {
|
|
|
|
if (!community || !community.tags)
|
|
|
|
return "";
|
|
|
|
|
|
|
|
const json = JSON.parse(community.tags);
|
|
|
|
const tagsArray = json.map(tag => {
|
|
|
|
return tag.name;
|
|
|
|
});
|
2022-07-05 11:42:37 +00:00
|
|
|
return JSON.stringify(tagsArray);
|
2022-07-01 11:58:56 +00:00
|
|
|
}
|
|
|
|
|
2022-03-23 15:38:23 +00:00
|
|
|
signal backToCommunityClicked
|
|
|
|
signal openLegacyPopupClicked // TODO: remove me when migration to new settings is done
|
|
|
|
|
2022-09-13 16:17:54 +00:00
|
|
|
onBackButtonClicked: {
|
|
|
|
centerPanelContentLoader.item.children[d.currentIndex].updateState();
|
|
|
|
}
|
|
|
|
|
2022-10-05 11:07:39 +00:00
|
|
|
leftPanel: Item {
|
2022-09-27 12:16:03 +00:00
|
|
|
anchors.fill: parent
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2022-09-27 12:16:03 +00:00
|
|
|
ColumnLayout {
|
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
bottom: footer.top
|
2022-10-05 12:14:29 +00:00
|
|
|
bottomMargin: 12
|
|
|
|
topMargin: Style.current.smallPadding
|
2022-09-27 12:16:03 +00:00
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
2022-10-05 12:14:29 +00:00
|
|
|
width: parent.width
|
|
|
|
spacing: 32
|
2022-09-27 12:16:03 +00:00
|
|
|
clip: true
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2022-10-05 12:14:29 +00:00
|
|
|
StatusChatInfoButton {
|
|
|
|
id: communityHeader
|
|
|
|
|
|
|
|
title: community.name
|
|
|
|
subTitle: qsTr("%n member(s)", "", community.members.count)
|
|
|
|
asset.name: community.image
|
|
|
|
asset.color: community.color
|
|
|
|
asset.isImage: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: Style.current.halfPadding
|
|
|
|
Layout.rightMargin: Style.current.halfPadding
|
|
|
|
type: StatusChatInfoButton.Type.OneToOneChat
|
|
|
|
hoverEnabled: false
|
2022-09-27 12:16:03 +00:00
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2022-09-27 12:16:03 +00:00
|
|
|
StatusListView {
|
|
|
|
id: listView
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2022-10-05 12:14:29 +00:00
|
|
|
Layout.leftMargin: Style.current.padding
|
|
|
|
Layout.rightMargin: Style.current.padding
|
2022-09-27 12:16:03 +00:00
|
|
|
model: root.settingsMenuModel
|
|
|
|
delegate: StatusNavigationListItem {
|
|
|
|
width: listView.width
|
|
|
|
title: modelData.name
|
|
|
|
asset.name: modelData.icon
|
2022-10-05 12:14:29 +00:00
|
|
|
asset.height: 24
|
|
|
|
asset.width: 24
|
2022-09-27 12:16:03 +00:00
|
|
|
selected: d.currentIndex === index
|
|
|
|
onClicked: d.currentIndex = index
|
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-27 12:16:03 +00:00
|
|
|
// TODO: remove me when migration to new settings is done. Only keep back button and anchor to it.
|
|
|
|
ColumnLayout {
|
|
|
|
id: footer
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2022-09-27 12:16:03 +00:00
|
|
|
anchors {
|
|
|
|
bottom: parent.bottom
|
|
|
|
bottomMargin: 16
|
|
|
|
}
|
|
|
|
width: parent.width
|
|
|
|
spacing: 16
|
|
|
|
|
|
|
|
// TODO: remove me when migration to new settings is done
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
text: qsTr("Open legacy popup (to be removed)")
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
font.pixelSize: 10
|
|
|
|
font.underline: true
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onClicked: root.openLegacyPopupClicked()
|
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
}
|
|
|
|
|
2022-09-27 12:16:03 +00:00
|
|
|
StatusBaseText {
|
|
|
|
objectName: "communitySettingsBackToCommunityButton"
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
text: "<- " + qsTr("Back to community")
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
font.pixelSize: 15
|
|
|
|
font.underline: true
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onClicked: root.backToCommunityClicked()
|
|
|
|
hoverEnabled: true
|
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-09 15:08:39 +00:00
|
|
|
centerPanel: Loader {
|
2022-09-13 16:17:54 +00:00
|
|
|
id: centerPanelContentLoader
|
2022-03-23 15:38:23 +00:00
|
|
|
anchors.fill: parent
|
2022-08-09 15:08:39 +00:00
|
|
|
//anchors.margins: 32
|
|
|
|
anchors {
|
|
|
|
leftMargin: 28
|
|
|
|
bottomMargin: 16
|
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
active: root.community
|
|
|
|
sourceComponent: StackLayout {
|
|
|
|
currentIndex: d.currentIndex
|
|
|
|
|
|
|
|
CommunityOverviewSettingsPanel {
|
2022-06-06 15:23:24 +00:00
|
|
|
communityId: root.community.id
|
2022-03-23 15:38:23 +00:00
|
|
|
name: root.community.name
|
|
|
|
description: root.community.description
|
2022-05-26 15:46:02 +00:00
|
|
|
introMessage: root.community.introMessage
|
|
|
|
outroMessage: root.community.outroMessage
|
2022-05-23 18:53:51 +00:00
|
|
|
logoImageData: root.community.image
|
|
|
|
bannerImageData: root.community.bannerImageData
|
2022-03-23 15:38:23 +00:00
|
|
|
color: root.community.color
|
2022-06-09 14:59:54 +00:00
|
|
|
tags: root.rootStore.communityTags
|
2022-07-01 11:58:56 +00:00
|
|
|
selectedTags: root.filteredSelectedTags
|
2022-05-26 15:46:02 +00:00
|
|
|
archiveSupportEnabled: root.community.historyArchiveSupportEnabled
|
|
|
|
requestToJoinEnabled: root.community.access === Constants.communityChatOnRequestAccess
|
|
|
|
pinMessagesEnabled: root.community.pinMessageAllMembersEnabled
|
2022-09-13 16:17:54 +00:00
|
|
|
onCurrentIndexChanged: {
|
|
|
|
root.backButtonName = (currentIndex === 1) ? qsTr("Overview") : "";
|
|
|
|
}
|
2022-05-26 15:46:02 +00:00
|
|
|
archiveSupportOptionVisible: root.rootStore.isCommunityHistoryArchiveSupportEnabled
|
2022-03-23 15:38:23 +00:00
|
|
|
editable: root.community.amISectionAdmin
|
|
|
|
|
|
|
|
onEdited: {
|
2022-06-02 17:48:10 +00:00
|
|
|
const error = root.chatCommunitySectionModule.editCommunity(
|
2022-07-05 10:12:27 +00:00
|
|
|
StatusQUtils.Utils.filterXSS(item.name),
|
|
|
|
StatusQUtils.Utils.filterXSS(item.description),
|
|
|
|
StatusQUtils.Utils.filterXSS(item.introMessage),
|
|
|
|
StatusQUtils.Utils.filterXSS(item.outroMessage),
|
2022-05-26 15:46:02 +00:00
|
|
|
item.options.requestToJoinEnabled ? Constants.communityChatOnRequestAccess : Constants.communityChatPublicAccess,
|
2022-04-28 07:41:57 +00:00
|
|
|
item.color.toString().toUpperCase(),
|
2022-06-09 14:59:54 +00:00
|
|
|
item.selectedTags,
|
2022-08-11 10:58:09 +00:00
|
|
|
Utils.getImageAndCropInfoJson(item.logoImagePath, item.logoCropRect),
|
|
|
|
Utils.getImageAndCropInfoJson(item.bannerPath, item.bannerCropRect),
|
2022-05-26 15:46:02 +00:00
|
|
|
item.options.archiveSupportEnabled,
|
|
|
|
item.options.pinMessagesEnabled
|
2022-04-28 07:41:57 +00:00
|
|
|
)
|
2022-05-26 15:46:02 +00:00
|
|
|
if (error) {
|
|
|
|
errorDialog.text = error.error
|
|
|
|
errorDialog.open()
|
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
}
|
2022-06-06 15:23:24 +00:00
|
|
|
|
|
|
|
onInviteNewPeopleClicked: {
|
2022-09-28 21:07:18 +00:00
|
|
|
Global.openInviteFriendsToCommunityPopup(root.community,
|
|
|
|
root.chatCommunitySectionModule)
|
2022-06-06 15:23:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onAirdropTokensClicked: { /* TODO in future */ }
|
|
|
|
onBackUpClicked: {
|
|
|
|
Global.openPopup(transferOwnershipPopup, {
|
|
|
|
privateKey: root.chatCommunitySectionModule.exportCommunity(root.communityId),
|
|
|
|
})
|
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CommunityMembersSettingsPanel {
|
|
|
|
membersModel: root.community.members
|
2022-06-28 15:03:10 +00:00
|
|
|
bannedMembersModel: root.community.bannedMembers
|
2022-08-04 07:49:41 +00:00
|
|
|
pendingMemberRequestsModel: root.community.pendingMemberRequests
|
|
|
|
declinedMemberRequestsModel: root.community.declinedMemberRequests
|
2022-03-23 15:38:23 +00:00
|
|
|
editable: root.community.amISectionAdmin
|
2022-06-28 15:03:10 +00:00
|
|
|
communityName: root.community.name
|
2022-03-23 15:38:23 +00:00
|
|
|
|
|
|
|
onUserProfileClicked: Global.openProfilePopup(id)
|
|
|
|
onKickUserClicked: root.rootStore.removeUserFromCommunity(id)
|
2022-04-07 14:49:38 +00:00
|
|
|
onBanUserClicked: root.rootStore.banUserFromCommunity(id)
|
2022-06-28 15:03:10 +00:00
|
|
|
onUnbanUserClicked: root.rootStore.unbanUserFromCommunity(id)
|
2022-08-04 07:49:41 +00:00
|
|
|
onAcceptRequestToJoin: root.rootStore.acceptRequestToJoinCommunity(id)
|
|
|
|
onDeclineRequestToJoin: root.rootStore.declineRequestToJoinCommunity(id)
|
2022-03-23 15:38:23 +00:00
|
|
|
}
|
2022-06-09 15:27:14 +00:00
|
|
|
|
2022-09-13 16:17:54 +00:00
|
|
|
CommunityPermissionsSettingsPanel {
|
|
|
|
onStateChanged: {
|
|
|
|
root.backButtonName = previousPageName;
|
|
|
|
}
|
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-09 15:27:14 +00:00
|
|
|
onSettingsMenuModelChanged: d.currentIndex = 0
|
2022-03-23 15:38:23 +00:00
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
property int currentIndex: 0
|
|
|
|
}
|
2022-05-26 15:46:02 +00:00
|
|
|
|
|
|
|
MessageDialog {
|
|
|
|
id: errorDialog
|
|
|
|
title: qsTr("Error editing the community")
|
|
|
|
icon: StandardIcon.Critical
|
|
|
|
standardButtons: StandardButton.Ok
|
|
|
|
}
|
2022-06-06 15:23:24 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: transferOwnershipPopup
|
|
|
|
TransferOwnershipPopup {
|
|
|
|
anchors.centerIn: parent
|
2022-06-29 13:19:18 +00:00
|
|
|
store: root.rootStore
|
2022-06-06 15:23:24 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
}
|