2022-11-25 17:35:30 +00:00
import QtQuick 2.14
import QtQuick . Layouts 1.14
import StatusQ . Core 0.1
2024-02-06 09:31:36 +00:00
import StatusQ . Controls 0.1
2022-11-25 17:35:30 +00:00
import SortFilterProxyModel 0.2
2024-02-06 09:31:36 +00:00
import shared . status 1.0
2022-11-24 16:23:54 +00:00
import shared . popups 1.0
2023-06-29 11:54:04 +00:00
import utils 1.0
2022-11-25 17:35:30 +00:00
2023-06-23 06:17:04 +00:00
import AppLayouts . Communities . controls 1.0
2023-06-29 11:54:04 +00:00
import AppLayouts . Communities . panels 1.0
2022-11-25 17:35:30 +00:00
2024-02-06 09:31:36 +00:00
ColumnLayout {
2022-11-25 17:35:30 +00:00
id: root
2024-02-06 09:31:36 +00:00
width: root . viewWidth
property int topPadding: count ? 16 : 0
spacing: 24
QtObject {
id: d
property int permissionIndexToRemove
}
2022-11-25 17:35:30 +00:00
2023-03-07 08:47:04 +00:00
required property var permissionsModel
required property var assetsModel
required property var collectiblesModel
required property var channelsModel
2023-06-29 07:37:49 +00:00
// id, name, image, color, owner, admin properties expected
2023-03-07 08:47:04 +00:00
required property var communityDetails
2023-02-22 17:51:49 +00:00
2022-11-25 17:35:30 +00:00
property int viewWidth: 560 // by design
2024-02-06 09:31:36 +00:00
property bool viewOnlyCanAddReaction
property bool showChannelOptions: false
property bool allowIntroPanel: true
2022-11-25 17:35:30 +00:00
2023-02-10 22:40:07 +00:00
signal editPermissionRequested ( int index )
signal duplicatePermissionRequested ( int index )
signal removePermissionRequested ( int index )
2024-02-06 09:31:36 +00:00
signal userRestrictionsToggled ( bool checked )
2022-11-24 16:23:54 +00:00
2023-06-29 11:54:04 +00:00
readonly property alias count: repeater . count
2024-02-06 09:31:36 +00:00
ListModel {
id: communityItemModel
Component.onCompleted: {
append ( {
text: root . communityDetails . name ,
imageSource: root . communityDetails . image ,
color: root . communityDetails . color
} )
}
}
2023-06-29 11:54:04 +00:00
2024-02-06 09:31:36 +00:00
IntroPanel {
Layout.fillWidth: true
2023-06-29 22:05:46 +00:00
2024-02-06 09:31:36 +00:00
visible: ( root . count === 0 && root . allowIntroPanel )
2023-01-18 19:54:14 +00:00
2024-02-06 09:31:36 +00:00
image: Style . png ( "community/permissions2_3" )
title: qsTr ( "Permissions" )
subtitle: qsTr ( "You can manage your community by creating and issuing membership and access permissions" )
checkersModel: [
qsTr ( "Give individual members access to private channels" ) ,
qsTr ( "Monetise your community with subscriptions and fees" ) ,
qsTr ( "Require holding a token or NFT to obtain exclusive membership rights" )
]
2022-11-24 16:23:54 +00:00
}
2024-02-06 09:31:36 +00:00
Repeater {
id: repeater
2023-01-27 09:22:04 +00:00
2024-02-06 09:31:36 +00:00
model: root . permissionsModel
2023-01-27 09:22:04 +00:00
2024-02-06 09:31:36 +00:00
delegate: PermissionItem {
2023-06-29 22:05:46 +00:00
Layout.fillWidth: true
2024-02-06 09:31:36 +00:00
holdingsListModel: HoldingsSelectionModel {
sourceModel: model . holdingsListModel
assetsModel: root . assetsModel
collectiblesModel: root . collectiblesModel
}
2023-02-11 19:03:57 +00:00
2024-02-06 09:31:36 +00:00
permissionType: model . permissionType
permissionState: model . permissionState // TODO: Backend!
2023-01-27 09:22:04 +00:00
2024-02-06 09:31:36 +00:00
ChannelsSelectionModel {
id: channelsSelectionModel
2023-01-27 09:22:04 +00:00
2024-02-06 09:31:36 +00:00
selectedChannels: model . channelsListModel ? ? null
allChannels: root . channelsModel
}
2023-01-27 09:22:04 +00:00
2024-02-06 09:31:36 +00:00
channelsListModel: channelsSelectionModel . count
? channelsSelectionModel : communityItemModel
isPrivate: model . isPrivate
2022-11-25 17:35:30 +00:00
2024-02-06 09:31:36 +00:00
showButtons: ( model . permissionType !== PermissionTypes . Type . TokenMaster &&
model . permissionType !== PermissionTypes . Type . Owner ) &&
( ! ! root . communityDetails && ( root . communityDetails . owner ||
( ( root . communityDetails . admin || root . communityDetails . tokenMaster ) && model . permissionType !== PermissionTypes . Type . Admin ) ) )
2023-06-14 16:00:41 +00:00
2024-02-06 09:31:36 +00:00
onEditClicked: root . editPermissionRequested ( model . index )
onDuplicateClicked: root . duplicatePermissionRequested ( model . index )
2023-01-27 09:22:04 +00:00
2024-02-06 09:31:36 +00:00
onRemoveClicked: {
d . permissionIndexToRemove = index
declineAllDialog . open ( )
2022-11-25 17:35:30 +00:00
}
}
}
2022-11-24 16:23:54 +00:00
2024-02-06 09:31:36 +00:00
StatusBaseText {
id: noPermissionsLabel
Layout.fillWidth: true
Layout.fillHeight: true
visible: ( root . count === 0 && root . showChannelOptions )
horizontalAlignment: Text . AlignHCenter
verticalAlignment: Text . AlignVCenter
text: qsTr ( "No channel permissions" )
color: Style . current . secondaryText
}
StatusIconSwitch {
Layout.fillWidth: true
padding: 0
visible: false //TODO: enable this when we have the backend support https://github.com/status-im/status-desktop/issues/13292
//visible: root.showChannelOptions
title: qsTr ( "Users with view only permissions can add reactions" )
icon: "emojis"
checked: root . viewOnlyCanAddReaction
onToggled: {
root . userRestrictionsToggled ( checked ) ;
}
}
2023-02-10 22:40:07 +00:00
ConfirmationDialog {
id: declineAllDialog
2023-05-23 12:46:16 +00:00
headerSettings.title: qsTr ( "Sure you want to delete permission" )
2023-02-15 23:04:24 +00:00
confirmationText: qsTr ( "If you delete this permission, any of your community members who rely on this permission will lose the access this permission gives them." )
2023-02-10 22:40:07 +00:00
onConfirmButtonClicked: {
root . removePermissionRequested ( d . permissionIndexToRemove )
close ( )
2022-11-24 16:23:54 +00:00
}
}
2022-11-25 17:35:30 +00:00
}