Merge pull request #163 from amnezia-vpn/feature/confirm-on-clear-and-delete-server

feature/confirm-on-clear-and-delete-server
This commit is contained in:
pokamest 2023-01-30 20:45:35 +00:00 committed by GitHub
commit c3fc3a3132
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 105 additions and 39 deletions

View file

@ -70,7 +70,7 @@ QList<DockerContainer> ContainerProps::allContainers()
QMap<DockerContainer, QString> ContainerProps::containerHumanNames() QMap<DockerContainer, QString> ContainerProps::containerHumanNames()
{ {
return { return {
{DockerContainer::None, "Unknown (Old version)"}, {DockerContainer::None, "Not installed"},
{DockerContainer::OpenVpn, "OpenVPN"}, {DockerContainer::OpenVpn, "OpenVPN"},
{DockerContainer::ShadowSocks, "OpenVpn over ShadowSocks"}, {DockerContainer::ShadowSocks, "OpenVpn over ShadowSocks"},
{DockerContainer::Cloak, "OpenVpn over Cloak"}, {DockerContainer::Cloak, "OpenVpn over Cloak"},

View file

@ -163,5 +163,6 @@
<file>images/svg/control_point_black_24dp.svg</file> <file>images/svg/control_point_black_24dp.svg</file>
<file>images/svg/settings_suggest_black_24dp.svg</file> <file>images/svg/settings_suggest_black_24dp.svg</file>
<file>server_scripts/website_tor/Dockerfile</file> <file>server_scripts/website_tor/Dockerfile</file>
<file>ui/qml/Controls/PopupWithQuestion.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -0,0 +1,57 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
Popup {
id: root
property string questionText
property string yesText: "yes"
property string noText: "no"
property var yesFunc
property var noFunc
anchors.centerIn: Overlay.overlay
modal: true
closePolicy: Popup.NoAutoClose
width: parent.width - 20
ColumnLayout {
width: parent.width
Text {
horizontalAlignment: Text.AlignHCenter
Layout.fillWidth: true
wrapMode: Text.WordWrap
font.pixelSize: 16
text: questionText
}
RowLayout {
BlueButtonType {
id: yesButton
Layout.preferredWidth: parent.width / 2
Layout.fillWidth: true
text: yesText
onClicked: {
root.enabled = false
if (yesFunc && typeof yesFunc === "function") {
yesFunc()
}
root.enabled = true
}
}
BlueButtonType {
id: noButton
Layout.preferredWidth: parent.width / 2
Layout.fillWidth: true
text: noText
onClicked: {
if (noFunc && typeof noFunc === "function") {
noFunc()
}
}
}
}
}
}

View file

@ -296,23 +296,24 @@ PageBase {
implicitHeight: 30 implicitHeight: 30
checked: default_role checked: default_role
onClicked: popupRemove.open()
MessageDialog {
id: dialogRemove
buttons: StandardButton.Yes | StandardButton.Cancel
title: "AmneziaVPN"
text: qsTr("Remove container") + " " + name_role + "?" + "\n" + qsTr("This action will erase all data of this container on the server.")
onAccepted: {
tb_c.currentIndex = -1
ServerContainersLogic.onPushButtonRemoveClicked(proxyContainersModel.mapToSource(index))
}
}
onClicked: dialogRemove.open()
VisibleBehavior on visible { } VisibleBehavior on visible { }
} }
PopupWithQuestion {
id: popupRemove
questionText: qsTr("Remove container") + " " + name_role + "?" + "\n" + qsTr("This action will erase all data of this container on the server.")
yesFunc: function() {
tb_c.currentIndex = -1
ServerContainersLogic.onPushButtonRemoveClicked(proxyContainersModel.mapToSource(index))
close()
}
noFunc: function() {
close()
}
}
ImageButtonType { ImageButtonType {
id: button_share id: button_share
visible: (index === tb_c.currentIndex) && ServerContainersLogic.isManagedServer visible: (index === tb_c.currentIndex) && ServerContainersLogic.isManagedServer
@ -417,7 +418,7 @@ PageBase {
BlueButtonType { BlueButtonType {
id: pb_add_container id: pb_add_container
visible: container_selector.selectedIndex < 0 visible: container_selector.selectedIndex < 0 && ServerContainersLogic.isManagedServer
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
@ -429,6 +430,5 @@ PageBase {
text: qsTr("Install new service") text: qsTr("Install new service")
font.pixelSize: 16 font.pixelSize: 16
onClicked: container_selector.visible ? container_selector.close() : container_selector.open() onClicked: container_selector.visible ? container_selector.close() : container_selector.open()
} }
} }

View file

@ -93,24 +93,49 @@ PageBase {
ServerSettingsLogic.onPushButtonClearClientCacheClicked() ServerSettingsLogic.onPushButtonClearClientCacheClicked()
} }
} }
BlueButtonType { BlueButtonType {
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 10 Layout.topMargin: 10
text: ServerSettingsLogic.pushButtonClearText text: ServerSettingsLogic.pushButtonClearText
visible: ServerSettingsLogic.pushButtonClearVisible visible: ServerSettingsLogic.pushButtonClearVisible
onClicked: { onClicked: {
ServerSettingsLogic.onPushButtonClearServer() popupClearServer.open()
} }
} }
PopupWithQuestion {
id: popupClearServer
questionText: "Attention! All containers will be deleted on the server. This means that configuration files, keys and certificates will be deleted. Continue?"
yesFunc: function() {
ServerSettingsLogic.onPushButtonClearServer()
close()
}
noFunc: function() {
close()
}
}
BlueButtonType { BlueButtonType {
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 10 Layout.topMargin: 10
text: qsTr("Forget this server") text: qsTr("Forget this server")
onClicked: { onClicked: {
ServerSettingsLogic.onPushButtonForgetServer() popupForgetServer.open()
} }
} }
PopupWithQuestion {
id: popupForgetServer
questionText: "Attention! This action will not remove the container on the server, it will only remove the container information from the application. Continue?"
yesFunc: function() {
ServerSettingsLogic.onPushButtonForgetServer()
close()
}
noFunc: function() {
close()
}
}
} }
} }

