2023-09-27 11:05:50 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Controls.Validators 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
|
|
|
import shared.controls 1.0
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
StatusStackModal {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
required property string communityName
|
2023-10-31 20:40:00 +00:00
|
|
|
required property int shardIndex
|
|
|
|
required property string pubsubTopic
|
2023-09-27 11:05:50 +00:00
|
|
|
property bool shardingInProgress
|
|
|
|
|
|
|
|
stackTitle: qsTr("Enable community sharding for %1").arg(communityName)
|
|
|
|
width: 640
|
|
|
|
|
|
|
|
readonly property var cancelButton: StatusFlatButton {
|
2023-10-31 20:40:00 +00:00
|
|
|
visible: typeof(currentItem.canGoNext) == "undefined" || currentItem.cancellable
|
2023-09-27 11:05:50 +00:00
|
|
|
text: qsTr("Cancel")
|
|
|
|
onClicked: root.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
nextButton: StatusButton {
|
2023-10-31 20:40:00 +00:00
|
|
|
text: qsTr("Enable community sharding")
|
2023-09-27 11:05:50 +00:00
|
|
|
enabled: typeof(currentItem.canGoNext) == "undefined" || currentItem.canGoNext
|
|
|
|
loading: root.shardingInProgress
|
|
|
|
onClicked: {
|
|
|
|
let nextAction = currentItem.nextAction
|
|
|
|
if (typeof(nextAction) == "function") {
|
|
|
|
return nextAction()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
finishButton: StatusButton {
|
2023-10-31 20:40:00 +00:00
|
|
|
text: qsTr("Close")
|
2023-09-27 11:05:50 +00:00
|
|
|
enabled: typeof(currentItem.canGoNext) == "undefined" || currentItem.canGoNext
|
|
|
|
onClicked: {
|
2023-10-31 20:40:00 +00:00
|
|
|
root.currentIndex = 0
|
2023-09-27 11:05:50 +00:00
|
|
|
root.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rightButtons: [cancelButton, nextButton, finishButton]
|
|
|
|
|
|
|
|
onAboutToShow: shardIndexEdit.focus = true
|
2023-10-31 20:40:00 +00:00
|
|
|
onShardingInProgressChanged: if (!root.shardingInProgress && root.currentIndex == 0) {
|
|
|
|
root.currentIndex++
|
|
|
|
}
|
2023-09-27 11:05:50 +00:00
|
|
|
|
|
|
|
stackItems: [
|
|
|
|
ColumnLayout {
|
|
|
|
id: firstPage
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: Theme.halfPadding
|
2023-09-27 11:05:50 +00:00
|
|
|
|
2023-10-31 20:40:00 +00:00
|
|
|
readonly property bool cancellable: true
|
|
|
|
readonly property bool canGoNext: shardIndexEdit.valid && root.shardIndex != parseInt(shardIndexEdit.text)
|
2023-09-27 11:05:50 +00:00
|
|
|
readonly property var nextAction: function () {
|
2023-10-31 20:40:00 +00:00
|
|
|
root.shardIndex = parseInt(shardIndexEdit.text)
|
2023-09-27 11:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusInput {
|
|
|
|
id: shardIndexEdit
|
|
|
|
Layout.fillWidth: true
|
|
|
|
label: qsTr("Enter shard number")
|
|
|
|
placeholderText: qsTr("Enter a number between 0 and 1023")
|
2023-10-31 20:40:00 +00:00
|
|
|
text: root.shardIndex !== -1 ? root.shardIndex : ""
|
2023-09-27 11:05:50 +00:00
|
|
|
validators: [
|
|
|
|
StatusIntValidator {
|
|
|
|
bottom: 0
|
|
|
|
top: 1023
|
|
|
|
errorMessage: qsTr("Invalid shard number. Number must be 0 — 1023.")
|
|
|
|
}
|
|
|
|
]
|
|
|
|
Keys.onPressed: {
|
|
|
|
if (!shardIndexEdit.valid)
|
|
|
|
return
|
|
|
|
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
|
|
|
|
event.accepted = true
|
|
|
|
firstPage.nextAction()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
ColumnLayout {
|
2023-10-31 20:40:00 +00:00
|
|
|
readonly property bool cancellable: false
|
2023-09-27 11:05:50 +00:00
|
|
|
readonly property bool canGoNext: agreement.checked
|
|
|
|
|
2023-10-02 12:20:15 +00:00
|
|
|
StatusBaseText {
|
|
|
|
text: qsTr("Pub/Sub topic")
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusTextArea {
|
2023-09-27 11:05:50 +00:00
|
|
|
Layout.fillWidth: true
|
2023-10-02 12:20:15 +00:00
|
|
|
Layout.preferredHeight: 138
|
|
|
|
readOnly: true
|
2023-10-31 20:40:00 +00:00
|
|
|
text: root.pubsubTopic
|
2023-10-02 12:20:15 +00:00
|
|
|
rightPadding: 48
|
|
|
|
wrapMode: TextEdit.Wrap
|
2023-09-27 11:05:50 +00:00
|
|
|
|
|
|
|
CopyButton {
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.rightMargin: 12
|
2023-10-02 12:20:15 +00:00
|
|
|
anchors.topMargin: 10
|
2023-09-27 11:05:50 +00:00
|
|
|
textToCopy: parent.text
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusCheckBox {
|
|
|
|
id: agreement
|
|
|
|
text: qsTr("I have made a copy of the Pub/Sub topic and public key string")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|