2023-06-29 11:54:04 +00:00
|
|
|
import QtQuick 2.15
|
2023-06-29 22:05:46 +00:00
|
|
|
import QtQuick.Controls 2.15
|
2022-06-09 15:27:14 +00:00
|
|
|
|
2023-06-23 06:17:04 +00:00
|
|
|
import AppLayouts.Communities.controls 1.0
|
|
|
|
import AppLayouts.Communities.layouts 1.0
|
|
|
|
import AppLayouts.Communities.views 1.0
|
2022-06-09 15:27:14 +00:00
|
|
|
|
fix(permissions): fix hang when all channel perm check return (#14259)
* fix(permissions): fix hang when all channel perm check return
Fixes #14234
The problem was that we updated **all** the models from **all** the channels of a community each time the channel requirement checks returned.
The fix is to first of all, make sure we don't call that check too often. It sometimes got called twice in a row by accident.
The other better fix is to check if anything actually changed before updating. This solves the issue almost entirely. Since the permissions almost never change, the updates now take only a second.
* fix(permisisons): never run permission checks for privileged users
Also fixes #14234 but for admins, TMs and Owners.
Admins+ were still getting the hang, because the permission checks always returned something different than the models, because the models knew that admins have access to everything, but the permission check was running as if it were a normal user (I think, un-tested).
Anyway, the solution is more simple, we never need to run the permission checks on admins+, because they always have access to everything!
* fix(Communities): prevent channels model from emitting unnecessary signals
Closes: #14274
* chore(Communities): improve channels metadata lookup performance
ChannelsSelectionModel is removed, replaced with plain LeftJoinModel.
Transformations of left-side model are done in a single place, not in
every delegate making the join.
* only call update functions when there is something to update + move permission model creation when needed
---------
Co-authored-by: Michał Cieślak <michalcieslak@status.im>
2024-04-04 15:26:44 +00:00
|
|
|
import StatusQ 0.1
|
2023-06-29 22:05:46 +00:00
|
|
|
import StatusQ.Controls 0.1
|
fix(permissions): fix hang when all channel perm check return (#14259)
* fix(permissions): fix hang when all channel perm check return
Fixes #14234
The problem was that we updated **all** the models from **all** the channels of a community each time the channel requirement checks returned.
The fix is to first of all, make sure we don't call that check too often. It sometimes got called twice in a row by accident.
The other better fix is to check if anything actually changed before updating. This solves the issue almost entirely. Since the permissions almost never change, the updates now take only a second.
* fix(permisisons): never run permission checks for privileged users
Also fixes #14234 but for admins, TMs and Owners.
Admins+ were still getting the hang, because the permission checks always returned something different than the models, because the models knew that admins have access to everything, but the permission check was running as if it were a normal user (I think, un-tested).
Anyway, the solution is more simple, we never need to run the permission checks on admins+, because they always have access to everything!
* fix(Communities): prevent channels model from emitting unnecessary signals
Closes: #14274
* chore(Communities): improve channels metadata lookup performance
ChannelsSelectionModel is removed, replaced with plain LeftJoinModel.
Transformations of left-side model are done in a single place, not in
every delegate making the join.
* only call update functions when there is something to update + move permission model creation when needed
---------
Co-authored-by: Michał Cieślak <michalcieslak@status.im>
2024-04-04 15:26:44 +00:00
|
|
|
import StatusQ.Core 0.1
|
2023-02-14 20:39:18 +00:00
|
|
|
import StatusQ.Core.Utils 0.1
|
2023-02-17 11:53:18 +00:00
|
|
|
|
2024-02-06 09:31:36 +00:00
|
|
|
import utils 1.0
|
2023-06-29 22:05:46 +00:00
|
|
|
import shared.popups 1.0
|
|
|
|
|
fix(permissions): fix hang when all channel perm check return (#14259)
* fix(permissions): fix hang when all channel perm check return
Fixes #14234
The problem was that we updated **all** the models from **all** the channels of a community each time the channel requirement checks returned.
The fix is to first of all, make sure we don't call that check too often. It sometimes got called twice in a row by accident.
The other better fix is to check if anything actually changed before updating. This solves the issue almost entirely. Since the permissions almost never change, the updates now take only a second.
* fix(permisisons): never run permission checks for privileged users
Also fixes #14234 but for admins, TMs and Owners.
Admins+ were still getting the hang, because the permission checks always returned something different than the models, because the models knew that admins have access to everything, but the permission check was running as if it were a normal user (I think, un-tested).
Anyway, the solution is more simple, we never need to run the permission checks on admins+, because they always have access to everything!
* fix(Communities): prevent channels model from emitting unnecessary signals
Closes: #14274
* chore(Communities): improve channels metadata lookup performance
ChannelsSelectionModel is removed, replaced with plain LeftJoinModel.
Transformations of left-side model are done in a single place, not in
every delegate making the join.
* only call update functions when there is something to update + move permission model creation when needed
---------
Co-authored-by: Michał Cieślak <michalcieslak@status.im>
2024-04-04 15:26:44 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
StackView {
|
2022-06-09 15:27:14 +00:00
|
|
|
id: root
|
|
|
|
|
2023-03-07 08:47:04 +00:00
|
|
|
required property var permissionsModel
|
|
|
|
required property var assetsModel
|
|
|
|
required property var collectiblesModel
|
|
|
|
required property var channelsModel
|
2024-02-06 09:31:36 +00:00
|
|
|
property bool showChannelSelector: true
|
|
|
|
property alias initialPage: initialItem
|
2023-03-07 08:47:04 +00:00
|
|
|
|
2023-06-21 14:20:39 +00:00
|
|
|
// id, name, image, color, owner properties expected
|
2023-03-07 08:47:04 +00:00
|
|
|
required property var communityDetails
|
|
|
|
|
2022-11-25 17:35:30 +00:00
|
|
|
property int viewWidth: 560 // by design
|
2023-06-29 22:05:46 +00:00
|
|
|
property string previousPageName: depth > 1 ? qsTr("Permissions") : ""
|
2022-11-25 17:35:30 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
signal createPermissionRequested(int permissionType, var holdings,
|
|
|
|
var channels, bool isPrivate)
|
|
|
|
signal updatePermissionRequested(string key, int permissionType,
|
|
|
|
var holdings, var channels, bool isPrivate)
|
2023-03-07 08:47:04 +00:00
|
|
|
signal removePermissionRequested(string key)
|
2023-07-05 21:43:15 +00:00
|
|
|
signal navigateToMintTokenSettings(bool isAssetType)
|
2023-03-24 12:41:46 +00:00
|
|
|
|
2022-12-07 16:14:36 +00:00
|
|
|
function navigateBack() {
|
2023-06-29 22:05:46 +00:00
|
|
|
if (depth === 2 && currentItem.toast.active)
|
|
|
|
currentItem.toast.notifyDirty()
|
|
|
|
else
|
|
|
|
pop(StackView.Immediate)
|
2022-09-13 16:17:54 +00:00
|
|
|
}
|
|
|
|
|
2024-02-06 09:31:36 +00:00
|
|
|
function pushEditView(properties) {
|
|
|
|
root.push(newPermissionView, properties, StackView.Immediate);
|
|
|
|
}
|
|
|
|
|
fix(permissions): fix hang when all channel perm check return (#14259)
* fix(permissions): fix hang when all channel perm check return
Fixes #14234
The problem was that we updated **all** the models from **all** the channels of a community each time the channel requirement checks returned.
The fix is to first of all, make sure we don't call that check too often. It sometimes got called twice in a row by accident.
The other better fix is to check if anything actually changed before updating. This solves the issue almost entirely. Since the permissions almost never change, the updates now take only a second.
* fix(permisisons): never run permission checks for privileged users
Also fixes #14234 but for admins, TMs and Owners.
Admins+ were still getting the hang, because the permission checks always returned something different than the models, because the models knew that admins have access to everything, but the permission check was running as if it were a normal user (I think, un-tested).
Anyway, the solution is more simple, we never need to run the permission checks on admins+, because they always have access to everything!
* fix(Communities): prevent channels model from emitting unnecessary signals
Closes: #14274
* chore(Communities): improve channels metadata lookup performance
ChannelsSelectionModel is removed, replaced with plain LeftJoinModel.
Transformations of left-side model are done in a single place, not in
every delegate making the join.
* only call update functions when there is something to update + move permission model creation when needed
---------
Co-authored-by: Michał Cieślak <michalcieslak@status.im>
2024-04-04 15:26:44 +00:00
|
|
|
SortFilterProxyModel {
|
|
|
|
id: allChannelsTransformed
|
|
|
|
|
|
|
|
sourceModel: root.channelsModel
|
|
|
|
|
|
|
|
proxyRoles: [
|
|
|
|
FastExpressionRole {
|
|
|
|
name: "key"
|
|
|
|
expression: model.itemId ?? ""
|
|
|
|
expectedRoles: ["itemId"]
|
|
|
|
},
|
|
|
|
FastExpressionRole {
|
|
|
|
name: "text"
|
|
|
|
expression: "#" + model.name
|
|
|
|
expectedRoles: ["name"]
|
|
|
|
},
|
|
|
|
FastExpressionRole {
|
|
|
|
name: "imageSource"
|
|
|
|
expression: model.icon
|
|
|
|
expectedRoles: ["icon"]
|
|
|
|
},
|
|
|
|
FastExpressionRole {
|
|
|
|
name: "operator"
|
|
|
|
|
|
|
|
// Direct call for singleton enum is not handled properly by SortFilterProxyModel.
|
|
|
|
readonly property int none: OperatorsUtils.Operators.None
|
|
|
|
|
|
|
|
expression: none
|
|
|
|
expectedRoles: []
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
// Community Permissions possible view contents:
|
|
|
|
initialItem: SettingsPage {
|
2024-02-06 09:31:36 +00:00
|
|
|
id: initialItem
|
2023-06-29 22:05:46 +00:00
|
|
|
implicitWidth: 0
|
2023-06-30 14:36:46 +00:00
|
|
|
|
|
|
|
title: qsTr("Permissions")
|
2023-02-08 10:13:16 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
buttons: StatusButton {
|
2023-06-30 15:10:45 +00:00
|
|
|
objectName: "addNewItemButton"
|
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
text: qsTr("Add new permission")
|
2022-11-24 16:23:54 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
onClicked: root.push(newPermissionView, StackView.Immediate)
|
|
|
|
}
|
2023-02-20 08:31:39 +00:00
|
|
|
|
2024-02-06 09:31:36 +00:00
|
|
|
contentItem: StatusScrollView {
|
|
|
|
contentHeight: (permissionsView.height + topPadding)
|
|
|
|
topPadding: permissionsView.topPadding
|
|
|
|
padding: 0
|
|
|
|
PermissionsView {
|
|
|
|
id: permissionsView
|
|
|
|
permissionsModel: root.permissionsModel
|
|
|
|
assetsModel: root.assetsModel
|
|
|
|
collectiblesModel: root.collectiblesModel
|
fix(permissions): fix hang when all channel perm check return (#14259)
* fix(permissions): fix hang when all channel perm check return
Fixes #14234
The problem was that we updated **all** the models from **all** the channels of a community each time the channel requirement checks returned.
The fix is to first of all, make sure we don't call that check too often. It sometimes got called twice in a row by accident.
The other better fix is to check if anything actually changed before updating. This solves the issue almost entirely. Since the permissions almost never change, the updates now take only a second.
* fix(permisisons): never run permission checks for privileged users
Also fixes #14234 but for admins, TMs and Owners.
Admins+ were still getting the hang, because the permission checks always returned something different than the models, because the models knew that admins have access to everything, but the permission check was running as if it were a normal user (I think, un-tested).
Anyway, the solution is more simple, we never need to run the permission checks on admins+, because they always have access to everything!
* fix(Communities): prevent channels model from emitting unnecessary signals
Closes: #14274
* chore(Communities): improve channels metadata lookup performance
ChannelsSelectionModel is removed, replaced with plain LeftJoinModel.
Transformations of left-side model are done in a single place, not in
every delegate making the join.
* only call update functions when there is something to update + move permission model creation when needed
---------
Co-authored-by: Michał Cieślak <michalcieslak@status.im>
2024-04-04 15:26:44 +00:00
|
|
|
channelsModel: allChannelsTransformed
|
|
|
|
|
2024-02-06 09:31:36 +00:00
|
|
|
communityDetails: root.communityDetails
|
|
|
|
|
|
|
|
viewWidth: root.viewWidth
|
2022-11-24 16:23:54 +00:00
|
|
|
|
2024-02-06 09:31:36 +00:00
|
|
|
onEditPermissionRequested: {
|
|
|
|
const item = ModelUtils.get(root.permissionsModel, index)
|
2022-11-24 16:23:54 +00:00
|
|
|
|
2024-02-06 09:31:36 +00:00
|
|
|
const properties = {
|
|
|
|
permissionKeyToEdit: item.key,
|
|
|
|
holdingsToEditModel: item.holdingsListModel,
|
|
|
|
channelsToEditModel: item.channelsListModel,
|
|
|
|
permissionTypeToEdit: item.permissionType,
|
|
|
|
isPrivateToEditValue: item.isPrivate
|
|
|
|
}
|
2022-06-09 15:27:14 +00:00
|
|
|
|
2024-02-06 09:31:36 +00:00
|
|
|
root.pushEditView(properties);
|
2023-06-29 22:05:46 +00:00
|
|
|
}
|
2022-06-09 15:27:14 +00:00
|
|
|
|
2024-02-06 09:31:36 +00:00
|
|
|
onDuplicatePermissionRequested: {
|
|
|
|
const item = ModelUtils.get(root.permissionsModel, index)
|
2022-11-25 17:35:30 +00:00
|
|
|
|
2024-02-06 09:31:36 +00:00
|
|
|
const properties = {
|
|
|
|
holdingsToEditModel: item.holdingsListModel,
|
|
|
|
channelsToEditModel: item.channelsListModel,
|
|
|
|
permissionTypeToEdit: item.permissionType,
|
|
|
|
isPrivateToEditValue: item.isPrivate
|
|
|
|
}
|
2023-02-08 10:13:16 +00:00
|
|
|
|
2024-02-06 09:31:36 +00:00
|
|
|
root.pushEditView(properties);
|
2023-06-29 22:05:46 +00:00
|
|
|
}
|
2022-11-24 16:23:54 +00:00
|
|
|
|
2024-02-06 09:31:36 +00:00
|
|
|
onRemovePermissionRequested: {
|
|
|
|
const key = ModelUtils.get(root.permissionsModel, index, "key")
|
|
|
|
root.removePermissionRequested(key)
|
|
|
|
}
|
2023-06-29 22:05:46 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-25 17:35:30 +00:00
|
|
|
}
|
|
|
|
|
2022-06-09 15:27:14 +00:00
|
|
|
Component {
|
|
|
|
id: newPermissionView
|
2023-02-17 11:53:18 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
SettingsPage {
|
|
|
|
id: newPermissionViewPage
|
|
|
|
implicitWidth: 0
|
2023-06-30 14:36:46 +00:00
|
|
|
title: isEditState ? qsTr("Edit permission") : qsTr("New permission")
|
2023-02-08 23:22:57 +00:00
|
|
|
|
2024-02-07 10:30:46 +00:00
|
|
|
property alias isSaveEnabled: editPermissionView.saveEnabled
|
2024-02-06 09:31:36 +00:00
|
|
|
property alias isPrivateToEditValue: editPermissionView.isPrivate
|
|
|
|
property alias permissionTypeToEdit: editPermissionView.permissionType
|
2023-06-29 22:05:46 +00:00
|
|
|
property alias holdingsToEditModel: editPermissionView.selectedHoldingsModel
|
|
|
|
property alias channelsToEditModel: editPermissionView.selectedChannelsModel
|
2024-02-06 09:31:36 +00:00
|
|
|
|
|
|
|
property bool holdingsRequired: editPermissionView.dirtyValues.holdingsRequired
|
2023-02-11 19:03:57 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
property string permissionKeyToEdit
|
|
|
|
readonly property bool isEditState: !!permissionKeyToEdit
|
2024-02-06 09:31:36 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
readonly property alias toast: settingsDirtyToastMessage
|
2023-02-11 19:03:57 +00:00
|
|
|
|
2024-02-06 09:31:36 +00:00
|
|
|
function resetChanges() {
|
|
|
|
editPermissionView.resetChanges();
|
|
|
|
}
|
|
|
|
function updatePermission() {
|
|
|
|
editPermissionView.saveChanges();
|
|
|
|
}
|
|
|
|
function createPermission() {
|
|
|
|
editPermissionView.createPermissionClicked();
|
|
|
|
}
|
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
contentItem: EditPermissionView {
|
|
|
|
id: editPermissionView
|
2023-04-04 14:10:37 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
viewWidth: root.viewWidth
|
2023-02-14 23:53:01 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
assetsModel: root.assetsModel
|
|
|
|
collectiblesModel: root.collectiblesModel
|
fix(permissions): fix hang when all channel perm check return (#14259)
* fix(permissions): fix hang when all channel perm check return
Fixes #14234
The problem was that we updated **all** the models from **all** the channels of a community each time the channel requirement checks returned.
The fix is to first of all, make sure we don't call that check too often. It sometimes got called twice in a row by accident.
The other better fix is to check if anything actually changed before updating. This solves the issue almost entirely. Since the permissions almost never change, the updates now take only a second.
* fix(permisisons): never run permission checks for privileged users
Also fixes #14234 but for admins, TMs and Owners.
Admins+ were still getting the hang, because the permission checks always returned something different than the models, because the models knew that admins have access to everything, but the permission check was running as if it were a normal user (I think, un-tested).
Anyway, the solution is more simple, we never need to run the permission checks on admins+, because they always have access to everything!
* fix(Communities): prevent channels model from emitting unnecessary signals
Closes: #14274
* chore(Communities): improve channels metadata lookup performance
ChannelsSelectionModel is removed, replaced with plain LeftJoinModel.
Transformations of left-side model are done in a single place, not in
every delegate making the join.
* only call update functions when there is something to update + move permission model creation when needed
---------
Co-authored-by: Michał Cieślak <michalcieslak@status.im>
2024-04-04 15:26:44 +00:00
|
|
|
channelsModel: allChannelsTransformed
|
2023-06-29 22:05:46 +00:00
|
|
|
communityDetails: root.communityDetails
|
2024-02-06 09:31:36 +00:00
|
|
|
showChannelSelector: root.showChannelSelector
|
2023-06-29 22:05:46 +00:00
|
|
|
isEditState: newPermissionViewPage.isEditState
|
|
|
|
holdingsRequired: selectedHoldingsModel
|
|
|
|
? selectedHoldingsModel.count > 0 : false
|
2023-02-14 23:53:01 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
permissionDuplicated: {
|
|
|
|
// dependencies
|
|
|
|
holdingsTracker.revision
|
|
|
|
channelsTracker.revision
|
|
|
|
editPermissionView.dirtyValues.permissionType
|
|
|
|
editPermissionView.dirtyValues.isPrivate
|
|
|
|
const model = root.permissionsModel
|
|
|
|
const count = model.rowCount()
|
2023-02-14 23:53:01 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
for (let i = 0; i < count; i++) {
|
|
|
|
const item = ModelUtils.get(model, i)
|
2023-02-14 23:53:01 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
if (newPermissionViewPage.permissionKeyToEdit === item.key)
|
2023-04-05 11:15:57 +00:00
|
|
|
continue
|
2023-04-04 14:10:37 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
const holdings = item.holdingsListModel
|
|
|
|
const channels = item.channelsListModel
|
|
|
|
const permissionType = item.permissionType
|
2023-04-04 14:10:37 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
const same = (a, b) => ModelUtils.checkEqualitySet(a, b, ["key"])
|
2023-02-14 23:53:01 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
if (holdings.rowCount() === 0)
|
|
|
|
if (dirtyValues.holdingsRequired)
|
|
|
|
continue
|
|
|
|
else
|
|
|
|
return true
|
|
|
|
|
|
|
|
if (holdings.rowCount() !== 0 && !dirtyValues.holdingsRequired)
|
|
|
|
continue
|
2023-02-14 23:53:01 +00:00
|
|
|
|
2024-02-07 10:30:46 +00:00
|
|
|
const channelsModel = showChannelSelector ?
|
|
|
|
dirtyValues.selectedChannelsModel :
|
|
|
|
selectedChannelsModel
|
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
if (same(dirtyValues.selectedHoldingsModel, holdings)
|
2024-02-07 10:30:46 +00:00
|
|
|
&& same(channelsModel, channels)
|
2023-06-29 22:05:46 +00:00
|
|
|
&& dirtyValues.permissionType === permissionType)
|
|
|
|
return true
|
|
|
|
}
|
2023-03-02 15:58:26 +00:00
|
|
|
|
|
|
|
return false
|
2023-06-29 22:05:46 +00:00
|
|
|
}
|
2023-03-02 15:58:26 +00:00
|
|
|
|
2024-03-18 17:28:09 +00:00
|
|
|
readonly property var permissionTypeLimitReachedOrExceeded: {
|
2023-06-29 22:05:46 +00:00
|
|
|
const type = dirtyValues.permissionType
|
|
|
|
const limit = PermissionTypes.getPermissionsCountLimit(type)
|
2023-03-02 15:58:26 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
if (limit === -1)
|
2024-03-18 17:28:09 +00:00
|
|
|
return [false, false]
|
2023-03-02 15:58:26 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
const model = root.permissionsModel
|
|
|
|
const count = model.rowCount()
|
|
|
|
let sameTypeCount = 0
|
2023-03-02 15:58:26 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
for (let i = 0; i < count; i++)
|
|
|
|
if (type === ModelUtils.get(model, i, "permissionType"))
|
|
|
|
sameTypeCount++
|
2023-02-22 12:26:02 +00:00
|
|
|
|
2024-03-18 17:28:09 +00:00
|
|
|
return [sameTypeCount >= limit, sameTypeCount > limit]
|
2023-06-29 22:05:46 +00:00
|
|
|
}
|
|
|
|
|
2024-03-18 17:28:09 +00:00
|
|
|
permissionTypeLimitReached: permissionTypeLimitReachedOrExceeded[0]
|
|
|
|
permissionTypeLimitExceeded: permissionTypeLimitReachedOrExceeded[1]
|
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
onCreatePermissionClicked: {
|
|
|
|
const holdings = dirtyValues.holdingsRequired ?
|
|
|
|
ModelUtils.modelToArray(
|
|
|
|
dirtyValues.selectedHoldingsModel,
|
|
|
|
["key", "type", "amount"]) : []
|
2023-02-22 12:26:02 +00:00
|
|
|
|
2024-02-06 09:31:36 +00:00
|
|
|
const channels = root.showChannelSelector ?
|
|
|
|
ModelUtils.modelToArray(
|
|
|
|
dirtyValues.selectedChannelsModel, ["key"]) :
|
|
|
|
ModelUtils.modelToArray(selectedChannelsModel, ["key"])
|
2023-02-08 23:22:57 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
root.createPermissionRequested(
|
|
|
|
dirtyValues.permissionType, holdings, channels,
|
|
|
|
dirtyValues.isPrivate)
|
2023-02-08 23:22:57 +00:00
|
|
|
|
2024-02-06 09:31:36 +00:00
|
|
|
if (root.showChannelSelector) {
|
|
|
|
root.pop(StackView.Immediate)
|
|
|
|
}
|
2023-06-29 22:05:46 +00:00
|
|
|
}
|
2023-03-24 12:41:46 +00:00
|
|
|
|
2023-07-05 21:43:15 +00:00
|
|
|
onNavigateToMintTokenSettings: root.navigateToMintTokenSettings(isAssetType)
|
2023-02-08 10:13:16 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
function saveChanges() {
|
2023-04-05 11:15:57 +00:00
|
|
|
const holdings = dirtyValues.holdingsRequired ?
|
|
|
|
ModelUtils.modelToArray(
|
|
|
|
dirtyValues.selectedHoldingsModel,
|
|
|
|
["key", "type", "amount"])
|
|
|
|
: []
|
2023-02-22 12:26:02 +00:00
|
|
|
|
|
|
|
const channels = ModelUtils.modelToArray(
|
2023-03-07 08:47:04 +00:00
|
|
|
dirtyValues.selectedChannelsModel, ["key"])
|
|
|
|
|
|
|
|
root.updatePermissionRequested(
|
2023-06-29 22:05:46 +00:00
|
|
|
newPermissionViewPage.permissionKeyToEdit,
|
|
|
|
dirtyValues.permissionType, holdings, channels,
|
|
|
|
dirtyValues.isPrivate)
|
2023-02-08 10:13:16 +00:00
|
|
|
}
|
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
ModelChangeTracker {
|
|
|
|
id: holdingsTracker
|
2023-02-14 20:39:18 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
model: editPermissionView.dirtyValues.selectedHoldingsModel
|
|
|
|
}
|
2023-02-14 20:39:18 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
ModelChangeTracker {
|
|
|
|
id: channelsTracker
|
2023-02-14 20:39:18 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
model: editPermissionView.dirtyValues.selectedChannelsModel
|
|
|
|
}
|
2023-02-14 20:39:18 +00:00
|
|
|
}
|
2023-02-10 22:40:07 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
SettingsDirtyToastMessage {
|
|
|
|
id: settingsDirtyToastMessage
|
2023-03-07 08:47:04 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
z: 1
|
|
|
|
anchors {
|
|
|
|
bottom: parent.bottom
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
bottomMargin: 16
|
|
|
|
}
|
2023-02-10 22:40:07 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
saveChangesText: qsTr("Update permission")
|
|
|
|
cancelChangesText: qsTr("Revert changes")
|
2023-02-10 22:40:07 +00:00
|
|
|
|
2024-02-07 10:30:46 +00:00
|
|
|
saveChangesButtonEnabled: editPermissionView.saveEnabled
|
2023-02-14 20:39:18 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
onSaveChangesClicked: {
|
|
|
|
editPermissionView.saveChanges()
|
|
|
|
root.pop(StackView.Immediate)
|
|
|
|
}
|
2023-02-10 22:40:07 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
onResetChangesClicked: editPermissionView.resetChanges()
|
2023-02-10 22:40:07 +00:00
|
|
|
|
2023-06-29 22:05:46 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
// delay to avoid toast blinking on entry
|
|
|
|
settingsDirtyToastMessage.active = Qt.binding(
|
|
|
|
() => editPermissionView.isEditState &&
|
2024-02-06 09:31:36 +00:00
|
|
|
editPermissionView.dirty &&
|
|
|
|
root.showChannelSelector)
|
2023-06-29 22:05:46 +00:00
|
|
|
}
|
2023-02-10 22:40:07 +00:00
|
|
|
}
|
2022-11-25 17:35:30 +00:00
|
|
|
}
|
2022-06-09 15:27:14 +00:00
|
|
|
}
|
|
|
|
}
|