View file

@ -11,10 +11,9 @@ PageProtocolBase {
protocol: ProtocolEnum.Cloak protocol: ProtocolEnum.Cloak
logic: UiLogic.protocolLogic(protocol) logic: UiLogic.protocolLogic(protocol)
enabled: logic.pageEnabled
BackButton { BackButton {
id: back id: back
enabled: logic.pageEnabled enabled: !logic.pushButtonCancelVisible
} }
Caption { Caption {

View file

@ -13,7 +13,7 @@ PageProtocolBase {
BackButton { BackButton {
id: back id: back
enabled: logic.pageEnabled enabled: !logic.pushButtonCancelVisible
} }
Caption { Caption {
@ -285,8 +285,6 @@ PageProtocolBase {
} }
} }
} }
} }
BasicButtonType { BasicButtonType {
@ -338,8 +336,6 @@ PageProtocolBase {
} }
} }
} }
} }
LabelType { LabelType {

View file

@ -13,7 +13,7 @@ PageProtocolBase {
BackButton { BackButton {
id: back id: back
enabled: logic.pageEnabled enabled: !logic.pushButtonCancelVisible
} }
Caption { Caption {

View file

@ -232,18 +232,6 @@ Window {
} }
} }
MessageDialog {
id: closePrompt
// x: (root.width - width) / 2
// y: (root.height - height) / 2
title: qsTr("Exit")
text: qsTr("Do you really want to quit?")
// standardButtons: StandardButton.Yes | StandardButton.No
// onYesClicked: {
// Qt.quit()
// }
visible: false
}
MessageDialog { MessageDialog {
id: publicKeyWarning id: publicKeyWarning
title: "AmneziaVPN" title: "AmneziaVPN"