feat(Community): Add pending states to Community Request Notification
This commit is contained in:
parent
351309a2c6
commit
e9a2b183c7
|
@ -41,7 +41,9 @@ type ActivityCenterMembershipStatus* {.pure.}= enum
|
|||
Idle = 0,
|
||||
Pending = 1,
|
||||
Accepted = 2,
|
||||
Declined = 3
|
||||
Declined = 3,
|
||||
AcceptedPending = 4,
|
||||
DeclinedPending = 5,
|
||||
|
||||
type ActivityCenterNotificationDto* = ref object of RootObj
|
||||
id*: string # ID is the id of the chat, for public chats it is the name e.g. status, for one-to-one is the hex encoded public key and for group chats is a random uuid appended with the hex encoded pk of the creator of the chat
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
"https://www.figma.com/file/idUoxN7OIW2Jpp3PMJ1Rl8/%E2%9A%99%EF%B8%8F-Settings-%7C-Desktop?node-id=1159%3A114479",
|
||||
"https://www.figma.com/file/idUoxN7OIW2Jpp3PMJ1Rl8/%E2%9A%99%EF%B8%8F-Settings-%7C-Desktop?node-id=1684%3A127762"
|
||||
],
|
||||
"ActivityNotificationCommunityMembershipRequest": [
|
||||
"https://www.figma.com/file/17fc13UBFvInrLgNUKJJg5/Kuba⎜Desktop?type=design&node-id=35909-606817&mode=design&t=Ia7Z0AzyYIjkuPtr-0"
|
||||
],
|
||||
"AirdropRecipientsSelector": [
|
||||
"https://www.figma.com/file/17fc13UBFvInrLgNUKJJg5/Kuba%E2%8E%9CDesktop?node-id=22628-494998",
|
||||
"https://www.figma.com/file/17fc13UBFvInrLgNUKJJg5/Kuba%E2%8E%9CDesktop?node-id=22628-495258",
|
||||
|
|
|
@ -0,0 +1,179 @@
|
|||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
import Qt.labs.settings 1.0
|
||||
|
||||
import mainui.activitycenter.views 1.0
|
||||
import mainui.activitycenter.stores 1.0
|
||||
|
||||
import utils 1.0
|
||||
|
||||
import Storybook 1.0
|
||||
|
||||
SplitView {
|
||||
id: root
|
||||
|
||||
property bool utilsReady: false
|
||||
|
||||
orientation: Qt.Vertical
|
||||
|
||||
Logs { id: logs }
|
||||
|
||||
Item {
|
||||
id: wrapper
|
||||
SplitView.fillHeight: true
|
||||
SplitView.fillWidth: true
|
||||
|
||||
Loader {
|
||||
active: root.utilsReady
|
||||
anchors.centerIn: parent
|
||||
width: parent.width - 50
|
||||
height: 80
|
||||
|
||||
sourceComponent : ActivityNotificationCommunityMembershipRequest {
|
||||
store: storeMock
|
||||
notification: notificationMock
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LogsAndControlsPanel {
|
||||
SplitView.minimumHeight: 100
|
||||
SplitView.preferredHeight: 160
|
||||
|
||||
logsView.logText: logs.logText
|
||||
|
||||
ColumnLayout {
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
Label {
|
||||
text: "Request state"
|
||||
}
|
||||
|
||||
ComboBox {
|
||||
id: stateSelector
|
||||
textRole: "text"
|
||||
valueRole: "value"
|
||||
model: ListModel {
|
||||
id: model
|
||||
ListElement { text: "Pending"; value: ActivityCenterStore.ActivityCenterMembershipStatus.Pending }
|
||||
ListElement { text: "Accepted"; value: ActivityCenterStore.ActivityCenterMembershipStatus.Accepted }
|
||||
ListElement { text: "Declined"; value: ActivityCenterStore.ActivityCenterMembershipStatus.Declined }
|
||||
ListElement { text: "AcceptedPending"; value: ActivityCenterStore.ActivityCenterMembershipStatus.AcceptedPending }
|
||||
ListElement { text: "DeclinedPending"; value: ActivityCenterStore.ActivityCenterMembershipStatus.DeclinedPending }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: utilsMock
|
||||
function getContactDetailsAsJson(arg1, arg2) {
|
||||
return JSON.stringify({
|
||||
displayName: "Mock user",
|
||||
displayIcon: Style.png("tokens/AST"),
|
||||
publicKey: 123456789,
|
||||
name: "",
|
||||
ensVerified: false,
|
||||
alias: "",
|
||||
lastUpdated: 0,
|
||||
lastUpdatedLocally: 0,
|
||||
localNickname: "",
|
||||
thumbnailImage: "",
|
||||
largeImage: "",
|
||||
isContact: false,
|
||||
isAdded: false,
|
||||
isBlocked: false,
|
||||
requestReceived: false,
|
||||
isSyncing: false,
|
||||
removed: false,
|
||||
trustStatus: Constants.trustStatus.unknown,
|
||||
verificationStatus: Constants.verificationStatus.unverified,
|
||||
incomingVerificationStatus: Constants.verificationStatus.unverified
|
||||
})
|
||||
}
|
||||
|
||||
function isCompressedPubKey(key) {
|
||||
return true
|
||||
}
|
||||
|
||||
function getColorId(publicKey) {
|
||||
return 1
|
||||
}
|
||||
|
||||
function isEnsVerified(publicKey) {
|
||||
return true
|
||||
}
|
||||
|
||||
function getCompressedPk(publicKey) {
|
||||
return "0x00000"
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
Utils.mainModuleInst = this
|
||||
Utils.globalUtilsInst = this
|
||||
root.utilsReady = true
|
||||
}
|
||||
Component.onDestruction: {
|
||||
root.utilsReady = false
|
||||
Utils.mainModuleInst = {}
|
||||
Utils.globalUtilsInst = {}
|
||||
}
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: storeMock
|
||||
|
||||
function getCommunityDetailsAsJson(community) {
|
||||
return {
|
||||
name : "Mock Community",
|
||||
image : Style.png("tokens/UNI"),
|
||||
color : "orchid"
|
||||
}
|
||||
}
|
||||
|
||||
function acceptRequestToJoinCommunity(notificationId, communityId) {
|
||||
stateSelector.currentIndex = stateSelector.indexOfValue(ActivityCenterStore.ActivityCenterMembershipStatus.AcceptedPending)
|
||||
}
|
||||
|
||||
function declineRequestToJoinCommunity(notificationId, communityId) {
|
||||
stateSelector.currentIndex = stateSelector.indexOfValue(ActivityCenterStore.ActivityCenterMembershipStatus.DeclinedPending)
|
||||
}
|
||||
|
||||
property var contactsStore: QtObject {
|
||||
property var myContactsModel: QtObject {
|
||||
signal itemChanged(string pubKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: notificationMock
|
||||
property string id: "1"
|
||||
property string chatId: "1"
|
||||
property string communityId: "1"
|
||||
property int membershipStatus: stateSelector.currentValue
|
||||
property int verificationStatus: 1
|
||||
property string sectionId: "1"
|
||||
property string name: "name"
|
||||
property string author: "author"
|
||||
property int notificationType: 1
|
||||
property var message: QtObject {
|
||||
property bool amISender: false
|
||||
}
|
||||
|
||||
property int timestamp: Date.now()
|
||||
property int previousTimestamp: 0
|
||||
property bool read: false
|
||||
property bool dismissed: false
|
||||
property bool accepted: false
|
||||
property var repliedMessage: ({})
|
||||
property int chatType: 1
|
||||
}
|
||||
|
||||
Settings {
|
||||
property alias activityNotificationRequestState: stateSelector.currentIndex
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
import QtQuick 2.14
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
import StatusQ.Core 0.1
|
||||
import StatusQ.Core.Theme 0.1
|
||||
|
@ -14,6 +15,9 @@ Item {
|
|||
property bool pending: false
|
||||
property bool accepted: false
|
||||
property bool declined: false
|
||||
property bool acceptedPending: false
|
||||
property bool declinedPending: false
|
||||
property bool ctaAllowed: true
|
||||
|
||||
signal acceptRequestToJoinCommunity()
|
||||
signal declineRequestToJoinCommunity()
|
||||
|
@ -47,30 +51,31 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
RowLayout {
|
||||
id: buttons
|
||||
anchors.centerIn: parent
|
||||
visible: pending
|
||||
spacing: Style.current.padding
|
||||
|
||||
StatusRoundButton {
|
||||
icon.name: "thumbs-up"
|
||||
icon.color: Style.current.white
|
||||
icon.hoverColor: Style.current.white
|
||||
implicitWidth: 28
|
||||
implicitHeight: 28
|
||||
color: Theme.palette.successColor1
|
||||
visible: pending || acceptedPending || declinedPending
|
||||
spacing: Style.current.halfPadding
|
||||
StatusFlatButton {
|
||||
icon.name: "checkmark-circle"
|
||||
icon.color: enabled ? Theme.palette.successColor1 : disabledTextColor
|
||||
onClicked: root.acceptRequestToJoinCommunity()
|
||||
enabled: !root.acceptedPending
|
||||
text: root.acceptedPending ? qsTr("Accept pending") : ""
|
||||
verticalPadding: 4
|
||||
horizontalPadding: 4
|
||||
visible: root.ctaAllowed || !enabled
|
||||
}
|
||||
|
||||
StatusRoundButton {
|
||||
icon.name: "thumbs-down"
|
||||
icon.color: Style.current.white
|
||||
icon.hoverColor: Style.current.white
|
||||
implicitWidth: 28
|
||||
implicitHeight: 28
|
||||
color: Theme.palette.dangerColor1
|
||||
StatusFlatButton {
|
||||
icon.name: "close-circle"
|
||||
icon.color: enabled ? Theme.palette.dangerColor1 : disabledTextColor
|
||||
onClicked: root.declineRequestToJoinCommunity()
|
||||
enabled: !root.declinedPending
|
||||
text: root.declinedPending ? qsTr("Reject pending") : ""
|
||||
verticalPadding: 4
|
||||
horizontalPadding: 4
|
||||
visible: root.ctaAllowed || !enabled
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,9 @@ QtObject {
|
|||
enum ActivityCenterMembershipStatus {
|
||||
Pending = 1,
|
||||
Accepted = 2,
|
||||
Declined = 3
|
||||
Declined = 3,
|
||||
AcceptedPending = 4,
|
||||
DeclinedPending = 5
|
||||
}
|
||||
|
||||
enum ActivityCenterContactRequestState {
|
||||
|
|
|
@ -46,7 +46,12 @@ ActivityNotificationMessage {
|
|||
pending: notification && notification.membershipStatus === ActivityCenterStore.ActivityCenterMembershipStatus.Pending
|
||||
accepted: notification && notification.membershipStatus === ActivityCenterStore.ActivityCenterMembershipStatus.Accepted
|
||||
declined: notification && notification.membershipStatus === ActivityCenterStore.ActivityCenterMembershipStatus.Declined
|
||||
acceptedPending: notification && notification.membershipStatus === ActivityCenterStore.ActivityCenterMembershipStatus.AcceptedPending
|
||||
declinedPending: notification && notification.membershipStatus === ActivityCenterStore.ActivityCenterMembershipStatus.DeclinedPending
|
||||
onAcceptRequestToJoinCommunity: root.store.acceptRequestToJoinCommunity(notification.id, notification.communityId)
|
||||
onDeclineRequestToJoinCommunity: root.store.declineRequestToJoinCommunity(notification.id, notification.communityId)
|
||||
//TODO: Get backend value. If the membersip is in acceptedPending or declinedPending state, another user can't accept or decline the request
|
||||
//Only the user who requested can cancel the request
|
||||
ctaAllowed: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
ActivityNotificationCommunityMembershipRequest 1.0 ActivityNotificationCommunityMembershipRequest.qml
|
Loading…
Reference in New Issue