Skip to content

Commit

Permalink
chore(CommunityPermissions): Adjust behavior of 'Hide permission' swi…
Browse files Browse the repository at this point in the history
…tch depending on selected permission

Closes: #9050
  • Loading branch information
micieslak committed Jan 26, 2023
1 parent 5c3b988 commit 63a0f51
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 97 deletions.
87 changes: 56 additions & 31 deletions storybook/pages/CommunityNewPermissionViewPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
119 changes: 59 additions & 60 deletions storybook/pages/CommunityPermissionsSettingsPanelPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -95,7 +95,7 @@ StatusDropdown {
checked: d.initialPermissionType === permissionType
buttonGroup: group

enabled: !root.disableAdminPermission
enabled: root.enableAdminPermission

Layout.fillWidth: true
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -431,7 +443,7 @@ StatusScrollView {
id: permissionsDropdown

initialPermissionType: d.permissionType
disableAdminPermission: !root.store.isOwner
enableAdminPermission: root.store.isOwner

onDone: {
if (d.permissionType === permissionType) {
Expand Down Expand Up @@ -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
Expand All @@ -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)
}
Expand Down

0 comments on commit 63a0f51

Please sign in to comment.