chore(PermissionsSettingsPanel): welcome view moved to PermissionsView

to simplify states management

Storybook page updated to cover case when permissions model is empty.
This commit is contained in:
Michał Cieślak 2023-06-29 13:54:04 +02:00 committed by Michał
parent 3a28d3e68d
commit f363397f77
3 changed files with 57 additions and 46 deletions

View File

@ -1,5 +1,6 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import StatusQ.Core.Theme 0.1
import StatusQ.Core.Utils 0.1
@ -28,12 +29,18 @@ SplitView {
margins: 50
}
permissionsModel: ListModel {
ListModel {
id: permissionsModel
Component.onCompleted: append(PermissionsModel.permissionsModelData)
}
ListModel {
id: emptyModel
}
permissionsModel: emptyModelCheckBox.checked ? emptyModel : permissionsModel
assetsModel: AssetsModel {
id: assetsModel
}
@ -78,8 +85,24 @@ SplitView {
SplitView.minimumWidth: 300
SplitView.preferredWidth: 300
CommunityPermissionsSettingsPanelEditor {
ColumnLayout {
anchors.fill: parent
CheckBox {
id: emptyModelCheckBox
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
text: "Empty model"
}
CommunityPermissionsSettingsPanelEditor {
clip: true
visible: !emptyModelCheckBox.checked
Layout.fillWidth: true
Layout.fillHeight: true
model: permissionsModel
assetKeys: assetsModel.data.map(asset => asset.key)
@ -93,6 +116,7 @@ SplitView {
}
}
}
}
}

View File

@ -1,4 +1,4 @@
import QtQuick 2.14
import QtQuick 2.15
import AppLayouts.Communities.controls 1.0
import AppLayouts.Communities.layouts 1.0
@ -48,11 +48,9 @@ SettingsPageLayout {
QtObject {
id: d
readonly property string welcomeViewState: "WELCOME"
readonly property string newPermissionViewState: "NEW_PERMISSION"
readonly property string permissionsViewState: "PERMISSIONS"
readonly property string editPermissionViewState: "EDIT_PERMISSION"
readonly property bool permissionsExist: root.permissionsModel.count > 0
signal saveChanges
signal resetChanges
@ -64,14 +62,7 @@ SettingsPageLayout {
property var channelsToEditModel
property bool isPrivateToEditValue: false
onPermissionsExistChanged: {
// Navigate back to welcome permissions view if all existing permissions are removed.
if(root.state === d.permissionsViewState && !permissionsExist) {
root.state = d.welcomeViewState;
}
}
readonly property string initialState: d.permissionsExist ? d.permissionsViewState : d.welcomeViewState
readonly property string initialState: d.permissionsViewState
function initializeData() {
holdingsToEditModel = emptyModel
@ -86,14 +77,6 @@ SettingsPageLayout {
cancelChangesText: qsTr("Revert changes")
state: d.initialState
states: [
State {
name: d.welcomeViewState
PropertyChanges {target: root; title: qsTr("Permissions")}
PropertyChanges {target: root; previousPageName: ""}
PropertyChanges {target: root; content: welcomeView}
PropertyChanges {target: root; primaryHeaderButton.visible: true}
PropertyChanges {target: root; primaryHeaderButton.text: qsTr("Add new permission")}
},
State {
name: d.newPermissionViewState
PropertyChanges {target: root; title: qsTr("New permission")}
@ -119,7 +102,7 @@ SettingsPageLayout {
]
onPrimaryHeaderButtonClicked: {
if(root.state === d.welcomeViewState || root.state === d.permissionsViewState) {
if(root.state === d.permissionsViewState) {
d.initializeData()
root.state = d.newPermissionViewState
}
@ -139,22 +122,6 @@ SettingsPageLayout {
}
// Community Permissions possible view contents:
Component {
id: welcomeView
WelcomeSettingsView {
viewWidth: root.viewWidth
image: Style.png("community/permissions2_3")
title: qsTr("Permissions")
subtitle: qsTr("You can manage your community by creating and issuing membership and access permissions")
checkersModel: [
qsTr("Give individual members access to private channels"),
qsTr("Monetise your community with subscriptions and fees"),
qsTr("Require holding a token or NFT to obtain exclusive membership rights")
]
}
}
Component {
id: newPermissionView

View File

@ -5,8 +5,10 @@ import StatusQ.Core 0.1
import SortFilterProxyModel 0.2
import shared.popups 1.0
import utils 1.0
import AppLayouts.Communities.controls 1.0
import AppLayouts.Communities.panels 1.0
StatusScrollView {
id: root
@ -25,6 +27,8 @@ StatusScrollView {
signal duplicatePermissionRequested(int index)
signal removePermissionRequested(int index)
readonly property alias count: repeater.count
QtObject {
id: d
@ -48,7 +52,23 @@ StatusScrollView {
}
}
IntroPanel {
visible: root.count === 0
width: root.viewWidth
image: Style.png("community/permissions2_3")
title: qsTr("Permissions")
subtitle: qsTr("You can manage your community by creating and issuing membership and access permissions")
checkersModel: [
qsTr("Give individual members access to private channels"),
qsTr("Monetise your community with subscriptions and fees"),
qsTr("Require holding a token or NFT to obtain exclusive membership rights")
]
}
Repeater {
id: repeater
model: root.permissionsModel
delegate: PermissionItem {