2022-06-06 15:23:24 +00:00
|
|
|
|
import QtQuick 2.14
|
2022-03-23 15:38:23 +00:00
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
import StatusQ.Components 0.1
|
2023-09-14 10:02:51 +00:00
|
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
2022-03-23 15:38:23 +00:00
|
|
|
|
|
2023-06-23 06:17:04 +00:00
|
|
|
|
import AppLayouts.Communities.layouts 1.0
|
|
|
|
|
import AppLayouts.Communities.panels 1.0
|
2023-09-14 10:02:51 +00:00
|
|
|
|
import AppLayouts.Communities.popups 1.0
|
|
|
|
|
import AppLayouts.Communities.helpers 1.0
|
2022-03-23 15:38:23 +00:00
|
|
|
|
|
2023-06-29 09:35:37 +00:00
|
|
|
|
import shared.popups 1.0
|
|
|
|
|
|
2023-09-14 10:02:51 +00:00
|
|
|
|
|
2022-06-06 15:23:24 +00:00
|
|
|
|
import utils 1.0
|
|
|
|
|
|
2022-03-23 15:38:23 +00:00
|
|
|
|
StackLayout {
|
|
|
|
|
id: root
|
|
|
|
|
|
2023-09-14 10:02:51 +00:00
|
|
|
|
required property bool isOwner
|
2024-04-17 13:25:45 +00:00
|
|
|
|
required property bool isAdmin
|
|
|
|
|
required property bool isTokenMaster
|
|
|
|
|
|
2022-06-06 15:23:24 +00:00
|
|
|
|
property string communityId
|
2022-03-23 15:38:23 +00:00
|
|
|
|
property string name
|
|
|
|
|
property string description
|
2022-05-26 15:46:02 +00:00
|
|
|
|
property string introMessage
|
|
|
|
|
property string outroMessage
|
2022-05-23 18:53:51 +00:00
|
|
|
|
property string logoImageData
|
|
|
|
|
property string bannerImageData
|
|
|
|
|
property rect bannerCropRect
|
2022-03-23 15:38:23 +00:00
|
|
|
|
property color color
|
2022-06-09 14:59:54 +00:00
|
|
|
|
property string tags
|
|
|
|
|
property string selectedTags
|
2022-05-26 15:46:02 +00:00
|
|
|
|
property bool archiveSupportEnabled
|
|
|
|
|
property bool requestToJoinEnabled
|
|
|
|
|
property bool pinMessagesEnabled
|
2022-12-07 16:14:36 +00:00
|
|
|
|
property string previousPageName: (currentIndex === 1) ? qsTr("Overview") : ""
|
2023-09-14 10:02:51 +00:00
|
|
|
|
property var sendModalPopup
|
2022-05-26 15:46:02 +00:00
|
|
|
|
|
2023-07-21 21:05:42 +00:00
|
|
|
|
property bool archiveSupporVisible: true
|
2022-03-23 15:38:23 +00:00
|
|
|
|
property bool editable: false
|
2023-07-19 05:58:21 +00:00
|
|
|
|
property bool isControlNode: false
|
2023-07-06 08:02:41 +00:00
|
|
|
|
property int loginType: Constants.LoginType.Password
|
2023-07-24 11:31:31 +00:00
|
|
|
|
property bool communitySettingsDisabled
|
2023-11-24 08:48:50 +00:00
|
|
|
|
property var ownerToken: null
|
2022-03-23 15:38:23 +00:00
|
|
|
|
|
2023-08-02 16:03:52 +00:00
|
|
|
|
property string overviewChartData: ""
|
|
|
|
|
|
2023-10-31 20:40:00 +00:00
|
|
|
|
property bool shardingEnabled
|
|
|
|
|
property int shardIndex: -1
|
|
|
|
|
property bool shardingInProgress
|
|
|
|
|
property string pubsubTopic
|
|
|
|
|
property string pubsubTopicKey
|
|
|
|
|
|
2024-05-10 15:57:06 +00:00
|
|
|
|
property bool isTokenDeployed: !!root.ownerToken && root.ownerToken.deployState === Constants.ContractTransactionStatus.Completed
|
|
|
|
|
|
2023-09-28 10:09:47 +00:00
|
|
|
|
// Community transfer ownership related props:
|
|
|
|
|
required property bool isPendingOwnershipRequest
|
2023-10-23 11:32:50 +00:00
|
|
|
|
signal finaliseOwnershipClicked
|
2023-09-26 18:04:51 +00:00
|
|
|
|
|
2022-12-07 16:14:36 +00:00
|
|
|
|
function navigateBack() {
|
2023-06-29 09:35:37 +00:00
|
|
|
|
if (editSettingsPanelLoader.item.dirty)
|
|
|
|
|
settingsDirtyToastMessage.notifyDirty()
|
|
|
|
|
else
|
|
|
|
|
root.currentIndex = 0
|
2022-09-13 16:17:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-03 20:30:34 +00:00
|
|
|
|
signal collectCommunityMetricsMessagesCount(var intervals)
|
2023-08-02 16:03:52 +00:00
|
|
|
|
|
2022-05-26 15:46:02 +00:00
|
|
|
|
signal edited(Item item) // item containing edited fields (name, description, logoImagePath, color, options, etc..)
|
2022-03-23 15:38:23 +00:00
|
|
|
|
|
2022-06-06 15:23:24 +00:00
|
|
|
|
signal inviteNewPeopleClicked
|
|
|
|
|
signal airdropTokensClicked
|
2023-07-19 05:58:21 +00:00
|
|
|
|
signal exportControlNodeClicked
|
2023-07-21 08:44:10 +00:00
|
|
|
|
signal importControlNodeClicked
|
2023-09-22 10:12:06 +00:00
|
|
|
|
signal mintOwnerTokenClicked
|
2022-06-06 15:23:24 +00:00
|
|
|
|
|
2023-10-31 20:40:00 +00:00
|
|
|
|
signal shardIndexEdited(int shardIndex)
|
|
|
|
|
|
2022-03-23 15:38:23 +00:00
|
|
|
|
clip: true
|
|
|
|
|
|
2023-07-24 11:31:31 +00:00
|
|
|
|
Component {
|
|
|
|
|
id: mainSettingsPageComp
|
|
|
|
|
ColumnLayout {
|
2022-03-23 15:38:23 +00:00
|
|
|
|
spacing: 16
|
|
|
|
|
RowLayout {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
|
|
spacing: 16
|
|
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
|
Layout.fillWidth: true
|
2023-06-30 12:25:37 +00:00
|
|
|
|
Layout.maximumWidth: 747
|
2022-03-23 15:38:23 +00:00
|
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
|
id: nameText
|
2022-08-03 20:16:43 +00:00
|
|
|
|
objectName: "communityOverviewSettingsCommunityName"
|
2022-03-23 15:38:23 +00:00
|
|
|
|
Layout.fillWidth: true
|
2023-06-30 12:25:37 +00:00
|
|
|
|
font.pixelSize: 28
|
|
|
|
|
font.bold: true
|
|
|
|
|
font.letterSpacing: -0.4
|
2022-03-23 15:38:23 +00:00
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
|
text: root.name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
|
id: descriptionText
|
2022-08-03 20:16:43 +00:00
|
|
|
|
objectName: "communityOverviewSettingsCommunityDescription"
|
2022-03-23 15:38:23 +00:00
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
|
text: root.description
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-30 12:25:37 +00:00
|
|
|
|
Item { Layout.fillWidth: true }
|
|
|
|
|
|
2023-09-14 10:02:51 +00:00
|
|
|
|
StatusButton {
|
|
|
|
|
Layout.preferredHeight: 38
|
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
|
objectName: "communityOverviewSettingsTransferOwnershipButton"
|
2023-09-22 10:12:06 +00:00
|
|
|
|
visible: root.isOwner
|
2023-09-14 10:02:51 +00:00
|
|
|
|
text: qsTr("Transfer ownership")
|
|
|
|
|
size: StatusBaseButton.Size.Small
|
|
|
|
|
|
2023-09-22 10:12:06 +00:00
|
|
|
|
onClicked: {
|
|
|
|
|
if(!!root.ownerToken && root.ownerToken.deployState === Constants.ContractTransactionStatus.Completed) {
|
2023-11-24 08:48:50 +00:00
|
|
|
|
Global.openTransferOwnershipPopup(root.communityId,
|
|
|
|
|
root.name,
|
2023-09-22 10:12:06 +00:00
|
|
|
|
root.logoImageData,
|
|
|
|
|
root.ownerToken,
|
|
|
|
|
root.sendModalPopup)
|
|
|
|
|
} else {
|
|
|
|
|
Global.openPopup(transferOwnershipAlertPopup, { mode: TransferOwnershipAlertPopup.Mode.TransferOwnership })
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-14 10:02:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-23 15:38:23 +00:00
|
|
|
|
StatusButton {
|
2023-06-30 12:25:37 +00:00
|
|
|
|
Layout.preferredHeight: 38
|
|
|
|
|
Layout.alignment: Qt.AlignTop
|
2022-08-03 20:16:43 +00:00
|
|
|
|
objectName: "communityOverviewSettingsEditCommunityButton"
|
2022-03-23 15:38:23 +00:00
|
|
|
|
visible: root.editable
|
|
|
|
|
text: qsTr("Edit Community")
|
|
|
|
|
onClicked: root.currentIndex = 1
|
2023-06-30 12:25:37 +00:00
|
|
|
|
size: StatusBaseButton.Size.Small
|
2022-03-23 15:38:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
|
|
implicitHeight: 1
|
2022-12-01 16:58:37 +00:00
|
|
|
|
color: Theme.palette.statusMenu.separatorColor
|
2022-03-23 15:38:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-14 10:34:23 +00:00
|
|
|
|
OverviewSettingsChart {
|
2023-08-02 16:03:52 +00:00
|
|
|
|
model: JSON.parse(root.overviewChartData)
|
2023-08-03 20:30:34 +00:00
|
|
|
|
onCollectCommunityMetricsMessagesCount: {
|
|
|
|
|
root.collectCommunityMetricsMessagesCount(intervals)
|
2023-08-02 16:03:52 +00:00
|
|
|
|
}
|
2023-07-14 10:34:23 +00:00
|
|
|
|
Layout.topMargin: 16
|
2022-03-23 15:38:23 +00:00
|
|
|
|
Layout.fillWidth: true
|
2023-07-14 10:34:23 +00:00
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
Layout.bottomMargin: 16
|
2023-08-02 16:03:52 +00:00
|
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
|
target: root
|
2023-08-03 20:30:34 +00:00
|
|
|
|
onCommunityIdChanged: reset()
|
2023-08-02 16:03:52 +00:00
|
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
|
}
|
2023-08-02 16:03:52 +00:00
|
|
|
|
|
2023-07-14 10:34:23 +00:00
|
|
|
|
Rectangle {
|
|
|
|
|
Layout.fillWidth: true
|
2024-04-17 13:25:45 +00:00
|
|
|
|
visible: mainSettingsPage.footer.active
|
2023-07-14 10:34:23 +00:00
|
|
|
|
implicitHeight: 1
|
|
|
|
|
color: Theme.palette.statusMenu.separatorColor
|
2022-03-23 15:38:23 +00:00
|
|
|
|
}
|
2023-07-06 08:02:41 +00:00
|
|
|
|
}
|
2023-07-24 11:31:31 +00:00
|
|
|
|
}
|
2022-06-06 15:23:24 +00:00
|
|
|
|
|
2023-07-24 11:31:31 +00:00
|
|
|
|
Component {
|
|
|
|
|
id: overviewSettingsFooterComp
|
2023-09-28 10:09:47 +00:00
|
|
|
|
|
2023-07-24 11:31:31 +00:00
|
|
|
|
OverviewSettingsFooter {
|
2023-07-06 08:02:41 +00:00
|
|
|
|
rightPadding: 64
|
|
|
|
|
leftPadding: 64
|
2023-07-14 10:34:23 +00:00
|
|
|
|
bottomPadding: 64
|
|
|
|
|
topPadding: 0
|
2023-07-06 08:02:41 +00:00
|
|
|
|
communityName: root.name
|
2023-09-28 10:09:47 +00:00
|
|
|
|
communityColor: root.color
|
2023-07-19 05:58:21 +00:00
|
|
|
|
isControlNode: root.isControlNode
|
2023-09-28 10:09:47 +00:00
|
|
|
|
isPendingOwnershipRequest: root.isPendingOwnershipRequest
|
2024-05-10 15:57:06 +00:00
|
|
|
|
isPromoteSelfToControlNodeEnabled: root.isControlNode || root.isTokenDeployed
|
2023-09-28 10:09:47 +00:00
|
|
|
|
|
2023-09-22 10:12:06 +00:00
|
|
|
|
onExportControlNodeClicked:{
|
2024-05-10 15:57:06 +00:00
|
|
|
|
if(root.isTokenDeployed) {
|
2023-09-22 10:12:06 +00:00
|
|
|
|
root.exportControlNodeClicked()
|
|
|
|
|
} else {
|
|
|
|
|
Global.openPopup(transferOwnershipAlertPopup, { mode: TransferOwnershipAlertPopup.Mode.MoveControlNode })
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-21 08:44:10 +00:00
|
|
|
|
onImportControlNodeClicked: root.importControlNodeClicked()
|
2023-10-23 11:32:50 +00:00
|
|
|
|
onFinaliseOwnershipTransferClicked: root.finaliseOwnershipClicked()
|
2024-05-10 15:57:06 +00:00
|
|
|
|
onLearnMoreClicked: Global.openLink(Constants.statusHelpLinkPrefix + "communities/about-the-control-node-in-status-communities")
|
2022-03-23 15:38:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-24 11:31:31 +00:00
|
|
|
|
Component {
|
|
|
|
|
id: disabledSettingsBannerComp
|
|
|
|
|
StatusInfoBoxPanel {
|
|
|
|
|
title: qsTr("Community administration is disabled when in testnet mode")
|
|
|
|
|
text: qsTr("To access your %1 community admin area, you need to turn off testnet mode.").arg(root.name)
|
|
|
|
|
icon: "settings"
|
|
|
|
|
iconType: StatusInfoBoxPanel.Type.Warning
|
|
|
|
|
buttonText: qsTr("Turn off testnet mode")
|
|
|
|
|
onClicked: Global.openTestnetPopup()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SettingsPage {
|
2024-04-17 13:25:45 +00:00
|
|
|
|
id: mainSettingsPage
|
2023-07-24 11:31:31 +00:00
|
|
|
|
Layout.fillWidth: !root.communitySettingsDisabled
|
|
|
|
|
Layout.preferredWidth: root.communitySettingsDisabled ? 560 + leftPadding + rightPadding : -1
|
|
|
|
|
Layout.fillHeight: !root.communitySettingsDisabled
|
|
|
|
|
rightPadding: 64
|
|
|
|
|
bottomPadding: 50
|
|
|
|
|
topPadding: 0
|
|
|
|
|
header: null
|
|
|
|
|
contentItem: Loader {
|
|
|
|
|
sourceComponent: root.communitySettingsDisabled ? disabledSettingsBannerComp : mainSettingsPageComp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
footer: Loader {
|
|
|
|
|
sourceComponent: overviewSettingsFooterComp
|
2024-04-17 13:25:45 +00:00
|
|
|
|
active: {
|
|
|
|
|
if (root.communitySettingsDisabled)
|
|
|
|
|
return false
|
|
|
|
|
if (root.isAdmin || root.isTokenMaster)
|
|
|
|
|
return root.isPendingOwnershipRequest // not allowed for admin or TM unless there's the pending request
|
|
|
|
|
return true
|
|
|
|
|
}
|
2023-07-24 11:31:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-29 09:35:37 +00:00
|
|
|
|
SettingsPage {
|
2022-03-23 15:38:23 +00:00
|
|
|
|
id: editCommunityPage
|
|
|
|
|
|
2023-06-30 14:36:46 +00:00
|
|
|
|
title: qsTr("Edit Community")
|
2023-06-29 09:35:37 +00:00
|
|
|
|
|
|
|
|
|
contentItem: Loader {
|
|
|
|
|
id: editSettingsPanelLoader
|
|
|
|
|
|
|
|
|
|
function reloadContent() {
|
|
|
|
|
active = false
|
|
|
|
|
active = true
|
2022-05-26 15:46:02 +00:00
|
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
|
|
2023-06-29 09:35:37 +00:00
|
|
|
|
sourceComponent: EditSettingsPanel {
|
|
|
|
|
id: editSettingsPanel
|
|
|
|
|
|
|
|
|
|
function isValidRect(r /*rect*/) {
|
|
|
|
|
return r.width !== 0 && r.height !== 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
readonly property bool dirty:
|
|
|
|
|
root.name != name ||
|
|
|
|
|
root.description != description ||
|
|
|
|
|
root.introMessage != introMessage ||
|
|
|
|
|
root.outroMessage != outroMessage ||
|
|
|
|
|
root.archiveSupportEnabled != options.archiveSupportEnabled ||
|
|
|
|
|
root.requestToJoinEnabled != options.requestToJoinEnabled ||
|
|
|
|
|
root.pinMessagesEnabled != options.pinMessagesEnabled ||
|
|
|
|
|
root.color != color ||
|
|
|
|
|
root.selectedTags != selectedTags ||
|
|
|
|
|
root.logoImageData != logoImageData ||
|
|
|
|
|
logoImagePath.length > 0 ||
|
|
|
|
|
isValidRect(logoCropRect) ||
|
|
|
|
|
root.bannerImageData != bannerImageData ||
|
|
|
|
|
bannerPath.length > 0 ||
|
|
|
|
|
isValidRect(bannerCropRect)
|
|
|
|
|
|
|
|
|
|
name: root.name
|
|
|
|
|
description: root.description
|
|
|
|
|
introMessage: root.introMessage
|
|
|
|
|
outroMessage: root.outroMessage
|
|
|
|
|
tags: root.tags
|
|
|
|
|
selectedTags: root.selectedTags
|
|
|
|
|
color: root.color
|
|
|
|
|
logoImageData: root.logoImageData
|
|
|
|
|
bannerImageData: root.bannerImageData
|
|
|
|
|
|
|
|
|
|
options {
|
|
|
|
|
archiveSupportEnabled: root.archiveSupportEnabled
|
2023-07-21 21:05:42 +00:00
|
|
|
|
archiveSupporVisible: root.archiveSupporVisible
|
2023-06-29 09:35:37 +00:00
|
|
|
|
requestToJoinEnabled: root.requestToJoinEnabled
|
|
|
|
|
pinMessagesEnabled: root.pinMessagesEnabled
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-31 20:40:00 +00:00
|
|
|
|
shardingEnabled: root.shardingEnabled
|
|
|
|
|
shardIndex: root.shardIndex
|
|
|
|
|
shardingInProgress: root.shardingInProgress
|
|
|
|
|
pubsubTopic: root.pubsubTopic
|
|
|
|
|
pubsubTopicKey: root.pubsubTopicKey
|
2023-09-26 18:04:51 +00:00
|
|
|
|
|
2023-06-29 09:35:37 +00:00
|
|
|
|
bottomReservedSpace:
|
|
|
|
|
Qt.size(settingsDirtyToastMessage.implicitWidth,
|
|
|
|
|
settingsDirtyToastMessage.implicitHeight +
|
|
|
|
|
settingsDirtyToastMessage.anchors.bottomMargin)
|
|
|
|
|
|
|
|
|
|
bottomReservedSpaceActive: dirty
|
|
|
|
|
|
|
|
|
|
Binding {
|
|
|
|
|
target: editSettingsPanel.flickable
|
|
|
|
|
property: "bottomMargin"
|
|
|
|
|
value: 24
|
|
|
|
|
}
|
2023-10-31 20:40:00 +00:00
|
|
|
|
|
|
|
|
|
onShardIndexEdited: root.shardIndexEdited(shardIndex)
|
2022-03-23 15:38:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-29 09:35:37 +00:00
|
|
|
|
SettingsDirtyToastMessage {
|
|
|
|
|
id: settingsDirtyToastMessage
|
|
|
|
|
|
|
|
|
|
z: 1
|
|
|
|
|
anchors {
|
|
|
|
|
bottom: parent.bottom
|
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
|
bottomMargin: 16
|
|
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
|
|
2023-06-29 09:35:37 +00:00
|
|
|
|
active: !!editSettingsPanelLoader.item &&
|
|
|
|
|
editSettingsPanelLoader.item.dirty
|
2024-04-17 13:25:45 +00:00
|
|
|
|
visible: active
|
2023-06-29 09:35:37 +00:00
|
|
|
|
|
|
|
|
|
saveChangesButtonEnabled:
|
|
|
|
|
!!editSettingsPanelLoader.item &&
|
|
|
|
|
editSettingsPanelLoader.item.saveChangesButtonEnabled
|
|
|
|
|
|
|
|
|
|
onResetChangesClicked: editSettingsPanelLoader.reloadContent()
|
|
|
|
|
|
|
|
|
|
onSaveChangesClicked: {
|
|
|
|
|
root.currentIndex = 0
|
|
|
|
|
root.edited(editSettingsPanelLoader.item)
|
|
|
|
|
editSettingsPanelLoader.reloadContent()
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
|
}
|
2023-09-22 10:12:06 +00:00
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
|
id: transferOwnershipAlertPopup
|
|
|
|
|
|
|
|
|
|
TransferOwnershipAlertPopup {
|
|
|
|
|
communityName: root.name
|
|
|
|
|
communityLogo: root.logoImageData
|
|
|
|
|
|
|
|
|
|
onMintClicked: root.mintOwnerTokenClicked()
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
|
}
|