chore(CommunityPermissions): Dissect real and mocked CommunitiesStore, adapt Storybook's pages

Closes: #9612
This commit is contained in:
Michał Cieślak 2023-02-22 18:44:04 +01:00 committed by Michał
parent 9693e19ba5
commit 44a13eedfc
7 changed files with 66 additions and 5 deletions

View File

@ -5,6 +5,7 @@ import QtQuick.Layouts 1.14
import AppLayouts.Chat.panels.communities 1.0
import AppLayouts.Chat.stores 1.0
import StatusQ.Core.Theme 0.1
import StatusQ.Core.Utils 0.1
import Storybook 1.0
import Models 1.0
@ -31,9 +32,18 @@ SplitView {
store: CommunitiesStore {
readonly property bool isOwner: isOwnerCheckBox.checked
assetsModel: AssetsModel {}
collectiblesModel: CollectiblesModel {}
channelsModel: ListModel {
property var permissionConflict: QtObject { // Backend conflicts object model assignment. Now mocked data.
property bool exists: false
property string holdings: qsTr("1 ETH")
property string permissions: qsTr("View and Post")
property string channels: qsTr("#general")
}
readonly property var permissionsModel: ListModel {}
readonly property var assetsModel: AssetsModel {}
readonly property var collectiblesModel: CollectiblesModel {}
readonly property var channelsModel: ListModel {
Component.onCompleted: {
append([
{
@ -49,6 +59,44 @@ SplitView {
])
}
}
readonly property QtObject _d: QtObject {
id: d
property int keyCounter: 0
function createPermissionEntry(holdings, permissionType, isPrivate, channels) {
const permission = {
holdingsListModel: holdings,
channelsListModel: channels,
permissionType,
isPrivate
}
return permission
}
}
function createPermission(holdings, permissionType, isPrivate, channels, index = null) {
const permissionEntry = d.createPermissionEntry(
holdings, permissionType, isPrivate, channels)
permissionEntry.key = "" + d.keyCounter++
permissionsModel.append(permissionEntry)
}
function editPermission(key, holdings, permissionType, channels, isPrivate) {
const permissionEntry = d.createPermissionEntry(
holdings, permissionType, isPrivate, channels)
const index = ModelUtils.indexOf(permissionsModel, "key", key)
permissionsModel.set(index, permissionEntry)
}
function removePermission(key) {
const index = ModelUtils.indexOf(permissionsModel, "key", key)
permissionsModel.remove(index)
}
}
rootStore: QtObject {

View File

@ -31,7 +31,8 @@ SplitView {
store: CommunitiesStore {
id: mockedCommunity
permissionsModel: PermissionsModel.permissionsModel
readonly property var permissionsModel:
PermissionsModel.permissionsModel
readonly property var assetsModel: AssetsModel {
id: assetsModel

View File

@ -0,0 +1,3 @@
import QtQuick 2.15
QtObject {}

View File

@ -0,0 +1,3 @@
import QtQuick 2.15
QtObject {}

View File

@ -0,0 +1,3 @@
import QtQuick 2.15
QtObject {}

View File

@ -0,0 +1,3 @@
CommunitiesStore 1.0 CommunitiesStore.qml
RootStore 1.0 RootStore.qml
StickersStore 1.0 StickersStore.qml

View File

@ -3,7 +3,7 @@ import QtQuick 2.15
import StatusQ.Core 0.1
import utils 1.0
import "../../../app/AppLayouts/Profile/stores"
import AppLayouts.Profile.stores 1.0
QtObject {
id: root