From 63a0f513052c141dff8c8eeb594d9824d562dbfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blak?= Date: Fri, 20 Jan 2023 12:22:04 +0100 Subject: [PATCH] chore(CommunityPermissions): Adjust behavior of 'Hide permission' switch depending on selected permission Closes: #9050 --- .../pages/CommunityNewPermissionViewPage.qml | 87 ++++++++----- .../CommunityPermissionsSettingsPanelPage.qml | 119 +++++++++--------- .../community/PermissionsDropdown.qml | 6 +- .../CommunityNewPermissionView.qml | 19 ++- 4 files changed, 134 insertions(+), 97 deletions(-) diff --git a/storybook/pages/CommunityNewPermissionViewPage.qml b/storybook/pages/CommunityNewPermissionViewPage.qml index 621ef73cb04..9f6dda00543 100644 --- a/storybook/pages/CommunityNewPermissionViewPage.qml +++ b/storybook/pages/CommunityNewPermissionViewPage.qml @@ -4,51 +4,76 @@ import QtQuick.Controls 2.14 import AppLayouts.Chat.views.communities 1.0 import AppLayouts.Chat.stores 1.0 +import Storybook 1.0 import Models 1.0 -Pane { - id: root +SplitView { + orientation: Qt.Vertical + SplitView.fillWidth: true - CommunityNewPermissionView { + Logs { id: logs } - store: CommunitiesStore { - readonly property var assetsModel: AssetsModel {} - readonly property var collectiblesModel: CollectiblesModel {} - readonly property var channelsModel: ChannelsModel {} - readonly property var permissionConflict: QtObject { - property bool exists: true - property string holdings: "1 ETH" - property string permissions: "View and Post" - property string channels: "#general" + Pane { + id: root - } + CommunityNewPermissionView { - function editPermission(index, holdings, permissions, channels, isPrivate) { - logs.logEvent("CommunitiesStore::editPermission - index: " + index) - } + store: CommunitiesStore { + readonly property var assetsModel: AssetsModel {} + readonly property var collectiblesModel: CollectiblesModel {} + readonly property var channelsModel: ChannelsModel {} + readonly property var permissionConflict: QtObject { + property bool exists: true + property string holdings: "1 ETH" + property string permissions: "View and Post" + property string channels: "#general" - function duplicatePermission(index) { - logs.logEvent("CommunitiesStore::duplicatePermission - index: " + index) - } + } - function removePermission(index) { - logs.logEvent("CommunitiesStore::removePermission - index: " + index) - } - } + readonly property bool isOwner: isOwnerCheckBox.checked + + function editPermission(index, holdings, permissions, channels, isPrivate) { + logs.logEvent("CommunitiesStore::editPermission - index: " + index) + } + + function duplicatePermission(index) { + logs.logEvent("CommunitiesStore::duplicatePermission - index: " + index) + } - rootStore: QtObject { - readonly property QtObject chatCommunitySectionModule: QtObject { - readonly property var model: ChannelsModel {} + function removePermission(index) { + logs.logEvent("CommunitiesStore::removePermission - index: " + index) + } } - readonly property QtObject mainModuleInst: QtObject { + rootStore: QtObject { + readonly property QtObject chatCommunitySectionModule: QtObject { + readonly property var model: ChannelsModel {} + } + + readonly property QtObject mainModuleInst: QtObject { - readonly property QtObject activeSection: QtObject { - readonly property string name: "Socks" - readonly property string image: ModelsData.icons.socks - readonly property color color: "red" + readonly property QtObject activeSection: QtObject { + readonly property string name: "Socks" + readonly property string image: ModelsData.icons.socks + readonly property color color: "red" + } } } } } + + LogsAndControlsPanel { + id: logsAndControlsPanel + + SplitView.minimumHeight: 100 + SplitView.preferredHeight: 150 + + logsView.logText: logs.logText + + CheckBox { + id: isOwnerCheckBox + + text: "Is owner" + } + } } diff --git a/storybook/pages/CommunityPermissionsSettingsPanelPage.qml b/storybook/pages/CommunityPermissionsSettingsPanelPage.qml index de60e9b3a32..894c4cbf018 100644 --- a/storybook/pages/CommunityPermissionsSettingsPanelPage.qml +++ b/storybook/pages/CommunityPermissionsSettingsPanelPage.qml @@ -8,86 +8,85 @@ import StatusQ.Core.Theme 0.1 import Storybook 1.0 import Models 1.0 + SplitView { + orientation: Qt.Vertical + SplitView.fillWidth: true + Logs { id: logs } - SplitView { - orientation: Qt.Vertical + Rectangle { SplitView.fillWidth: true - - Rectangle { - SplitView.fillWidth: true - SplitView.fillHeight: true - color: Theme.palette.statusAppLayout.rightPanelBackgroundColor - CommunityPermissionsSettingsPanel { - anchors { - fill: parent - topMargin: 50 - } - store: CommunitiesStore { - readonly property bool isOwner: isOwnerCheckBox.checked - - assetsModel: AssetsModel {} - collectiblesModel: CollectiblesModel {} - channelsModel: ListModel { - Component.onCompleted: { - append([ - { - key: "welcome", - iconSource: ModelsData.assets.inch, - name: "#welcome" - }, - { - key: "general", - iconSource: ModelsData.assets.inch, - name: "#general" - } - ]) - } + SplitView.fillHeight: true + color: Theme.palette.statusAppLayout.rightPanelBackgroundColor + CommunityPermissionsSettingsPanel { + anchors { + fill: parent + topMargin: 50 + } + store: CommunitiesStore { + readonly property bool isOwner: isOwnerCheckBox.checked + + assetsModel: AssetsModel {} + collectiblesModel: CollectiblesModel {} + channelsModel: ListModel { + Component.onCompleted: { + append([ + { + key: "welcome", + iconSource: ModelsData.assets.inch, + name: "#welcome" + }, + { + key: "general", + iconSource: ModelsData.assets.inch, + name: "#general" + } + ]) } + } - function editPermission(index, holdings, permissions, channels, isPrivate) { - logs.logEvent("CommunitiesStore::editPermission - index: " + index) - } + function editPermission(index, holdings, permissions, channels, isPrivate) { + logs.logEvent("CommunitiesStore::editPermission - index: " + index) + } - function duplicatePermission(index) { - logs.logEvent("CommunitiesStore::duplicatePermission - index: " + index) - } + function duplicatePermission(index) { + logs.logEvent("CommunitiesStore::duplicatePermission - index: " + index) + } - function removePermission(index) { - logs.logEvent("CommunitiesStore::removePermission - index: " + index) - } + function removePermission(index) { + logs.logEvent("CommunitiesStore::removePermission - index: " + index) } + } - rootStore: QtObject { - readonly property QtObject chatCommunitySectionModule: QtObject { - readonly property var model: ChannelsModel {} - } + rootStore: QtObject { + readonly property QtObject chatCommunitySectionModule: QtObject { + readonly property var model: ChannelsModel {} + } - readonly property QtObject mainModuleInst: QtObject { - readonly property QtObject activeSection: QtObject { - readonly property string name: "Socks" - readonly property string image: ModelsData.icons.socks - readonly property color color: "red" - } + readonly property QtObject mainModuleInst: QtObject { + readonly property QtObject activeSection: QtObject { + readonly property string name: "Socks" + readonly property string image: ModelsData.icons.socks + readonly property color color: "red" } } } } + } - LogsAndControlsPanel { - id: logsAndControlsPanel + LogsAndControlsPanel { + id: logsAndControlsPanel - SplitView.minimumHeight: 100 - SplitView.preferredHeight: 150 + SplitView.minimumHeight: 100 + SplitView.preferredHeight: 150 - logsView.logText: logs.logText + logsView.logText: logs.logText - CheckBox { - id: isOwnerCheckBox + CheckBox { + id: isOwnerCheckBox - text: "Is owner" - } + text: "Is owner" } } } diff --git a/ui/app/AppLayouts/Chat/controls/community/PermissionsDropdown.qml b/ui/app/AppLayouts/Chat/controls/community/PermissionsDropdown.qml index 016d07002fa..742442c3248 100644 --- a/ui/app/AppLayouts/Chat/controls/community/PermissionsDropdown.qml +++ b/ui/app/AppLayouts/Chat/controls/community/PermissionsDropdown.qml @@ -15,7 +15,7 @@ StatusDropdown { property int mode: PermissionsDropdown.Mode.Add property int initialPermissionType: PermissionTypes.Type.None - property bool disableAdminPermission: false + property bool enableAdminPermission: true enum Mode { Add, Update @@ -95,7 +95,7 @@ StatusDropdown { checked: d.initialPermissionType === permissionType buttonGroup: group - enabled: !root.disableAdminPermission + enabled: root.enableAdminPermission Layout.fillWidth: true } @@ -160,7 +160,7 @@ StatusDropdown { readonly property string description: qsTr("Members who meet the requirements will be allowed to read the selected channels") - title: qsTr("Read") + title: qsTr("View only") asset.name: "show" checked: d.initialPermissionType === permissionType buttonGroup: group diff --git a/ui/app/AppLayouts/Chat/views/communities/CommunityNewPermissionView.qml b/ui/app/AppLayouts/Chat/views/communities/CommunityNewPermissionView.qml index 8cf52f7bfa9..e54425f5a5d 100644 --- a/ui/app/AppLayouts/Chat/views/communities/CommunityNewPermissionView.qml +++ b/ui/app/AppLayouts/Chat/views/communities/CommunityNewPermissionView.qml @@ -81,6 +81,18 @@ StatusScrollView { permissionType === PermissionTypes.Type.Admin || permissionType === PermissionTypes.Type.Member + onPermissionTypeChanged: { + if (permissionType === PermissionTypes.Type.Admin) { + d.dirtyValues.isPrivateDirty = (root.isPrivate === false) + } else { + if (permissionType === PermissionTypes.Type.Moderator) { + d.dirtyValues.isPrivateDirty = (root.isPrivate === false) + } else { + d.dirtyValues.isPrivateDirty = (root.isPrivate === true) + } + } + } + onIsCommunityPermissionChanged: { if (isCommunityPermission) { inModelChannels.clear() @@ -431,7 +443,7 @@ StatusScrollView { id: permissionsDropdown initialPermissionType: d.permissionType - disableAdminPermission: !root.store.isOwner + enableAdminPermission: root.store.isOwner onDone: { if (d.permissionType === permissionType) { @@ -594,14 +606,14 @@ StatusScrollView { ColumnLayout { Layout.fillWidth: true StatusBaseText { - text: qsTr("Private") + text: qsTr("Hide permission") color: Theme.palette.directColor1 font.pixelSize: 15 } StatusBaseText { Layout.fillWidth: true Layout.fillHeight: true - text: qsTr("Make this permission private to hide it from members who don’t meet it’s requirements") + text: qsTr("Make this permission hidden from members who don’t meet it’s requirements") color: Theme.palette.baseColor1 font.pixelSize: 15 lineHeight: 1.2 @@ -611,6 +623,7 @@ StatusScrollView { } } StatusSwitch { + enabled: d.permissionType !== PermissionTypes.Type.Admin checked: d.dirtyValues.isPrivateDirty ? !root.isPrivate : root.isPrivate onToggled: d.dirtyValues.isPrivateDirty = (root.isPrivate !== checked) }