2023-07-04 15:11:41 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
|
2024-04-01 14:20:07 +00:00
|
|
|
import StatusQ 0.1
|
2023-07-04 15:11:41 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Core.Utils 0.1
|
|
|
|
|
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
|
|
|
import AppLayouts.Communities.controls 1.0
|
|
|
|
import AppLayouts.Communities.views 1.0
|
|
|
|
import AppLayouts.Communities.helpers 1.0
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: root
|
|
|
|
|
2024-03-27 12:48:17 +00:00
|
|
|
required property int /*PermissionTypes.Type*/ eligibleToJoinAs
|
|
|
|
|
2023-08-02 17:39:42 +00:00
|
|
|
property bool isEditMode
|
2024-04-12 09:52:53 +00:00
|
|
|
property bool isDirty
|
2023-08-02 17:39:42 +00:00
|
|
|
|
|
|
|
property string communityName
|
|
|
|
property string communityIcon
|
|
|
|
|
2023-07-04 15:11:41 +00:00
|
|
|
property var permissionsModel
|
|
|
|
property var assetsModel
|
|
|
|
property var collectiblesModel
|
2023-08-02 17:39:42 +00:00
|
|
|
|
2024-03-25 18:39:45 +00:00
|
|
|
property bool requirementsCheckPending
|
2024-05-16 09:28:06 +00:00
|
|
|
property bool checkingPermissionToJoinInProgress
|
|
|
|
property bool joinPermissionsCheckCompletedWithoutErrors
|
2024-03-25 18:39:45 +00:00
|
|
|
|
2023-08-02 17:39:42 +00:00
|
|
|
readonly property bool lostPermissionToJoin: d.lostPermissionToJoin
|
|
|
|
readonly property bool lostChannelPermissions: d.lostChannelPermissions
|
2023-07-04 15:11:41 +00:00
|
|
|
|
|
|
|
implicitHeight: permissionsScrollView.contentHeight - permissionsScrollView.anchors.topMargin
|
2024-03-27 12:48:17 +00:00
|
|
|
color: Theme.palette.baseColor4
|
2023-07-04 15:11:41 +00:00
|
|
|
|
2024-01-18 14:06:25 +00:00
|
|
|
readonly property bool hasAnyVisiblePermission: root.permissionsModel && root.permissionsModel.count &&
|
|
|
|
(d.tokenMasterPermissionsModel.count > 0 || d.adminPermissionsModel.count > 0 ||
|
|
|
|
d.joinPermissionsModel.count > 0 || d.channelsPermissionsModel.count > 0)
|
|
|
|
|
2023-07-04 15:11:41 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
// UI
|
|
|
|
readonly property int absLeftMargin: 12
|
|
|
|
readonly property color tableBorderColor: Theme.palette.directColor7
|
|
|
|
|
|
|
|
// internal logic
|
2023-08-02 17:39:42 +00:00
|
|
|
readonly property bool lostPermissionToJoin: root.isEditMode && joinPermissionsModel.count && !joinPermissionPanel.tokenCriteriaMet
|
|
|
|
|
2023-07-04 15:11:41 +00:00
|
|
|
readonly property var uniquePermissionChannels:
|
2024-04-04 11:06:44 +00:00
|
|
|
d.channelsPermissionsModel.count ?
|
2023-07-04 15:11:41 +00:00
|
|
|
PermissionsHelpers.getUniquePermissionChannels(root.permissionsModel, [PermissionTypes.Type.Read, PermissionTypes.Type.ViewAndPost])
|
|
|
|
: []
|
|
|
|
|
2023-08-02 17:39:42 +00:00
|
|
|
property var initialChannelPermissions
|
|
|
|
|
|
|
|
function getChannelPermissions() {
|
|
|
|
var result = {}
|
|
|
|
for (let i = 0; i < channelPermissionsPanel.count; i++) {
|
|
|
|
const channel = channelPermissionsPanel.itemAt(i)
|
|
|
|
const ckey = channel.channelKey
|
|
|
|
result[ckey] = [channel.readPermissionMet, channel.viewAndPostPermissionMet]
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
readonly property bool lostChannelPermissions: root.isEditMode && d.uniquePermissionChannels.length > 0 && channelPermissionsPanel.anyPermissionLost
|
|
|
|
|
2023-07-04 15:11:41 +00:00
|
|
|
// models
|
2024-01-18 14:06:25 +00:00
|
|
|
readonly property var tokenMasterPermissionsModel: SortFilterProxyModel {
|
|
|
|
id: tokenMasterPermissionsModel
|
|
|
|
sourceModel: root.permissionsModel
|
2024-04-04 11:06:44 +00:00
|
|
|
filters: [
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "permissionType"
|
|
|
|
value: Constants.permissionType.becomeTokenMaster
|
|
|
|
},
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "tokenCriteriaMet"
|
|
|
|
value: true
|
|
|
|
}
|
|
|
|
]
|
2024-01-18 14:06:25 +00:00
|
|
|
}
|
2023-07-04 15:11:41 +00:00
|
|
|
readonly property var adminPermissionsModel: SortFilterProxyModel {
|
|
|
|
id: adminPermissionsModel
|
|
|
|
sourceModel: root.permissionsModel
|
2024-04-04 11:06:44 +00:00
|
|
|
filters: [
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "permissionType"
|
|
|
|
value: Constants.permissionType.admin
|
|
|
|
},
|
|
|
|
AnyOf {
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "isPrivate"
|
|
|
|
value: false
|
|
|
|
}
|
|
|
|
AllOf {
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "tokenCriteriaMet"
|
|
|
|
value: true
|
|
|
|
}
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "isPrivate"
|
|
|
|
value: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2023-07-04 15:11:41 +00:00
|
|
|
}
|
|
|
|
readonly property var joinPermissionsModel: SortFilterProxyModel {
|
|
|
|
id: joinPermissionsModel
|
|
|
|
sourceModel: root.permissionsModel
|
2024-04-04 11:06:44 +00:00
|
|
|
filters: [
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "permissionType"
|
|
|
|
value: Constants.permissionType.member
|
|
|
|
},
|
|
|
|
AnyOf {
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "isPrivate"
|
|
|
|
value: false
|
|
|
|
}
|
|
|
|
AllOf {
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "tokenCriteriaMet"
|
|
|
|
value: true
|
|
|
|
}
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "isPrivate"
|
|
|
|
value: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2023-07-04 15:11:41 +00:00
|
|
|
}
|
2024-01-18 14:06:25 +00:00
|
|
|
|
|
|
|
// used to check if there are any visible channel permissions
|
|
|
|
readonly property var channelsPermissionsModel: SortFilterProxyModel {
|
|
|
|
id: channelsPermissionsModel
|
|
|
|
sourceModel: root.permissionsModel
|
2024-04-04 11:06:44 +00:00
|
|
|
filters: [
|
|
|
|
AnyOf {
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "permissionType"
|
|
|
|
value: Constants.permissionType.read
|
|
|
|
}
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "permissionType"
|
|
|
|
value: Constants.permissionType.viewAndPost
|
|
|
|
}
|
|
|
|
},
|
|
|
|
AnyOf {
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "isPrivate"
|
|
|
|
value: false
|
|
|
|
}
|
|
|
|
AllOf {
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "tokenCriteriaMet"
|
|
|
|
value: true
|
|
|
|
}
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "isPrivate"
|
|
|
|
value: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2024-01-18 14:06:25 +00:00
|
|
|
}
|
2023-07-04 15:11:41 +00:00
|
|
|
}
|
|
|
|
|
2023-08-02 17:39:42 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
d.initialChannelPermissions = d.getChannelPermissions()
|
|
|
|
}
|
|
|
|
|
2023-07-04 15:11:41 +00:00
|
|
|
StatusScrollView {
|
|
|
|
id: permissionsScrollView
|
|
|
|
anchors.fill: parent
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.topMargin: -Theme.padding
|
2024-03-27 12:48:17 +00:00
|
|
|
bottomPadding: eligibilityHintBubble.visible ? eligibilityHintBubble.height + eligibilityHintBubble.anchors.bottomMargin*2
|
|
|
|
: 16
|
2023-07-04 15:11:41 +00:00
|
|
|
contentWidth: availableWidth
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
width: parent.width
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: Theme.halfPadding
|
2023-07-04 15:11:41 +00:00
|
|
|
|
|
|
|
// header
|
|
|
|
RowLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.bottomMargin: 4
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: Theme.padding
|
2023-07-04 15:11:41 +00:00
|
|
|
StatusRoundedImage {
|
|
|
|
Layout.preferredWidth: 40
|
|
|
|
Layout.preferredHeight: 40
|
|
|
|
Layout.leftMargin: d.absLeftMargin
|
|
|
|
image.source: root.communityIcon
|
|
|
|
}
|
|
|
|
StatusBaseText {
|
|
|
|
font.weight: Font.Medium
|
|
|
|
text: qsTr("Permissions")
|
|
|
|
}
|
2024-03-25 18:39:45 +00:00
|
|
|
Item { Layout.fillWidth: true }
|
|
|
|
RowLayout {
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.rightMargin: Theme.halfPadding
|
2024-03-25 18:39:45 +00:00
|
|
|
spacing: 4
|
|
|
|
visible: root.requirementsCheckPending
|
|
|
|
StatusBaseText {
|
|
|
|
text: qsTr("Updating eligibility")
|
2024-10-15 19:26:12 +00:00
|
|
|
font.pixelSize: Theme.tertiaryTextFontSize
|
2024-03-25 18:39:45 +00:00
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
StatusLoadingIndicator {
|
|
|
|
Layout.preferredWidth: 12
|
|
|
|
Layout.preferredHeight: 12
|
|
|
|
}
|
|
|
|
}
|
2023-07-04 15:11:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// permission types
|
|
|
|
PermissionPanel {
|
2023-08-02 17:39:42 +00:00
|
|
|
id: joinPermissionPanel
|
2023-07-04 15:11:41 +00:00
|
|
|
permissionType: PermissionTypes.Type.Member
|
|
|
|
permissionsModel: d.joinPermissionsModel
|
|
|
|
}
|
|
|
|
PermissionPanel {
|
|
|
|
permissionType: PermissionTypes.Type.Admin
|
|
|
|
permissionsModel: d.adminPermissionsModel
|
|
|
|
}
|
2024-03-27 12:48:17 +00:00
|
|
|
PermissionPanel {
|
|
|
|
id: tokenMasterPermissionPanel
|
|
|
|
permissionType: PermissionTypes.Type.TokenMaster
|
|
|
|
permissionsModel: d.tokenMasterPermissionsModel
|
|
|
|
}
|
2023-07-04 15:11:41 +00:00
|
|
|
|
|
|
|
Repeater { // channel repeater
|
2023-08-02 17:39:42 +00:00
|
|
|
id: channelPermissionsPanel
|
2023-07-20 18:59:54 +00:00
|
|
|
model: d.uniquePermissionChannels
|
2023-07-04 15:11:41 +00:00
|
|
|
delegate: ChannelPermissionPanel {}
|
2023-08-02 17:39:42 +00:00
|
|
|
readonly property bool anyPermissionLost: {
|
|
|
|
for (let i = 0; i < channelPermissionsPanel.count; i++) {
|
|
|
|
const channel = channelPermissionsPanel.itemAt(i)
|
|
|
|
if (channel && channel.anyPermissionLost)
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2023-07-04 15:11:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-27 12:48:17 +00:00
|
|
|
CommunityEligibilityTag {
|
|
|
|
id: eligibilityHintBubble
|
2024-05-16 09:28:06 +00:00
|
|
|
visible: !root.checkingPermissionToJoinInProgress && root.joinPermissionsCheckCompletedWithoutErrors
|
2024-03-27 12:48:17 +00:00
|
|
|
eligibleToJoinAs: root.eligibleToJoinAs
|
2024-04-12 09:52:53 +00:00
|
|
|
isEditMode: root.isEditMode
|
|
|
|
isDirty: root.isDirty
|
2024-03-27 12:48:17 +00:00
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: 24
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
|
|
|
|
2023-07-04 15:11:41 +00:00
|
|
|
component PanelBg: Rectangle {
|
|
|
|
color: Theme.palette.statusListItem.backgroundColor
|
|
|
|
border.width: 1
|
|
|
|
border.color: Theme.palette.baseColor2
|
2024-10-15 19:26:12 +00:00
|
|
|
radius: Theme.radius
|
2023-07-04 15:11:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
component PanelIcon: StatusRoundIcon {
|
|
|
|
Layout.preferredWidth: 40
|
|
|
|
Layout.preferredHeight: 40
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
asset.name: {
|
|
|
|
switch (permissionType) {
|
2024-03-27 12:48:17 +00:00
|
|
|
case PermissionTypes.Type.TokenMaster:
|
|
|
|
return "arbitrator"
|
2023-07-04 15:11:41 +00:00
|
|
|
case PermissionTypes.Type.Admin:
|
|
|
|
return "admin"
|
|
|
|
case PermissionTypes.Type.Member:
|
|
|
|
return "communities"
|
|
|
|
default:
|
|
|
|
return "channel"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
radius: height/2
|
|
|
|
}
|
|
|
|
|
|
|
|
component PanelHeading: StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
elide: Text.ElideRight
|
|
|
|
font.weight: Font.Medium
|
|
|
|
text: {
|
|
|
|
switch (permissionType) {
|
|
|
|
case PermissionTypes.Type.Admin:
|
|
|
|
return qsTr("Become an admin")
|
|
|
|
case PermissionTypes.Type.Member:
|
|
|
|
return qsTr("Join %1").arg(root.communityName)
|
2024-01-18 14:06:25 +00:00
|
|
|
case PermissionTypes.Type.TokenMaster:
|
|
|
|
return qsTr("Become a TokenMaster")
|
2023-07-04 15:11:41 +00:00
|
|
|
default:
|
2023-07-20 18:59:54 +00:00
|
|
|
return d.uniquePermissionChannels[index][1]
|
2023-07-04 15:11:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
component SinglePermissionFlow: Flow {
|
2023-08-02 17:39:42 +00:00
|
|
|
Layout.fillWidth: true
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: Theme.halfPadding
|
2023-07-04 15:11:41 +00:00
|
|
|
Repeater {
|
|
|
|
model: HoldingsSelectionModel {
|
|
|
|
sourceModel: model.holdingsListModel
|
|
|
|
assetsModel: root.assetsModel
|
|
|
|
collectiblesModel: root.collectiblesModel
|
|
|
|
}
|
|
|
|
delegate: Row {
|
|
|
|
spacing: 4
|
|
|
|
StatusRoundedImage {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
width: 16
|
|
|
|
height: 16
|
|
|
|
image.source: model.imageSource
|
2024-03-27 12:48:17 +00:00
|
|
|
visible: !isError
|
2023-07-04 15:11:41 +00:00
|
|
|
}
|
|
|
|
StatusBaseText {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
font.pixelSize: Theme.tertiaryTextFontSize
|
2024-04-12 09:52:53 +00:00
|
|
|
text: !!model.text ? model.text : ""
|
2024-04-04 11:06:44 +00:00
|
|
|
color: model.available ? Theme.palette.successColor1 : Theme.palette.baseColor1
|
2023-07-04 15:11:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
component PermissionPanel: Control {
|
|
|
|
id: permissionPanel
|
|
|
|
property int permissionType: PermissionTypes.Type.None
|
|
|
|
property var permissionsModel
|
|
|
|
|
|
|
|
readonly property bool tokenCriteriaMet: overallPermissionRow.tokenCriteriaMet
|
|
|
|
|
|
|
|
visible: permissionsModel.count
|
|
|
|
Layout.fillWidth: true
|
|
|
|
padding: d.absLeftMargin
|
|
|
|
background: PanelBg {}
|
|
|
|
contentItem: RowLayout {
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: Theme.padding
|
2023-07-04 15:11:41 +00:00
|
|
|
PanelIcon {}
|
|
|
|
ColumnLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
PanelHeading {}
|
|
|
|
Rectangle {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: grid.implicitHeight + grid.anchors.margins*2
|
|
|
|
border.width: 1
|
|
|
|
border.color: d.tableBorderColor
|
2024-10-15 19:26:12 +00:00
|
|
|
radius: Theme.radius
|
2023-07-04 15:11:41 +00:00
|
|
|
color: "transparent"
|
|
|
|
|
|
|
|
GridLayout {
|
|
|
|
id: grid
|
|
|
|
anchors.fill: parent
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.margins: Theme.halfPadding
|
|
|
|
rowSpacing: Theme.halfPadding
|
|
|
|
columnSpacing: Theme.halfPadding
|
2023-07-04 15:11:41 +00:00
|
|
|
columns: 2
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: permissionsRepeater
|
|
|
|
|
|
|
|
property int revision
|
2023-08-02 17:39:42 +00:00
|
|
|
onItemAdded: revision++
|
|
|
|
onItemRemoved: revision++
|
2023-07-04 15:11:41 +00:00
|
|
|
|
|
|
|
model: permissionPanel.permissionsModel
|
2023-08-02 17:39:42 +00:00
|
|
|
delegate: ColumnLayout {
|
2023-07-04 15:11:41 +00:00
|
|
|
Layout.column: 0
|
|
|
|
Layout.row: index
|
|
|
|
Layout.fillWidth: true
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: Theme.halfPadding
|
2023-07-04 15:11:41 +00:00
|
|
|
|
|
|
|
readonly property bool tokenCriteriaMet: model.tokenCriteriaMet ?? false
|
|
|
|
onTokenCriteriaMetChanged: permissionsRepeater.revision++
|
|
|
|
|
|
|
|
SinglePermissionFlow {}
|
|
|
|
|
|
|
|
Rectangle {
|
2023-08-02 17:39:42 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: -grid.anchors.leftMargin
|
|
|
|
Layout.rightMargin: -grid.anchors.rightMargin
|
|
|
|
Layout.preferredHeight: 1
|
2023-07-04 15:11:41 +00:00
|
|
|
color: d.tableBorderColor
|
|
|
|
visible: index < permissionsRepeater.count - 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RowLayout {
|
|
|
|
id: overallPermissionRow
|
|
|
|
Layout.column: 1
|
|
|
|
Layout.rowSpan: permissionsRepeater.count || 1
|
|
|
|
Layout.preferredWidth: 110
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
readonly property bool tokenCriteriaMet: {
|
2023-08-02 17:39:42 +00:00
|
|
|
permissionsRepeater.revision
|
|
|
|
for (var i = 0; i < permissionsRepeater.count; i++) { // NB no let/const here b/c of https://bugreports.qt.io/browse/QTBUG-91917
|
2023-07-04 15:11:41 +00:00
|
|
|
var permissionItem = permissionsRepeater.itemAt(i);
|
2023-08-02 17:39:42 +00:00
|
|
|
if (permissionItem && permissionItem.tokenCriteriaMet)
|
2023-07-04 15:11:41 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
Layout.preferredWidth: 1
|
|
|
|
Layout.fillHeight: true
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.topMargin: -Theme.halfPadding
|
|
|
|
Layout.bottomMargin: -Theme.halfPadding
|
2023-07-04 15:11:41 +00:00
|
|
|
color: d.tableBorderColor
|
|
|
|
}
|
|
|
|
Row {
|
|
|
|
Layout.alignment: Qt.AlignCenter
|
2024-03-27 12:48:17 +00:00
|
|
|
spacing: 4
|
2023-07-04 15:11:41 +00:00
|
|
|
StatusIcon {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
width: 16
|
|
|
|
height: 16
|
|
|
|
icon: overallPermissionRow.tokenCriteriaMet ? "tiny/checkmark" : "tiny/secure"
|
2023-08-02 17:39:42 +00:00
|
|
|
color: {
|
|
|
|
if (d.lostPermissionToJoin)
|
|
|
|
return Theme.palette.dangerColor1
|
|
|
|
if (overallPermissionRow.tokenCriteriaMet)
|
|
|
|
return Theme.palette.successColor1
|
|
|
|
return Theme.palette.baseColor1
|
|
|
|
}
|
2023-07-04 15:11:41 +00:00
|
|
|
}
|
|
|
|
StatusBaseText {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
font.pixelSize: Theme.tertiaryTextFontSize
|
|
|
|
text: {
|
|
|
|
switch (permissionPanel.permissionType) {
|
|
|
|
case PermissionTypes.Type.Admin:
|
|
|
|
return qsTr("Admin")
|
|
|
|
case PermissionTypes.Type.Member:
|
|
|
|
return qsTr("Join")
|
|
|
|
case PermissionTypes.Type.Read:
|
|
|
|
return qsTr("View only")
|
|
|
|
case PermissionTypes.Type.ViewAndPost:
|
|
|
|
return qsTr("View & post")
|
2024-01-18 14:06:25 +00:00
|
|
|
case PermissionTypes.Type.TokenMaster:
|
|
|
|
return qsTr("TokenMaster")
|
2023-07-04 15:11:41 +00:00
|
|
|
default:
|
|
|
|
return "???"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-02 17:39:42 +00:00
|
|
|
color: {
|
|
|
|
if (d.lostPermissionToJoin)
|
|
|
|
return Theme.palette.dangerColor1
|
|
|
|
if (overallPermissionRow.tokenCriteriaMet)
|
|
|
|
return Theme.palette.directColor1
|
|
|
|
return Theme.palette.baseColor1
|
|
|
|
}
|
2023-07-04 15:11:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
component ChannelPermissionPanel: Control {
|
|
|
|
id: channelPermsPanel
|
|
|
|
Layout.fillWidth: true
|
|
|
|
spacing: 10
|
|
|
|
padding: d.absLeftMargin
|
|
|
|
background: PanelBg {}
|
|
|
|
|
2024-01-18 14:06:25 +00:00
|
|
|
visible: {
|
|
|
|
for (var i = 0; i < channelPermsRepeater.count; i++) {
|
|
|
|
var chanPermissionItem = channelPermsRepeater.itemAt(i);
|
|
|
|
if (chanPermissionItem.channelPermissionsModel.count > 0)
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2023-08-02 17:39:42 +00:00
|
|
|
readonly property string channelKey: modelData[0]
|
|
|
|
readonly property bool readPermissionMet: channelPermsRepeater.count > 0 ? channelPermsRepeater.itemAt(0).tokenCriteriaMet : false
|
|
|
|
readonly property bool viewAndPostPermissionMet: channelPermsRepeater.count > 1 ? channelPermsRepeater.itemAt(1).tokenCriteriaMet : false
|
|
|
|
readonly property bool anyPermissionLost: channelPermsRepeater.count > 0 ? channelPermsRepeater.itemAt(0).permissionLost || channelPermsRepeater.itemAt(1).permissionLost : false
|
2023-07-04 15:11:41 +00:00
|
|
|
|
|
|
|
contentItem: RowLayout {
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: Theme.padding
|
2023-07-04 15:11:41 +00:00
|
|
|
PanelIcon {}
|
|
|
|
ColumnLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: Theme.smallPadding
|
2023-07-04 15:11:41 +00:00
|
|
|
PanelHeading {}
|
|
|
|
Repeater { // permissions repeater
|
2023-08-02 17:39:42 +00:00
|
|
|
id: channelPermsRepeater
|
2023-07-04 15:11:41 +00:00
|
|
|
model: [PermissionTypes.Type.Read, PermissionTypes.Type.ViewAndPost]
|
|
|
|
|
|
|
|
delegate: Rectangle {
|
|
|
|
id: channelPermsSubPanel
|
|
|
|
|
|
|
|
readonly property int permissionType: modelData
|
2023-08-02 17:39:42 +00:00
|
|
|
readonly property alias tokenCriteriaMet: overallPermissionRow2.tokenCriteriaMet
|
|
|
|
readonly property bool permissionLost: d.initialChannelPermissions[channelPermsPanel.channelKey][index] && !tokenCriteriaMet
|
2024-01-18 14:06:25 +00:00
|
|
|
readonly property alias channelPermissionsModel: permissionsRepeater2.model
|
2023-07-04 15:11:41 +00:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: grid2.implicitHeight + grid2.anchors.margins*2
|
|
|
|
border.width: 1
|
|
|
|
border.color: d.tableBorderColor
|
2024-10-15 19:26:12 +00:00
|
|
|
radius: Theme.radius
|
2023-07-04 15:11:41 +00:00
|
|
|
color: "transparent"
|
2024-01-18 14:06:25 +00:00
|
|
|
visible: permissionsRepeater2.model.count > 0
|
2023-07-04 15:11:41 +00:00
|
|
|
|
|
|
|
GridLayout {
|
|
|
|
id: grid2
|
|
|
|
anchors.fill: parent
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.margins: Theme.halfPadding
|
|
|
|
rowSpacing: Theme.halfPadding
|
|
|
|
columnSpacing: Theme.halfPadding
|
2023-07-04 15:11:41 +00:00
|
|
|
columns: 2
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: permissionsRepeater2
|
|
|
|
|
|
|
|
property int revision
|
2023-08-02 17:39:42 +00:00
|
|
|
onItemAdded: revision++
|
|
|
|
onItemRemoved: revision++
|
2023-07-04 15:11:41 +00:00
|
|
|
|
|
|
|
model: SortFilterProxyModel {
|
|
|
|
id: channelPermissionsModel
|
2024-04-04 11:06:44 +00:00
|
|
|
sourceModel: d.channelsPermissionsModel
|
|
|
|
|
|
|
|
function filterPredicate(channelsListModel) {
|
|
|
|
return ModelUtils.contains(channelsListModel, "key", channelPermsPanel.channelKey)
|
2023-07-04 15:11:41 +00:00
|
|
|
}
|
2024-04-04 11:06:44 +00:00
|
|
|
|
|
|
|
filters: [
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "permissionType"
|
|
|
|
value: channelPermsSubPanel.permissionType
|
|
|
|
},
|
|
|
|
FastExpressionFilter {
|
|
|
|
expression: channelPermissionsModel.filterPredicate(model.channelsListModel) // filter and group by channel "key"
|
|
|
|
expectedRoles: ["channelsListModel"]
|
|
|
|
}
|
|
|
|
]
|
2023-07-04 15:11:41 +00:00
|
|
|
}
|
2023-08-02 17:39:42 +00:00
|
|
|
delegate: ColumnLayout {
|
2023-07-04 15:11:41 +00:00
|
|
|
Layout.column: 0
|
|
|
|
Layout.row: index
|
|
|
|
Layout.fillWidth: true
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: Theme.halfPadding
|
2023-07-04 15:11:41 +00:00
|
|
|
|
|
|
|
readonly property bool tokenCriteriaMet: model.tokenCriteriaMet ?? false
|
|
|
|
onTokenCriteriaMetChanged: permissionsRepeater2.revision++
|
|
|
|
|
|
|
|
SinglePermissionFlow {}
|
|
|
|
|
|
|
|
Rectangle {
|
2023-08-02 17:39:42 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: -grid2.anchors.leftMargin
|
|
|
|
Layout.rightMargin: -grid2.anchors.rightMargin
|
|
|
|
Layout.preferredHeight: 1
|
2023-07-04 15:11:41 +00:00
|
|
|
color: d.tableBorderColor
|
|
|
|
visible: index < permissionsRepeater2.count - 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: overallPermissionRow2
|
|
|
|
Layout.column: 1
|
|
|
|
Layout.rowSpan: channelPermissionsModel.count || 1
|
|
|
|
Layout.preferredWidth: 110
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
readonly property bool tokenCriteriaMet: {
|
|
|
|
permissionsRepeater2.revision
|
2023-08-02 17:39:42 +00:00
|
|
|
for (var i = 0; i < permissionsRepeater2.count; i++) { // NB no let/const here b/c of https://bugreports.qt.io/browse/QTBUG-91917
|
2023-07-04 15:11:41 +00:00
|
|
|
const permissionItem = permissionsRepeater2.itemAt(i);
|
2023-08-02 17:39:42 +00:00
|
|
|
if (permissionItem && permissionItem.tokenCriteriaMet)
|
2023-07-04 15:11:41 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
Layout.preferredWidth: 1
|
|
|
|
Layout.fillHeight: true
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.topMargin: -Theme.halfPadding
|
|
|
|
Layout.bottomMargin: -Theme.halfPadding
|
2023-07-04 15:11:41 +00:00
|
|
|
color: d.tableBorderColor
|
|
|
|
}
|
|
|
|
Row {
|
|
|
|
Layout.alignment: Qt.AlignCenter
|
2024-03-27 12:48:17 +00:00
|
|
|
spacing: 4
|
2023-07-04 15:11:41 +00:00
|
|
|
StatusIcon {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
width: 16
|
|
|
|
height: 16
|
|
|
|
icon: overallPermissionRow2.tokenCriteriaMet ? "tiny/checkmark" : "tiny/secure"
|
2023-08-02 17:39:42 +00:00
|
|
|
color: {
|
|
|
|
if (channelPermsSubPanel.permissionLost)
|
|
|
|
return Theme.palette.dangerColor1
|
|
|
|
if (overallPermissionRow2.tokenCriteriaMet)
|
|
|
|
return Theme.palette.successColor1
|
|
|
|
return Theme.palette.baseColor1
|
|
|
|
}
|
2023-07-04 15:11:41 +00:00
|
|
|
}
|
|
|
|
StatusBaseText {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
font.pixelSize: Theme.tertiaryTextFontSize
|
|
|
|
text: {
|
|
|
|
switch (channelPermsSubPanel.permissionType) {
|
|
|
|
case PermissionTypes.Type.Read:
|
|
|
|
return qsTr("View only")
|
|
|
|
case PermissionTypes.Type.ViewAndPost:
|
|
|
|
return qsTr("View & post")
|
|
|
|
default:
|
|
|
|
return "???"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-02 17:39:42 +00:00
|
|
|
color: {
|
|
|
|
if (channelPermsSubPanel.permissionLost)
|
|
|
|
return Theme.palette.dangerColor1
|
|
|
|
if (overallPermissionRow2.tokenCriteriaMet)
|
|
|
|
return Theme.palette.directColor1
|
|
|
|
return Theme.palette.baseColor1
|
|
|
|
}
|
2023-07-04 15:11:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|