mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 06:55:59 +03:00
Show password set errors in the popup where passwords are set rather than in the main dialog
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
d92bc91bdf
commit
ec3c361c89
4 changed files with 41 additions and 4 deletions
|
@ -21,6 +21,7 @@ import QtGraphicalEffects 1.15
|
||||||
import com.nextcloud.desktopclient 1.0
|
import com.nextcloud.desktopclient 1.0
|
||||||
import Style 1.0
|
import Style 1.0
|
||||||
import "../tray"
|
import "../tray"
|
||||||
|
import "../"
|
||||||
|
|
||||||
GridLayout {
|
GridLayout {
|
||||||
id: root
|
id: root
|
||||||
|
@ -87,6 +88,11 @@ GridLayout {
|
||||||
property bool waitingForPasswordChange: false
|
property bool waitingForPasswordChange: false
|
||||||
property bool waitingForNoteChange: false
|
property bool waitingForNoteChange: false
|
||||||
|
|
||||||
|
function showPasswordSetError(message) {
|
||||||
|
passwordErrorBoxLoader.message = message !== "" ?
|
||||||
|
message : qsTr("An error occurred setting the share password.");
|
||||||
|
}
|
||||||
|
|
||||||
function resetNoteField() {
|
function resetNoteField() {
|
||||||
noteTextEdit.text = note;
|
noteTextEdit.text = note;
|
||||||
waitingForNoteChange = false;
|
waitingForNoteChange = false;
|
||||||
|
@ -468,6 +474,7 @@ GridLayout {
|
||||||
!root.waitingForPasswordProtectEnabledChange
|
!root.waitingForPasswordProtectEnabledChange
|
||||||
|
|
||||||
onAccepted: if(text !== root.password && text !== root.passwordPlaceholder) {
|
onAccepted: if(text !== root.password && text !== root.passwordPlaceholder) {
|
||||||
|
passwordErrorBoxLoader.message = "";
|
||||||
root.setPassword(text);
|
root.setPassword(text);
|
||||||
root.waitingForPasswordChange = true;
|
root.waitingForPasswordChange = true;
|
||||||
}
|
}
|
||||||
|
@ -482,6 +489,36 @@ GridLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loader {
|
||||||
|
id: passwordErrorBoxLoader
|
||||||
|
|
||||||
|
property string message: ""
|
||||||
|
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
height: message !== "" ? implicitHeight : 0
|
||||||
|
|
||||||
|
active: message !== ""
|
||||||
|
visible: active
|
||||||
|
|
||||||
|
sourceComponent: Item {
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
// Artificially add vertical padding
|
||||||
|
implicitHeight: passwordErrorBox.implicitHeight + (Style.smallSpacing * 2)
|
||||||
|
|
||||||
|
ErrorBox {
|
||||||
|
id: passwordErrorBox
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
|
text: passwordErrorBoxLoader.message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CheckBox {
|
CheckBox {
|
||||||
id: expireDateEnabledMenuItem
|
id: expireDateEnabledMenuItem
|
||||||
|
|
||||||
|
|
|
@ -202,11 +202,12 @@ ColumnLayout {
|
||||||
// password set has failed, meaning we won't be able to easily tell when we
|
// password set has failed, meaning we won't be able to easily tell when we
|
||||||
// have had a response from the server in QML. So we listen to this signal
|
// have had a response from the server in QML. So we listen to this signal
|
||||||
// directly from the model and do the reset of the password field manually.
|
// directly from the model and do the reset of the password field manually.
|
||||||
function onPasswordSetError(shareId) {
|
function onPasswordSetError(shareId, errorCode, errorMessage) {
|
||||||
if(shareId !== model.shareId) {
|
if(shareId !== model.shareId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
shareDelegate.resetPasswordField();
|
shareDelegate.resetPasswordField();
|
||||||
|
shareDelegate.showPasswordSetError(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onServerError() {
|
function onServerError() {
|
||||||
|
|
|
@ -388,9 +388,8 @@ void ShareModel::slotAddShare(const SharePtr &share)
|
||||||
connect(share.data(), &Share::serverError, this, &ShareModel::slotServerError);
|
connect(share.data(), &Share::serverError, this, &ShareModel::slotServerError);
|
||||||
connect(share.data(), &Share::passwordSetError, this, [this, shareId](const int code, const QString &message) {
|
connect(share.data(), &Share::passwordSetError, this, [this, shareId](const int code, const QString &message) {
|
||||||
_shareIdRecentlySetPasswords.remove(shareId);
|
_shareIdRecentlySetPasswords.remove(shareId);
|
||||||
slotServerError(code, message);
|
|
||||||
slotSharePasswordSet(shareId);
|
slotSharePasswordSet(shareId);
|
||||||
Q_EMIT passwordSetError(shareId);
|
Q_EMIT passwordSetError(shareId, code, message);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Passing shareId by reference here will cause crashing, so we pass by value
|
// Passing shareId by reference here will cause crashing, so we pass by value
|
||||||
|
|
|
@ -107,7 +107,7 @@ signals:
|
||||||
void hasInitialShareFetchCompletedChanged();
|
void hasInitialShareFetchCompletedChanged();
|
||||||
|
|
||||||
void serverError(const int code, const QString &message);
|
void serverError(const int code, const QString &message);
|
||||||
void passwordSetError(const QString &shareId);
|
void passwordSetError(const QString &shareId, const int code, const QString &message);
|
||||||
void requestPasswordForLinkShare();
|
void requestPasswordForLinkShare();
|
||||||
void requestPasswordForEmailSharee(const ShareePtr &sharee);
|
void requestPasswordForEmailSharee(const ShareePtr &sharee);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue