From 44a13eedfc72faeb0127e8737ddbc8393760ca93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blak?= Date: Wed, 22 Feb 2023 18:44:04 +0100 Subject: [PATCH] chore(CommunityPermissions): Dissect real and mocked CommunitiesStore, adapt Storybook's pages Closes: #9612 --- .../CommunityPermissionsSettingsPanelPage.qml | 54 +++++++++++++++++-- .../pages/CommunityPermissionsViewPage.qml | 3 +- .../Chat/stores/CommunitiesStore.qml | 3 ++ .../AppLayouts/Chat/stores/RootStore.qml | 3 ++ .../AppLayouts/Chat/stores/StickersStore.qml | 3 ++ storybook/stubs/AppLayouts/Chat/stores/qmldir | 3 ++ ui/imports/shared/stores/CurrenciesStore.qml | 2 +- 7 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 storybook/stubs/AppLayouts/Chat/stores/CommunitiesStore.qml create mode 100644 storybook/stubs/AppLayouts/Chat/stores/RootStore.qml create mode 100644 storybook/stubs/AppLayouts/Chat/stores/StickersStore.qml create mode 100644 storybook/stubs/AppLayouts/Chat/stores/qmldir diff --git a/storybook/pages/CommunityPermissionsSettingsPanelPage.qml b/storybook/pages/CommunityPermissionsSettingsPanelPage.qml index 1fbf82fb09..427bba0292 100644 --- a/storybook/pages/CommunityPermissionsSettingsPanelPage.qml +++ b/storybook/pages/CommunityPermissionsSettingsPanelPage.qml @@ -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 { diff --git a/storybook/pages/CommunityPermissionsViewPage.qml b/storybook/pages/CommunityPermissionsViewPage.qml index ff4335cf00..07ddaa0d96 100644 --- a/storybook/pages/CommunityPermissionsViewPage.qml +++ b/storybook/pages/CommunityPermissionsViewPage.qml @@ -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 diff --git a/storybook/stubs/AppLayouts/Chat/stores/CommunitiesStore.qml b/storybook/stubs/AppLayouts/Chat/stores/CommunitiesStore.qml new file mode 100644 index 0000000000..c1b71cdad1 --- /dev/null +++ b/storybook/stubs/AppLayouts/Chat/stores/CommunitiesStore.qml @@ -0,0 +1,3 @@ +import QtQuick 2.15 + +QtObject {} diff --git a/storybook/stubs/AppLayouts/Chat/stores/RootStore.qml b/storybook/stubs/AppLayouts/Chat/stores/RootStore.qml new file mode 100644 index 0000000000..c1b71cdad1 --- /dev/null +++ b/storybook/stubs/AppLayouts/Chat/stores/RootStore.qml @@ -0,0 +1,3 @@ +import QtQuick 2.15 + +QtObject {} diff --git a/storybook/stubs/AppLayouts/Chat/stores/StickersStore.qml b/storybook/stubs/AppLayouts/Chat/stores/StickersStore.qml new file mode 100644 index 0000000000..c1b71cdad1 --- /dev/null +++ b/storybook/stubs/AppLayouts/Chat/stores/StickersStore.qml @@ -0,0 +1,3 @@ +import QtQuick 2.15 + +QtObject {} diff --git a/storybook/stubs/AppLayouts/Chat/stores/qmldir b/storybook/stubs/AppLayouts/Chat/stores/qmldir new file mode 100644 index 0000000000..340194c3f7 --- /dev/null +++ b/storybook/stubs/AppLayouts/Chat/stores/qmldir @@ -0,0 +1,3 @@ +CommunitiesStore 1.0 CommunitiesStore.qml +RootStore 1.0 RootStore.qml +StickersStore 1.0 StickersStore.qml diff --git a/ui/imports/shared/stores/CurrenciesStore.qml b/ui/imports/shared/stores/CurrenciesStore.qml index e8c81631de..adf31c23d8 100644 --- a/ui/imports/shared/stores/CurrenciesStore.qml +++ b/ui/imports/shared/stores/CurrenciesStore.qml @@ -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