fix(CommunitySettingsView): hide control node functionality for admins and token masters

- hide the footer when the user is an admin or token master, unless
there is a pending ownership request (`isPendingOwnershipRequest`)
- similarly, hide the sharding section in `CommunityInfoEditor`
- do not cover the shard button with the `SettingsDirtyToastMessage`
- some SB page cleanups and additions
This commit is contained in:
Lukáš Tinkl 2024-04-17 15:25:45 +02:00 committed by Lukáš Tinkl
parent 559f94a706
commit 6260519e66
7 changed files with 61 additions and 31 deletions

View File

@ -20,7 +20,7 @@ ColumnLayout {
readonly property bool shardingEnabled: ctrlShardingEnabled.checked readonly property bool shardingEnabled: ctrlShardingEnabled.checked
property alias shardIndex: ctrlShardIndex.value property alias shardIndex: ctrlShardIndex.value
spacing: 24 spacing: 12
ColumnLayout { ColumnLayout {
Label { Label {

View File

@ -44,24 +44,19 @@ SplitView {
SplitView.preferredHeight: 150 SplitView.preferredHeight: 150
logsView.logText: logs.logText logsView.logText: logs.logText
}
}
Pane { ColumnLayout {
SplitView.preferredWidth: 300 Switch {
SplitView.fillHeight: true id: controlNodeSwitch
text: "Control node on/off"
checked: true
}
ColumnLayout { Switch {
Switch { id: pendingOwnershipSwitch
id: controlNodeSwitch text: "Is there a pending transfer ownership request?"
text: "Control node on/off" checked: true
checked: true }
}
Switch {
id: pendingOwnershipSwitch
text: "Is there a pending transfer ownership request?"
checked: true
} }
} }
} }

View File

@ -2,12 +2,19 @@ import QtQuick 2.14
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import mainui 1.0
import AppLayouts.Communities.panels 1.0 import AppLayouts.Communities.panels 1.0
SplitView { SplitView {
id: root id: root
SplitView.fillWidth: true SplitView.fillWidth: true
Popups {
popupParent: root
rootStore: QtObject {}
communityTokensStore: QtObject {}
}
OverviewSettingsPanel { OverviewSettingsPanel {
SplitView.fillWidth: true SplitView.fillWidth: true
SplitView.fillHeight: true SplitView.fillHeight: true
@ -18,8 +25,11 @@ SplitView {
color: communityEditor.color color: communityEditor.color
bannerImageData: communityEditor.banner bannerImageData: communityEditor.banner
editable: communityEditor.isCommunityEditable
isOwner: communityEditor.amISectionAdmin isOwner: communityEditor.amISectionAdmin
isAdmin: ctrlIsAdmin.checked
isTokenMaster: ctrlIsTM.checked
editable: communityEditor.isCommunityEditable
communitySettingsDisabled: !editable communitySettingsDisabled: !editable
shardingEnabled: communityEditor.shardingEnabled shardingEnabled: communityEditor.shardingEnabled
@ -32,16 +42,27 @@ SplitView {
SplitView.minimumWidth: 300 SplitView.minimumWidth: 300
SplitView.preferredWidth: 300 SplitView.preferredWidth: 300
ColumnLayout { ScrollView {
CommunityInfoEditor{ anchors.fill: parent
id: communityEditor contentWidth: availableWidth
anchors.fill: parent
}
Switch { CommunityInfoEditor {
id: pendingOwnershipSwitch id: communityEditor
text: "Is there a pending transfer ownership request?"
checked: true Switch {
id: pendingOwnershipSwitch
text: "Pending transfer ownership request?"
}
Switch {
id: ctrlIsAdmin
text: "Is admin?"
}
Switch {
id: ctrlIsTM
text: "Is token master?"
}
} }
} }
} }

View File

@ -22,6 +22,9 @@ StackLayout {
id: root id: root
required property bool isOwner required property bool isOwner
required property bool isAdmin
required property bool isTokenMaster
property string communityId property string communityId
property string name property string name
property string description property string description
@ -176,7 +179,7 @@ StackLayout {
Rectangle { Rectangle {
Layout.fillWidth: true Layout.fillWidth: true
visible: mainSettingsPage.footer.active
implicitHeight: 1 implicitHeight: 1
color: Theme.palette.statusMenu.separatorColor color: Theme.palette.statusMenu.separatorColor
} }
@ -223,6 +226,7 @@ StackLayout {
} }
SettingsPage { SettingsPage {
id: mainSettingsPage
Layout.fillWidth: !root.communitySettingsDisabled Layout.fillWidth: !root.communitySettingsDisabled
Layout.preferredWidth: root.communitySettingsDisabled ? 560 + leftPadding + rightPadding : -1 Layout.preferredWidth: root.communitySettingsDisabled ? 560 + leftPadding + rightPadding : -1
Layout.fillHeight: !root.communitySettingsDisabled Layout.fillHeight: !root.communitySettingsDisabled
@ -236,7 +240,13 @@ StackLayout {
footer: Loader { footer: Loader {
sourceComponent: overviewSettingsFooterComp sourceComponent: overviewSettingsFooterComp
active: !root.communitySettingsDisabled 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
}
} }
} }
@ -329,6 +339,7 @@ StackLayout {
active: !!editSettingsPanelLoader.item && active: !!editSettingsPanelLoader.item &&
editSettingsPanelLoader.item.dirty editSettingsPanelLoader.item.dirty
visible: active
saveChangesButtonEnabled: saveChangesButtonEnabled:
!!editSettingsPanelLoader.item && !!editSettingsPanelLoader.item &&

View File

@ -82,6 +82,7 @@ StatusDialog {
ConfirmationDialog { ConfirmationDialog {
id: confirmationPopup id: confirmationPopup
width: root.width - root.margins
anchors.centerIn: parent anchors.centerIn: parent
headerSettings.title: qsTr("Are you sure you want to disable sharding?") headerSettings.title: qsTr("Are you sure you want to disable sharding?")
showCancelButton: true showCancelButton: true

View File

@ -168,6 +168,8 @@ StatusSectionLayout {
readonly property bool sectionEnabled: true readonly property bool sectionEnabled: true
isOwner: root.isOwner isOwner: root.isOwner
isAdmin: root.isAdmin
isTokenMaster: root.isTokenMasterOwner
communityId: root.community.id communityId: root.community.id
name: root.community.name name: root.community.name
description: root.community.description description: root.community.description
@ -187,7 +189,7 @@ StatusSectionLayout {
isControlNode: root.isControlNode isControlNode: root.isControlNode
communitySettingsDisabled: root.communitySettingsDisabled communitySettingsDisabled: root.communitySettingsDisabled
overviewChartData: rootStore.overviewChartData overviewChartData: rootStore.overviewChartData
shardingEnabled: localAppSettings.wakuV2ShardedCommunitiesEnabled ?? false shardingEnabled: !isAdmin && !isTokenMaster && localAppSettings.wakuV2ShardedCommunitiesEnabled
shardIndex: root.community.shardIndex shardIndex: root.community.shardIndex
shardingInProgress: root.chatCommunitySectionModule.shardingInProgress shardingInProgress: root.chatCommunitySectionModule.shardingInProgress
pubsubTopic: root.community.pubsubTopic pubsubTopic: root.community.pubsubTopic