chore(CommunityPermissions): Dissect real and mocked CommunitiesStore, adapt Storybook's pages
Closes: #9612
This commit is contained in:
parent
9693e19ba5
commit
44a13eedfc
|
@ -5,6 +5,7 @@ import QtQuick.Layouts 1.14
|
||||||
import AppLayouts.Chat.panels.communities 1.0
|
import AppLayouts.Chat.panels.communities 1.0
|
||||||
import AppLayouts.Chat.stores 1.0
|
import AppLayouts.Chat.stores 1.0
|
||||||
import StatusQ.Core.Theme 0.1
|
import StatusQ.Core.Theme 0.1
|
||||||
|
import StatusQ.Core.Utils 0.1
|
||||||
|
|
||||||
import Storybook 1.0
|
import Storybook 1.0
|
||||||
import Models 1.0
|
import Models 1.0
|
||||||
|
@ -31,9 +32,18 @@ SplitView {
|
||||||
store: CommunitiesStore {
|
store: CommunitiesStore {
|
||||||
readonly property bool isOwner: isOwnerCheckBox.checked
|
readonly property bool isOwner: isOwnerCheckBox.checked
|
||||||
|
|
||||||
assetsModel: AssetsModel {}
|
property var permissionConflict: QtObject { // Backend conflicts object model assignment. Now mocked data.
|
||||||
collectiblesModel: CollectiblesModel {}
|
property bool exists: false
|
||||||
channelsModel: ListModel {
|
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: {
|
Component.onCompleted: {
|
||||||
append([
|
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 {
|
rootStore: QtObject {
|
||||||
|
|
|
@ -31,7 +31,8 @@ SplitView {
|
||||||
store: CommunitiesStore {
|
store: CommunitiesStore {
|
||||||
id: mockedCommunity
|
id: mockedCommunity
|
||||||
|
|
||||||
permissionsModel: PermissionsModel.permissionsModel
|
readonly property var permissionsModel:
|
||||||
|
PermissionsModel.permissionsModel
|
||||||
|
|
||||||
readonly property var assetsModel: AssetsModel {
|
readonly property var assetsModel: AssetsModel {
|
||||||
id: assetsModel
|
id: assetsModel
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
import QtQuick 2.15
|
||||||
|
|
||||||
|
QtObject {}
|
|
@ -0,0 +1,3 @@
|
||||||
|
import QtQuick 2.15
|
||||||
|
|
||||||
|
QtObject {}
|
|
@ -0,0 +1,3 @@
|
||||||
|
import QtQuick 2.15
|
||||||
|
|
||||||
|
QtObject {}
|
|
@ -0,0 +1,3 @@
|
||||||
|
CommunitiesStore 1.0 CommunitiesStore.qml
|
||||||
|
RootStore 1.0 RootStore.qml
|
||||||
|
StickersStore 1.0 StickersStore.qml
|
|
@ -3,7 +3,7 @@ import QtQuick 2.15
|
||||||
import StatusQ.Core 0.1
|
import StatusQ.Core 0.1
|
||||||
|
|
||||||
import utils 1.0
|
import utils 1.0
|
||||||
import "../../../app/AppLayouts/Profile/stores"
|
import AppLayouts.Profile.stores 1.0
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: root
|
id: root
|
||||||
|
|
Loading…
Reference in New Issue