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
|
|
|
|
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"
|
|
|
|
|
|
|
|
StatusAppTwoPanelLayout {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
// TODO: get this model from backend?
|
|
|
|
property var model: [{name: qsTr("Overview"), icon: "help"},
|
|
|
|
{name: qsTr("Members"), icon: "group-chat"},
|
|
|
|
// {name: qsTr("Permissions"), icon: "objects"},
|
|
|
|
// {name: qsTr("Tokens"), icon: "token"},
|
|
|
|
// {name: qsTr("Airdrops"), icon: "airdrop"},
|
|
|
|
// {name: qsTr("Token sales"), icon: "token-sale"},
|
|
|
|
// {name: qsTr("Subscriptions"), icon: "subscription"},
|
|
|
|
{name: qsTr("Notifications"), icon: "notification"}]
|
|
|
|
|
|
|
|
property var rootStore
|
|
|
|
property var community
|
|
|
|
property var chatCommunitySectionModule
|
2022-06-06 15:23:24 +00:00
|
|
|
property bool hasAddedContacts: false
|
2022-06-21 11:44:20 +00:00
|
|
|
property Component membershipRequestPopup
|
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;
|
|
|
|
});
|
|
|
|
return tagsArray;
|
|
|
|
}
|
|
|
|
|
2022-03-23 15:38:23 +00:00
|
|
|
signal backToCommunityClicked
|
|
|
|
signal openLegacyPopupClicked // TODO: remove me when migration to new settings is done
|
|
|
|
|
|
|
|
leftPanel: ColumnLayout {
|
|
|
|
anchors {
|
|
|
|
fill: parent
|
|
|
|
margins: 8
|
|
|
|
topMargin: 16
|
|
|
|
bottomMargin: 16
|
|
|
|
}
|
|
|
|
|
|
|
|
spacing: 16
|
|
|
|
|
|
|
|
StatusNavigationPanelHeadline {
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
text: qsTr("Settings")
|
|
|
|
}
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
id: listView
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
implicitHeight: contentItem.childrenRect.height
|
|
|
|
|
|
|
|
model: root.model
|
|
|
|
delegate: StatusNavigationListItem {
|
|
|
|
width: listView.width
|
|
|
|
title: modelData.name
|
|
|
|
icon.name: modelData.icon
|
|
|
|
selected: d.currentIndex == index
|
|
|
|
onClicked: d.currentIndex = index
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rightPanel: Loader {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 16
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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-04-28 07:41:57 +00:00
|
|
|
Utils.filterXSS(item.name),
|
|
|
|
Utils.filterXSS(item.description),
|
2022-05-26 15:46:02 +00:00
|
|
|
Utils.filterXSS(item.introMessage),
|
|
|
|
Utils.filterXSS(item.outroMessage),
|
|
|
|
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-05-23 17:36:48 +00:00
|
|
|
JSON.stringify({imagePath: String(item.logoImagePath).replace("file://", ""), cropRect: item.logoCropRect}),
|
2022-05-23 18:53:51 +00:00
|
|
|
JSON.stringify({imagePath: String(item.bannerPath).replace("file://", ""), cropRect: 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: {
|
|
|
|
Global.openPopup(inviteFriendsToCommunityPopup, {
|
|
|
|
community: root.community,
|
2022-06-20 13:27:00 +00:00
|
|
|
hasAddedContacts: root.hasAddedContacts
|
2022-06-06 15:23:24 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
onAirdropTokensClicked: { /* TODO in future */ }
|
|
|
|
onBackUpClicked: {
|
|
|
|
Global.openPopup(transferOwnershipPopup, {
|
|
|
|
privateKey: root.chatCommunitySectionModule.exportCommunity(root.communityId),
|
|
|
|
store: root.store
|
|
|
|
})
|
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CommunityMembersSettingsPanel {
|
|
|
|
membersModel: root.community.members
|
|
|
|
editable: root.community.amISectionAdmin
|
|
|
|
pendingRequests: root.community.pendingRequestsToJoin ? root.community.pendingRequestsToJoin.count : 0
|
|
|
|
|
|
|
|
onUserProfileClicked: Global.openProfilePopup(id)
|
|
|
|
onKickUserClicked: root.rootStore.removeUserFromCommunity(id)
|
2022-04-07 14:49:38 +00:00
|
|
|
onBanUserClicked: root.rootStore.banUserFromCommunity(id)
|
2022-06-21 11:44:20 +00:00
|
|
|
onMembershipRequestsClicked: Global.openPopup(root.membershipRequestPopup, {
|
2022-03-23 15:38:23 +00:00
|
|
|
communitySectionModule: root.chatCommunitySectionModule
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
SettingsPageLayout {
|
|
|
|
title: qsTr("Notifications")
|
|
|
|
|
|
|
|
content: ColumnLayout {
|
|
|
|
StatusListItem {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
title: qsTr("Enabled")
|
|
|
|
icon.name: "notification"
|
|
|
|
sensor.cursorShape: Qt.ArrowCursor
|
|
|
|
components: [
|
|
|
|
StatusSwitch {
|
|
|
|
checked: !root.community.muted
|
|
|
|
onClicked: root.chatCommunitySectionModule.setCommunityMuted(!checked)
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: inviteFriendsToCommunityPopup
|
|
|
|
InviteFriendsToCommunityPopup {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
rootStore: root.rootStore
|
2022-06-20 13:27:00 +00:00
|
|
|
contactsStore: root.rootStore.contactsStore
|
2022-06-06 15:23:24 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
|
|
|
|
onSendInvites: {
|
|
|
|
const error = root.communitySectionModule.inviteUsersToCommunity(JSON.stringify(pubKeys))
|
|
|
|
processInviteResult(error)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-06-20 12:01:50 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: membershipRequestPopup
|
|
|
|
MembershipRequestsPopup {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
store: root.rootStore
|
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
}
|