2022-06-09 15:27:14 +00:00
|
|
|
|
import QtQuick 2.14
|
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
import shared.panels 1.0
|
|
|
|
|
|
|
|
|
|
import "../../../Chat/controls/community"
|
2022-08-23 08:46:37 +00:00
|
|
|
|
import "../../stores"
|
2022-06-09 15:27:14 +00:00
|
|
|
|
|
|
|
|
|
Flickable {
|
|
|
|
|
id: root
|
|
|
|
|
|
2022-08-23 08:46:37 +00:00
|
|
|
|
property var store: CommunitiesStore {}
|
|
|
|
|
|
|
|
|
|
|
2022-06-09 15:27:14 +00:00
|
|
|
|
signal createPermission()
|
|
|
|
|
|
2022-08-23 08:46:37 +00:00
|
|
|
|
// TODO: Call this when permissions are stored in backend to start a new permissions flow
|
|
|
|
|
function clearPermissions() {
|
|
|
|
|
d.permissions.clear()
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-09 15:27:14 +00:00
|
|
|
|
QtObject {
|
|
|
|
|
id: d
|
|
|
|
|
property bool isPrivate: false
|
2022-08-23 08:46:37 +00:00
|
|
|
|
property ListModel permissions: ListModel{}
|
2022-06-09 15:27:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
contentWidth: mainLayout.width
|
|
|
|
|
contentHeight: mainLayout.height
|
|
|
|
|
clip: true
|
|
|
|
|
flickableDirection: Flickable.AutoFlickIfNeeded
|
|
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
|
id: mainLayout
|
|
|
|
|
width: 560 // by design
|
|
|
|
|
spacing: 0
|
|
|
|
|
CurveSeparatorWithText {
|
|
|
|
|
Layout.alignment: Qt.AlignLeft
|
|
|
|
|
Layout.leftMargin: 14
|
|
|
|
|
text: qsTr("Anyone")
|
|
|
|
|
}
|
|
|
|
|
StatusItemSelector {
|
|
|
|
|
id: tokensSelector
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
icon: Style.svg("contact_verified")
|
|
|
|
|
title: qsTr("Who holds")
|
|
|
|
|
defaultItemText: qsTr("Example: 10 SNT")
|
|
|
|
|
andOperatorText: qsTr("and")
|
|
|
|
|
orOperatorText: qsTr("or")
|
|
|
|
|
popupItem: HoldingsDropdown {
|
|
|
|
|
id: dropdown
|
2022-08-23 08:46:37 +00:00
|
|
|
|
store: root.store
|
2022-06-09 15:27:14 +00:00
|
|
|
|
withOperatorSelector: tokensSelector.itemsModel.count > 0
|
2022-08-23 08:46:37 +00:00
|
|
|
|
onAddItem: {
|
|
|
|
|
tokensSelector.addItem(itemText, itemImage, operator)
|
|
|
|
|
d.permissions.append([{itemKey: itemKey}, {operator: operator}])
|
2022-06-09 15:27:14 +00:00
|
|
|
|
dropdown.close()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Rectangle {
|
|
|
|
|
Layout.leftMargin: 16
|
|
|
|
|
Layout.preferredWidth: 2
|
|
|
|
|
Layout.preferredHeight: 24
|
|
|
|
|
color: Style.current.separator
|
|
|
|
|
}
|
|
|
|
|
StatusItemSelector {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
icon: Style.svg("profile/security")
|
|
|
|
|
iconSize: 24
|
|
|
|
|
title: qsTr("Is allowed to")
|
|
|
|
|
defaultItemText: qsTr("Example: View and post")
|
|
|
|
|
}
|
|
|
|
|
Rectangle {
|
|
|
|
|
Layout.leftMargin: 16
|
|
|
|
|
Layout.preferredWidth: 2
|
|
|
|
|
Layout.preferredHeight: 24
|
|
|
|
|
color: Style.current.separator
|
|
|
|
|
}
|
|
|
|
|
StatusItemSelector {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
icon: Style.svg("create-category")
|
|
|
|
|
iconSize: 24
|
|
|
|
|
title: qsTr("In")
|
|
|
|
|
defaultItemText: qsTr("Example: `#general` channel")
|
|
|
|
|
}
|
|
|
|
|
Separator {
|
|
|
|
|
Layout.topMargin: 24
|
|
|
|
|
}
|
|
|
|
|
RowLayout {
|
|
|
|
|
Layout.topMargin: 12
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.leftMargin: 16
|
|
|
|
|
Layout.rightMargin: Layout.leftMargin
|
|
|
|
|
spacing: 16
|
|
|
|
|
StatusRoundIcon {
|
2022-08-11 11:55:08 +00:00
|
|
|
|
asset.name: "hide"
|
2022-06-09 15:27:14 +00:00
|
|
|
|
}
|
|
|
|
|
ColumnLayout {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
StatusBaseText {
|
|
|
|
|
text: qsTr("Private")
|
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
}
|
|
|
|
|
StatusBaseText {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
text: qsTr("Make this permission private to hide it from members who don’t meet it’s requirements")
|
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
lineHeight: 1.2
|
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
|
elide: Text.ElideRight
|
|
|
|
|
clip: true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
StatusSwitch {
|
|
|
|
|
checked: d.isPrivate
|
|
|
|
|
onToggled: { d.isPrivate = checked }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
StatusButton {
|
|
|
|
|
Layout.topMargin: 24
|
|
|
|
|
text: qsTr("Create permission")
|
2022-08-23 08:46:37 +00:00
|
|
|
|
enabled: d.permissions.count > 0
|
2022-06-09 15:27:14 +00:00
|
|
|
|
Layout.preferredHeight: 44
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
Layout.fillWidth: true
|
2022-08-23 08:46:37 +00:00
|
|
|
|
onClicked: {
|
|
|
|
|
root.store.createPermissions(d.permissions)
|
|
|
|
|
root.clearPermissions()
|
|
|
|
|
}
|
2022-06-09 15:27:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|