fix(Storybook): update InviteFriendsToCommunityPopup page

This commit is contained in:
Michał Cieślak 2022-11-07 14:14:18 +01:00 committed by Michał
parent 6e705eab2a
commit c21337a02f
3 changed files with 121 additions and 72 deletions

View File

@ -18,6 +18,10 @@ Item {
{colorId: 19, segmentLength: 2}]) {colorId: 19, segmentLength: 2}])
} }
function isCompressedPubKey() {
return true
}
Component.onCompleted: { Component.onCompleted: {
Utils.globalUtilsInst = this Utils.globalUtilsInst = this
globalUtilsReady = true globalUtilsReady = true

View File

@ -13,6 +13,10 @@ Item {
return "compressed" return "compressed"
} }
function isCompressedPubKey() {
return true
}
function getColorHashAsJson(publicKey) { function getColorHashAsJson(publicKey) {
return JSON.stringify([{colorId: 0, segmentLength: 1}, return JSON.stringify([{colorId: 0, segmentLength: 1},
{colorId: 19, segmentLength: 2}]) {colorId: 19, segmentLength: 2}])

View File

@ -1,96 +1,137 @@
import QtQuick 2.14 import QtQuick 2.14
import QtQuick.Controls 2.14
import AppLayouts.Chat.popups 1.0 import AppLayouts.Chat.popups 1.0
import utils 1.0 import utils 1.0
Item { import Storybook 1.0
Rectangle {
color: 'lightgray' SplitView {
anchors.fill: parent orientation: Qt.Vertical
}
Logs { id: logs }
property bool globalUtilsReady: false property bool globalUtilsReady: false
property bool mainModuleReady: false property bool mainModuleReady: false
QtObject { Item {
function getCompressedPk(publicKey) {
return "compressed" SplitView.fillWidth: true
SplitView.fillHeight: true
Rectangle {
color: 'lightgray'
anchors.fill: parent
} }
function getColorHashAsJson(publicKey) { Button {
return JSON.stringify([{colorId: 0, segmentLength: 1},
{colorId: 19, segmentLength: 2}])
}
Component.onCompleted: {
Utils.globalUtilsInst = this
globalUtilsReady = true
}
Component.onDestruction: {
globalUtilsReady = false
Utils.globalUtilsInst = {}
}
}
QtObject {
function getContactDetailsAsJson() {
return JSON.stringify({})
}
Component.onCompleted: {
mainModuleReady = true
Utils.mainModuleInst = this
}
Component.onDestruction: {
mainModuleReady = false
Utils.mainModuleInst = {}
}
}
Loader {
active: globalUtilsReady && mainModuleReady
anchors.fill: parent
sourceComponent: InviteFriendsToCommunityPopup {
parent: parent
modal: false
anchors.centerIn: parent anchors.centerIn: parent
text: "Reopen"
community: ({ onClicked: loader.item.open()
id: "communityId", }
name: "community-name"
})
rootStore: QtObject { QtObject {
function communityHasMember(communityId, pubKey) { function getCompressedPk(publicKey) {
return false return "compressed"
}
} }
contactsStore: QtObject { function isCompressedPubKey() {
readonly property ListModel myContactsModel: ListModel { return true
Component.onCompleted: { }
for (let i = 0; i < 20; i++) {
const key = `pub_key_${i}`
append({ function getColorHashAsJson(publicKey) {
alias: "", return JSON.stringify([{colorId: 0, segmentLength: 1},
colorId: "1", {colorId: 19, segmentLength: 2}])
displayName: `contact ${i}`, }
ensName: "",
icon: "", Component.onCompleted: {
isContact: true, Utils.globalUtilsInst = this
localNickname: "", globalUtilsReady = true
onlineStatus: 1,
pubKey: key }
}) Component.onDestruction: {
globalUtilsReady = false
Utils.globalUtilsInst = {}
}
}
QtObject {
function getContactDetailsAsJson() {
return JSON.stringify({})
}
Component.onCompleted: {
mainModuleReady = true
Utils.mainModuleInst = this
}
Component.onDestruction: {
mainModuleReady = false
Utils.mainModuleInst = {}
}
}
Loader {
id: loader
active: globalUtilsReady && mainModuleReady
anchors.fill: parent
sourceComponent: InviteFriendsToCommunityPopup {
parent: parent
modal: false
anchors.centerIn: parent
community: ({
id: "communityId",
name: "community-name"
})
rootStore: QtObject {
function communityHasMember(communityId, pubKey) {
return false
}
}
communitySectionModule: QtObject {
function inviteUsersToCommunity() {
logs.logEvent("communitySectionModule::inviteUsersToCommunity",
["keys", "message"], arguments)
}
}
contactsStore: QtObject {
readonly property ListModel myContactsModel: ListModel {
Component.onCompleted: {
for (let i = 0; i < 20; i++) {
const key = `pub_key_${i}`
append({
alias: "",
colorId: "1",
displayName: `contact ${i}`,
ensName: "",
icon: "",
isContact: true,
localNickname: "",
onlineStatus: 1,
pubKey: key
})
}
} }
} }
} }
}
Component.onCompleted: open() Component.onCompleted: open()
}
} }
} }
LogsAndControlsPanel {
id: logsAndControlsPanel
SplitView.minimumHeight: 100
SplitView.preferredHeight: 200
logsView.logText: logs.logText
}
} }