mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 06:55:59 +03:00
Add a dismiss link for notifications without it.
- Fix for #5606 and #5585. - That is how it is done in the server and other clients. - Update tests. Signed-off-by: Camila <hello@camila.codes>
This commit is contained in:
parent
6d6f9a8e9a
commit
d6db8fcbd6
3 changed files with 49 additions and 4 deletions
|
@ -74,7 +74,7 @@ ItemDelegate {
|
|||
ActivityItemActions {
|
||||
id: activityActions
|
||||
|
||||
visible: !root.isFileActivityList && model.linksForActionButtons.length > 0 && !isTalkReplyOptionVisible
|
||||
visible: !root.isFileActivityList && model.linksForActionButtons.length > 1 && !isTalkReplyOptionVisible
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: Style.trayListItemIconSize + activityContent.spacing
|
||||
|
|
|
@ -82,7 +82,6 @@ void ServerNotificationHandler::slotNotificationsReceived(const QJsonDocument &j
|
|||
ActivityList list;
|
||||
ActivityList callList;
|
||||
|
||||
|
||||
foreach (auto element, notifies) {
|
||||
auto json = element.toObject();
|
||||
auto a = Activity::fromActivityJson(json, ai->account());
|
||||
|
@ -145,7 +144,15 @@ void ServerNotificationHandler::slotNotificationsReceived(const QJsonDocument &j
|
|||
}
|
||||
|
||||
a._links.insert(al._primary? 0 : a._links.size(), al);
|
||||
}
|
||||
}
|
||||
|
||||
if (a._links.isEmpty()) {
|
||||
ActivityLink dismissLink;
|
||||
dismissLink._label = tr("Dismiss");
|
||||
dismissLink._verb = "DELETE";
|
||||
dismissLink._primary = false;
|
||||
a._links.insert(0, dismissLink);
|
||||
}
|
||||
|
||||
QUrl link(json.value("link").toString());
|
||||
if (!link.isEmpty()) {
|
||||
|
|
|
@ -234,7 +234,7 @@ public:
|
|||
activity.insert(QStringLiteral("activity_id"), _startingId);
|
||||
activity.insert(QStringLiteral("object_type"), "2fa_id");
|
||||
activity.insert(QStringLiteral("subject"), QStringLiteral("Login attempt from 127.0.0.1"));
|
||||
activity.insert(QStringLiteral("message"), QStringLiteral("Please apporve or deny the login attempt."));
|
||||
activity.insert(QStringLiteral("message"), QStringLiteral("Please approve or deny the login attempt."));
|
||||
activity.insert(QStringLiteral("object_name"), QStringLiteral(""));
|
||||
activity.insert(QStringLiteral("datetime"), QDateTime::currentDateTime().toString(Qt::ISODate));
|
||||
activity.insert(QStringLiteral("icon"), QStringLiteral("http://example.de/core/img/places/password.svg"));
|
||||
|
@ -263,6 +263,34 @@ public:
|
|||
_startingId++;
|
||||
}
|
||||
|
||||
// Insert notification data
|
||||
for (quint32 i = 0; i < _numItemsToInsert; i++) {
|
||||
QJsonObject activity;
|
||||
activity.insert(QStringLiteral("activity_id"), _startingId);
|
||||
activity.insert(QStringLiteral("object_type"), "create");
|
||||
activity.insert(QStringLiteral("subject"), QStringLiteral("Generate backup codes"));
|
||||
activity.insert(QStringLiteral("message"), QStringLiteral("You enabled two-factor authentication but did not generate backup codes yet. They are needed to restore access to your account in case you lose your second factor."));
|
||||
activity.insert(QStringLiteral("object_name"), QStringLiteral(""));
|
||||
activity.insert(QStringLiteral("datetime"), QDateTime::currentDateTime().toString(Qt::ISODate));
|
||||
activity.insert(QStringLiteral("icon"), QStringLiteral("http://example.de/core/img/places/password.svg"));
|
||||
|
||||
QJsonArray actionsArray;
|
||||
|
||||
QJsonObject secondaryAction;
|
||||
secondaryAction.insert(QStringLiteral("label"), QStringLiteral("Dismiss"));
|
||||
secondaryAction.insert(QStringLiteral("link"),
|
||||
QString(QStringLiteral("ocs/v2.php/apps/notifications/api/v2/notifications/19867")));
|
||||
secondaryAction.insert(QStringLiteral("type"), QStringLiteral("DELETE"));
|
||||
secondaryAction.insert(QStringLiteral("primary"), false);
|
||||
actionsArray.push_back(secondaryAction);
|
||||
|
||||
activity.insert(QStringLiteral("actions"), actionsArray);
|
||||
|
||||
_activityData.push_back(activity);
|
||||
|
||||
_startingId++;
|
||||
}
|
||||
|
||||
_startingId--;
|
||||
}
|
||||
|
||||
|
@ -619,6 +647,9 @@ private slots:
|
|||
QVERIFY(index.data(OCC::ActivityListModel::ActionTextRole).canConvert<QString>());
|
||||
QVERIFY(index.data(OCC::ActivityListModel::MessageRole).canConvert<QString>());
|
||||
QVERIFY(index.data(OCC::ActivityListModel::LinkRole).canConvert<QUrl>());
|
||||
|
||||
QVERIFY(index.data(OCC::ActivityListModel::ActionsLinksForActionButtonsRole).canConvert<QList<QVariant>>());
|
||||
|
||||
QVERIFY(index.data(OCC::ActivityListModel::AccountConnectedRole).canConvert<bool>());
|
||||
QVERIFY(index.data(OCC::ActivityListModel::DisplayActions).canConvert<bool>());
|
||||
|
||||
|
@ -677,6 +708,13 @@ private slots:
|
|||
QVERIFY(actionsLinksContextMenu.isEmpty());
|
||||
}
|
||||
|
||||
// Generate 2FA backup codes notification
|
||||
if (objectType == QStringLiteral("create")) {
|
||||
QVERIFY(actionsLinks.size() == 1);
|
||||
QVERIFY(!actionsLinks[0].value<OCC::ActivityLink>()._primary);
|
||||
QVERIFY(actionsLinksContextMenu.isEmpty());
|
||||
}
|
||||
|
||||
if ((objectType == QStringLiteral("chat") || objectType == QStringLiteral("call")
|
||||
|| objectType == QStringLiteral("room"))) {
|
||||
|
||||
|
|
Loading…
Reference in a new issue