From fe5abb60dae2d8947fd060540c54352979afaf13 Mon Sep 17 00:00:00 2001 From: Noelia Date: Tue, 14 Feb 2023 17:33:23 +0100 Subject: [PATCH] feat(TokensPermissionsPoupup): Created new popup - Created new dialog. - Created storybook page for that. - Model properties renames. Closes #9433 --- storybook/PagesModel.qml | 4 ++ .../CommunityTokenPermissionsPopupPage.qml | 56 ++++++++++++++++++ .../pages/JoinCommunityPermissionsEditor.qml | 38 +++++++------ storybook/pages/JoinCommunityViewPage.qml | 24 ++++---- .../pages/JoinPermissionsOverlayPanelPage.qml | 24 ++++---- .../JoinPermissionsOverlayPanel.qml | 29 +++++----- .../CommunityTokenPermissionsPopup.qml | 57 +++++++++++++++++++ .../AppLayouts/Chat/popups/community/qmldir | 1 + .../Chat/stores/CommunitiesStore.qml | 2 +- .../views/communities/JoinCommunityView.qml | 16 +++--- 10 files changed, 188 insertions(+), 63 deletions(-) create mode 100644 storybook/pages/CommunityTokenPermissionsPopupPage.qml create mode 100644 ui/app/AppLayouts/Chat/popups/community/CommunityTokenPermissionsPopup.qml diff --git a/storybook/PagesModel.qml b/storybook/PagesModel.qml index 88bbb0c0a8..d6e83ba645 100644 --- a/storybook/PagesModel.qml +++ b/storybook/PagesModel.qml @@ -93,6 +93,10 @@ ListModel { title: "CommunityIntroDialog" section: "Popups" } + ListElement { + title: "CommunityTokenPermissionsPopup" + section: "Popups" + } ListElement { title: "MembersSelector" section: "Components" diff --git a/storybook/pages/CommunityTokenPermissionsPopupPage.qml b/storybook/pages/CommunityTokenPermissionsPopupPage.qml new file mode 100644 index 0000000000..d29c816ff0 --- /dev/null +++ b/storybook/pages/CommunityTokenPermissionsPopupPage.qml @@ -0,0 +1,56 @@ +import QtQuick 2.14 +import QtQuick.Controls 2.14 +import QtQuick.Layouts 1.14 + +import Storybook 1.0 +import Models 1.0 + +import AppLayouts.Chat.popups.community 1.0 + +SplitView { + SplitView { + orientation: Qt.Vertical + SplitView.fillWidth: true + + Item { + SplitView.fillWidth: true + SplitView.fillHeight: true + + PopupBackground { + anchors.fill: parent + } + + Button { + anchors.centerIn: parent + text: "Reopen" + + onClicked: dialog.open() + } + + CommunityTokenPermissionsPopup { + id: dialog + + anchors.centerIn: parent + channelName: editor.channelName + viewOnlyHoldingsModel: editor.viewOnlyHoldingsModel + viewAndPostHoldingsModel: editor.viewAndPostHoldingsModel + moderateHoldingsModel: editor.moderateHoldingsModel + } + } + } + + Pane { + SplitView.minimumWidth: 300 + SplitView.preferredWidth: 300 + + JoinCommunityPermissionsEditor { + id: editor + + isOnlyChannelPanelEditor: true + channelName: "#vip" + joinCommunity: false + } + } +} + + diff --git a/storybook/pages/JoinCommunityPermissionsEditor.qml b/storybook/pages/JoinCommunityPermissionsEditor.qml index 8fdad85368..ca7b5c4c59 100644 --- a/storybook/pages/JoinCommunityPermissionsEditor.qml +++ b/storybook/pages/JoinCommunityPermissionsEditor.qml @@ -9,20 +9,22 @@ import utils 1.0 ColumnLayout { id: root + property bool isOnlyChannelPanelEditor: false property string channelName: "#vip" property bool joinCommunity: true // Otherwise, enter channel property bool requirementsMet: true property bool isInvitationPending: false property bool isJoinRequestRejected: false property bool requiresRequest: false - property var communityHoldings: PermissionsModel.shortPermissionsModel - property var viewOnlyHoldings: PermissionsModel.shortPermissionsModel - property var viewAndPostHoldings: PermissionsModel.shortPermissionsModel - property var moderateHoldings: PermissionsModel.shortPermissionsModel + property var communityHoldingsModel: PermissionsModel.shortPermissionsModel + property var viewOnlyHoldingsModel: PermissionsModel.shortPermissionsModel + property var viewAndPostHoldingsModel: PermissionsModel.shortPermissionsModel + property var moderateHoldingsModel: PermissionsModel.shortPermissionsModel spacing: 16 ColumnLayout { + visible: !isOnlyChannelPanelEditor Label { Layout.fillWidth: true text: "View type:" @@ -33,6 +35,7 @@ ColumnLayout { text: "Join community" onCheckedChanged: if(checked) d.joinCommunity = true } + RadioButton { text: "Enter channel" onCheckedChanged: if(checked) d.joinCommunity = false @@ -40,6 +43,7 @@ ColumnLayout { } ColumnLayout { + visible: !isOnlyChannelPanelEditor Label { Layout.fillWidth: true text: "Requirements met:" @@ -52,6 +56,7 @@ ColumnLayout { } ColumnLayout { + visible: !isOnlyChannelPanelEditor Label { Layout.fillWidth: true text: "Request pending:" @@ -64,6 +69,7 @@ ColumnLayout { } ColumnLayout { + visible: !isOnlyChannelPanelEditor Label { Layout.fillWidth: true text: "Request rejected:" @@ -76,7 +82,7 @@ ColumnLayout { } ColumnLayout { - visible: root.joinCommunity + visible: !isOnlyChannelPanelEditor && root.joinCommunity Label { Layout.fillWidth: true text: "Requires request:" @@ -98,12 +104,12 @@ ColumnLayout { RadioButton { checked: true text: "Short model" - onCheckedChanged: if(checked) root.communityHoldings = PermissionsModel.shortPermissionsModel + onCheckedChanged: if(checked) root.communityHoldingsModel = PermissionsModel.shortPermissionsModel } RadioButton { text: "Long model" - onCheckedChanged: if(checked) root.communityHoldings = PermissionsModel.longPermissionsModel + onCheckedChanged: if(checked) root.communityHoldingsModel = PermissionsModel.longPermissionsModel } } @@ -134,17 +140,17 @@ ColumnLayout { RadioButton { checked: true text: "Short model" - onCheckedChanged: if(checked) root.viewOnlyHoldings = PermissionsModel.shortPermissionsModel + onCheckedChanged: if(checked) root.viewOnlyHoldingsModel = PermissionsModel.shortPermissionsModel } RadioButton { text: "Long model" - onCheckedChanged: if(checked) root.viewOnlyHoldings = PermissionsModel.longPermissionsModel + onCheckedChanged: if(checked) root.viewOnlyHoldingsModel = PermissionsModel.longPermissionsModel } RadioButton { text: "None" - onCheckedChanged: if(checked) root.viewOnlyHoldings = undefined + onCheckedChanged: if(checked) root.viewOnlyHoldingsModel = undefined } } @@ -159,17 +165,17 @@ ColumnLayout { RadioButton { checked: true text: "Short model" - onCheckedChanged: if(checked) root.viewAndPostHoldings = PermissionsModel.shortPermissionsModel + onCheckedChanged: if(checked) root.viewAndPostHoldingsModel = PermissionsModel.shortPermissionsModel } RadioButton { text: "Long model" - onCheckedChanged: if(checked) root.viewAndPostHoldings = PermissionsModel.longPermissionsModel + onCheckedChanged: if(checked) root.viewAndPostHoldingsModel = PermissionsModel.longPermissionsModel } RadioButton { text: "None" - onCheckedChanged: if(checked) root.viewAndPostHoldings = undefined + onCheckedChanged: if(checked) root.viewAndPostHoldingsModel = undefined } } @@ -184,17 +190,17 @@ ColumnLayout { RadioButton { checked: true text: "Short model" - onCheckedChanged: if(checked) root.moderateHoldings = PermissionsModel.shortPermissionsModel + onCheckedChanged: if(checked) root.moderateHoldingsModel = PermissionsModel.shortPermissionsModel } RadioButton { text: "Long model" - onCheckedChanged: if(checked) root.moderateHoldings = PermissionsModel.longPermissionsModel + onCheckedChanged: if(checked) root.moderateHoldingsModel = PermissionsModel.longPermissionsModel } RadioButton { text: "None" - onCheckedChanged: if(checked) root.moderateHoldings = undefined + onCheckedChanged: if(checked) root.moderateHoldingsModel = undefined } } } diff --git a/storybook/pages/JoinCommunityViewPage.qml b/storybook/pages/JoinCommunityViewPage.qml index 78050ac25f..423ea1b8b0 100644 --- a/storybook/pages/JoinCommunityViewPage.qml +++ b/storybook/pages/JoinCommunityViewPage.qml @@ -41,10 +41,10 @@ Nemo enim 😋 ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, property bool isInvitationPending: true property bool isJoinRequestRejected: false property bool requiresRequest: false - property var communityHoldings: PermissionsModel.shortPermissionsModel - property var viewOnlyHoldings: PermissionsModel.shortPermissionsModel - property var viewAndPostHoldings: PermissionsModel.shortPermissionsModel - property var moderateHoldings: PermissionsModel.shortPermissionsModel + property var communityHoldingsModel: PermissionsModel.shortPermissionsModel + property var viewOnlyHoldingsModel: PermissionsModel.shortPermissionsModel + property var viewAndPostHoldingsModel: PermissionsModel.shortPermissionsModel + property var moderateHoldingsModel: PermissionsModel.shortPermissionsModel // Blur background: property int membersCount: 184 @@ -128,10 +128,10 @@ Nemo enim 😋 ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, requirementsMet: d.requirementsMet isJoinRequestRejected: d.isJoinRequestRejected requiresRequest: d.requiresRequest - communityHoldings: d.communityHoldings - viewOnlyHoldings: d.viewOnlyHoldings - viewAndPostHoldings: d.viewAndPostHoldings - moderateHoldings: d.moderateHoldings + communityHoldingsModel: d.communityHoldingsModel + viewOnlyHoldingsModel: d.viewOnlyHoldingsModel + viewAndPostHoldingsModel: d.viewAndPostHoldingsModel + moderateHoldingsModel: d.moderateHoldingsModel onInfoButtonClicked: logs.logEvent("JoinCommunityView::onInfoButtonClicked()") onAdHocChatButtonClicked: { @@ -269,10 +269,10 @@ Nemo enim 😋 ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, onIsInvitationPendingChanged: d.isInvitationPending = isInvitationPending onIsJoinRequestRejectedChanged: d.isJoinRequestRejected = isJoinRequestRejected onRequiresRequestChanged: d.requiresRequest = requiresRequest - onCommunityHoldingsChanged: d.communityHoldings = communityHoldings - onViewOnlyHoldingsChanged: d.viewOnlyHoldings = viewOnlyHoldings - onViewAndPostHoldingsChanged: d.viewAndPostHoldings = viewAndPostHoldings - onModerateHoldingsChanged: d.moderateHoldings = moderateHoldings + onCommunityHoldingsModelChanged: d.communityHoldingsModel = communityHoldingsModel + onViewOnlyHoldingsModelChanged: d.viewOnlyHoldingsModel = viewOnlyHoldingsModel + onViewAndPostHoldingsModelChanged: d.viewAndPostHoldingsModel = viewAndPostHoldingsModel + onModerateHoldingsModelChanged: d.moderateHoldingsModel = moderateHoldingsModel } } } diff --git a/storybook/pages/JoinPermissionsOverlayPanelPage.qml b/storybook/pages/JoinPermissionsOverlayPanelPage.qml index 84bbca3141..897a95488c 100644 --- a/storybook/pages/JoinPermissionsOverlayPanelPage.qml +++ b/storybook/pages/JoinPermissionsOverlayPanelPage.qml @@ -25,10 +25,10 @@ SplitView { property bool isInvitationPending: false property bool isJoinRequestRejected: false property bool requiresRequest: false - property var communityHoldings: PermissionsModel.shortPermissionsModel - property var viewOnlyHoldings: PermissionsModel.shortPermissionsModel - property var viewAndPostHoldings: PermissionsModel.shortPermissionsModel - property var moderateHoldings: PermissionsModel.shortPermissionsModel + property var communityHoldingsModel: PermissionsModel.shortPermissionsModel + property var viewOnlyHoldingsModel: PermissionsModel.shortPermissionsModel + property var viewAndPostHoldingsModel: PermissionsModel.shortPermissionsModel + property var moderateHoldingsModel: PermissionsModel.shortPermissionsModel } Logs { id: logs } @@ -74,11 +74,11 @@ SplitView { isJoinRequestRejected: d.isJoinRequestRejected requiresRequest: d.requiresRequest communityName: d.name - communityHoldings: d.communityHoldings + communityHoldingsModel: d.communityHoldingsModel channelName: d.channelName - viewOnlyHoldings: d.viewOnlyHoldings - viewAndPostHoldings: d.viewAndPostHoldings - moderateHoldings: d.moderateHoldings + viewOnlyHoldingsModel: d.viewOnlyHoldingsModel + viewAndPostHoldingsModel: d.viewAndPostHoldingsModel + moderateHoldingsModel: d.moderateHoldingsModel onRevealAddressClicked: logs.logEvent("JoinPermissionsOverlayPanel::onRevealAddressClicked()") onInvitationPendingClicked: logs.logEvent("JoinPermissionsOverlayPanel::onInvitationPendingClicked()") @@ -157,10 +157,10 @@ SplitView { onIsInvitationPendingChanged: d.isInvitationPending = isInvitationPending onIsJoinRequestRejectedChanged: d.isJoinRequestRejected = isJoinRequestRejected onRequiresRequestChanged: d.requiresRequest = requiresRequest - onCommunityHoldingsChanged: d.communityHoldings = communityHoldings - onViewOnlyHoldingsChanged: d.viewOnlyHoldings = viewOnlyHoldings - onViewAndPostHoldingsChanged: d.viewAndPostHoldings = viewAndPostHoldings - onModerateHoldingsChanged: d.moderateHoldings = moderateHoldings + onCommunityHoldingsModelChanged: d.communityHoldingsModel = communityHoldingsModel + onViewOnlyHoldingsModelChanged: d.viewOnlyHoldingsModel = viewOnlyHoldingsModel + onViewAndPostHoldingsModelChanged: d.viewAndPostHoldingsModel = viewAndPostHoldingsModel + onModerateHoldingsModelChanged: d.moderateHoldingsModel = moderateHoldingsModel } } } diff --git a/ui/app/AppLayouts/Chat/panels/communities/JoinPermissionsOverlayPanel.qml b/ui/app/AppLayouts/Chat/panels/communities/JoinPermissionsOverlayPanel.qml index f726589b7e..07f9f888d2 100644 --- a/ui/app/AppLayouts/Chat/panels/communities/JoinPermissionsOverlayPanel.qml +++ b/ui/app/AppLayouts/Chat/panels/communities/JoinPermissionsOverlayPanel.qml @@ -22,11 +22,12 @@ Control { property bool isInvitationPending: false property bool isJoinRequestRejected: false property string communityName - property var communityHoldings + property var communityHoldingsModel property string channelName - property var viewOnlyHoldings - property var viewAndPostHoldings - property var moderateHoldings + property var viewOnlyHoldingsModel + property var viewAndPostHoldingsModel + property var moderateHoldingsModel + property bool showOnlyPanels: false signal revealAddressClicked signal invitationPendingClicked @@ -65,38 +66,38 @@ Control { HoldingsListPanel { Layout.fillWidth: true spacing: root.spacing - visible: root.joinCommunity && root.communityHoldings + visible: root.joinCommunity && root.communityHoldingsModel introText: qsTr("To join %1 you need to prove that you hold").arg(root.communityName) - model: root.communityHoldings + model: root.communityHoldingsModel } HoldingsListPanel { Layout.fillWidth: true spacing: root.spacing - visible: !root.joinCommunity && !!root.viewOnlyHoldings + visible: !root.joinCommunity && !!root.viewOnlyHoldingsModel introText: qsTr("To only view the %1 channel you need to hold").arg(root.channelName) - model: root.viewOnlyHoldings + model: root.viewOnlyHoldingsModel } HoldingsListPanel { Layout.fillWidth: true spacing: root.spacing - visible: !root.joinCommunity && !!root.viewAndPostHoldings + visible: !root.joinCommunity && !!root.viewAndPostHoldingsModel introText: qsTr("To view and post in the %1 channel you need to hold").arg(root.channelName) - model: root.viewAndPostHoldings + model: root.viewAndPostHoldingsModel } HoldingsListPanel { Layout.fillWidth: true spacing: root.spacing - visible: !root.joinCommunity && !!root.moderateHoldings + visible: !root.joinCommunity && !!root.moderateHoldingsModel introText: qsTr("To moderate in the %1 channel you need to hold").arg(root.channelName) - model: root.moderateHoldings + model: root.moderateHoldingsModel } StatusButton { Layout.alignment: Qt.AlignHCenter - visible: !root.isJoinRequestRejected + visible: !root.showOnlyPanels && !root.isJoinRequestRejected text: root.isInvitationPending ? d.getInvitationPendingText() : d.getRevealAddressText() font.pixelSize: 13 enabled: root.requirementsMet @@ -105,7 +106,7 @@ Control { StatusBaseText { Layout.alignment: Qt.AlignHCenter - visible: root.isJoinRequestRejected || !root.requirementsMet + visible: !root.showOnlyPanels && (root.isJoinRequestRejected || !root.requirementsMet) text: root.isJoinRequestRejected ? d.memberchipRequestRejectedText : (root.joinCommunity ? d.communityRequirementsNotMetText : d.channelRequirementsNotMetText) color: Theme.palette.dangerColor1 diff --git a/ui/app/AppLayouts/Chat/popups/community/CommunityTokenPermissionsPopup.qml b/ui/app/AppLayouts/Chat/popups/community/CommunityTokenPermissionsPopup.qml new file mode 100644 index 0000000000..79c5d69ac2 --- /dev/null +++ b/ui/app/AppLayouts/Chat/popups/community/CommunityTokenPermissionsPopup.qml @@ -0,0 +1,57 @@ +import QtQuick 2.14 +import QtQuick.Controls 2.14 + +import StatusQ.Core 0.1 +import StatusQ.Popups.Dialog 0.1 + +import AppLayouts.Chat.panels.communities 1.0 + +StatusDialog { + id: root + + property string channelName + property alias viewOnlyHoldingsModel: overlayPanel.viewOnlyHoldingsModel + property alias viewAndPostHoldingsModel: overlayPanel.viewAndPostHoldingsModel + property alias moderateHoldingsModel: overlayPanel.moderateHoldingsModel + + QtObject { + id: d + + readonly property int maxWidth: 640 + readonly property int minWidth: 300 + readonly property int maxHeight: 480 + + function getVerticalPadding() { + return root.topPadding + root.bottomPadding + } + + function getHorizontalPadding() { + return root.leftPadding + root.rightPadding + } + + function getMaxMinWidth() { + return Math.max(overlayPanel.implicitWidth, d.minWidth) + } + } + + title: qsTr("Token permissions for %1 channel").arg(root.channelName) + footer.visible: false + implicitWidth: Math.min(d.getMaxMinWidth(), d.maxWidth) + d.getHorizontalPadding() + implicitHeight: Math.min(overlayPanel.implicitHeight + d.getVerticalPadding() + root.header.height, d.maxHeight) + contentItem: StatusScrollView { + ScrollBar.vertical.policy: ScrollBar.AsNeeded + ScrollBar.horizontal.policy: ScrollBar.AsNeeded + contentHeight: overlayPanel.implicitHeight + contentWidth: overlayPanel.implicitWidth + padding: 0 + + JoinPermissionsOverlayPanel { + id: overlayPanel + + anchors.centerIn: parent + joinCommunity: false + channelName: root.channelName + showOnlyPanels: true + } + } +} diff --git a/ui/app/AppLayouts/Chat/popups/community/qmldir b/ui/app/AppLayouts/Chat/popups/community/qmldir index 053c80eec4..0cc36edd0a 100644 --- a/ui/app/AppLayouts/Chat/popups/community/qmldir +++ b/ui/app/AppLayouts/Chat/popups/community/qmldir @@ -1 +1,2 @@ CreateChannelPopup 1.0 CreateChannelPopup.qml +CommunityTokenPermissionsPopup 1.0 CommunityTokenPermissionsPopup.qml diff --git a/ui/app/AppLayouts/Chat/stores/CommunitiesStore.qml b/ui/app/AppLayouts/Chat/stores/CommunitiesStore.qml index 3b86c4f5fd..a85961bfbd 100644 --- a/ui/app/AppLayouts/Chat/stores/CommunitiesStore.qml +++ b/ui/app/AppLayouts/Chat/stores/CommunitiesStore.qml @@ -209,7 +209,7 @@ QtObject { //MINTING - property var mintTokensModel: mintingModuleInst.tokensModel + property var mintTokensModel: !!mintingModuleInst ? mintingModuleInst.tokensModel : null function mintCollectible(address, name, symbol, description, supply, infiniteSupply, transferable, selfDestruct, network) diff --git a/ui/app/AppLayouts/Chat/views/communities/JoinCommunityView.qml b/ui/app/AppLayouts/Chat/views/communities/JoinCommunityView.qml index aaf52b85ea..d34dab9267 100644 --- a/ui/app/AppLayouts/Chat/views/communities/JoinCommunityView.qml +++ b/ui/app/AppLayouts/Chat/views/communities/JoinCommunityView.qml @@ -36,10 +36,10 @@ StatusSectionLayout { property bool requirementsMet: true property bool isJoinRequestRejected: false property bool requiresRequest: false - property var communityHoldings - property var viewOnlyHoldings - property var viewAndPostHoldings - property var moderateHoldings + property var communityHoldingsModel + property var viewOnlyHoldingsModel + property var viewAndPostHoldingsModel + property var moderateHoldingsModel // Blur view properties: property int membersCount @@ -269,11 +269,11 @@ StatusSectionLayout { isJoinRequestRejected: root.isJoinRequestRejected requiresRequest: root.requiresRequest communityName: root.name - communityHoldings: root.communityHoldings + communityHoldingsModel: root.communityHoldingsModel channelName: root.channelName - viewOnlyHoldings: root.viewOnlyHoldings - viewAndPostHoldings: root.viewAndPostHoldings - moderateHoldings: root.moderateHoldings + viewOnlyHoldingsModel: root.viewOnlyHoldingsModel + viewAndPostHoldingsModel: root.viewAndPostHoldingsModel + moderateHoldingsModel: root.moderateHoldingsModel onRevealAddressClicked: root.revealAddressClicked() onInvitationPendingClicked: root.invitationPendingClicked()