Skip to content

Commit

Permalink
add isAdmin property
Browse files Browse the repository at this point in the history
  • Loading branch information
iurimatias committed Sep 18, 2024
1 parent 6a687d2 commit 68d7b20
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
19 changes: 16 additions & 3 deletions storybook/pages/MessageContextMenuPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ SplitView {
ensVerified: ensVerifiedCheckBox.checked
onlineStatus: onlineStatusSelector.currentValue
hasLocalNickname: hasLocalNicknameCheckBox.checked
chatType: chatTypeSelector.currentValue // Add this line
chatType: chatTypeSelector.currentValue
isAdmin: isAdminCheckBox.checked

onOpenProfileClicked: (publicKey) => {
logs.logEvent("Open profile clicked for:", publicKey)
Expand Down Expand Up @@ -147,7 +148,8 @@ SplitView {
ensVerified: ensVerifiedCheckBox.checked
onlineStatus: onlineStatusSelector.currentValue
hasLocalNickname: hasLocalNicknameCheckBox.checked
chatType: chatTypeSelector.currentValue // Add this line
chatType: chatTypeSelector.currentValue
isAdmin: isAdminCheckBox.checked

onOpenProfileClicked: (publicKey) => {
logs.logEvent("Open profile clicked for:", publicKey)
Expand Down Expand Up @@ -314,7 +316,18 @@ SplitView {
currentIndex: 0
}

Label {
CheckBox {
id: isAdminCheckBox
text: "Is Admin"
checked: false
}

Label {
Layout.fillWidth: true
text: "Is Admin: " + (isAdminCheckBox.checked ? "Yes" : "No")
}

Label {
Layout.fillWidth: true
text: "Chat type: " + chatTypeSelector.currentText
}
Expand Down
3 changes: 2 additions & 1 deletion ui/app/AppLayouts/Chat/panels/UserListPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,10 @@ Item {
if (mouse.button === Qt.RightButton) {
const { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname } = root.store.contactsStore.getProfileContext(model.pubKey, userProfile.pubKey)
const chatType = chatContentModule.chatDetails.type
const isAdmin = chatContentModule.amIChatAdmin()

Global.openMenu(profileContextMenuComponent, this, {
profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname, chatType,
profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname, chatType, isAdmin,
selectedUserPublicKey: model.pubKey,
selectedUserDisplayName: nickName || userName,
selectedUserIcon: model.icon,
Expand Down
3 changes: 2 additions & 1 deletion ui/imports/shared/views/chat/MessageView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,9 @@ Loader {
const isBridgedAccount = isReply ? (quotedMessageContentType === Constants.messageContentType.bridgeMessageType) : root.isBridgeMessage
const { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname } = root.contactsStore.getProfileContext(publicKey, root.rootStore.contactsStore.myPublicKey, isBridgedAccount)
const chatType = chatContentModule.chatDetails.type
const isAdmin = chatContentModule.amIChatAdmin()

const params = { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname, chatType,
const params = { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname, chatType, isAdmin,
selectedUserPublicKey: isReply ? quotedMessageFrom : root.senderId,
selectedUserDisplayName: isReply ? quotedMessageAuthorDetailsDisplayName : root.senderDisplayName,
selectedUserIcon: isReply ? quotedMessageAuthorDetailsThumbnailImage : root.senderIcon,
Expand Down
3 changes: 2 additions & 1 deletion ui/imports/shared/views/chat/ProfileContextMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ StatusMenu {
property bool hasLocalNickname: false
property int profileType: Constants.profileType.regular
property int chatType: Constants.chatType.unknown
property bool isAdmin: false

signal openProfileClicked(string publicKey)
signal createOneToOneChat(string communityId, string chatId, string ensName)
Expand Down Expand Up @@ -136,7 +137,7 @@ StatusMenu {
objectName: "removeFromGroup_StatusItem"
icon.name: "remove-contact"
type: StatusAction.Type.Danger
enabled: root.profileType !== Constants.profileType.self && root.chatType === Constants.chatType.privateGroupChat
enabled: root.isAdmin && root.profileType !== Constants.profileType.self && root.chatType === Constants.chatType.privateGroupChat
onTriggered: root.removeFromGroup(root.selectedUserPublicKey)
}

Expand Down

0 comments on commit 68d7b20

Please sign in to comment.