Skip to content

Commit

Permalink
Display opne in browser on sync root
Browse files Browse the repository at this point in the history
Fixes: #10572
  • Loading branch information
TheOneRing committed Mar 7, 2023
1 parent 39a86d7 commit f7dbf99
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
3 changes: 3 additions & 0 deletions changelog/unreleased/10572
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Enhancement: Display open in web in file browser context menu, on sync roots

https://github.com/owncloud/client/issues/10572
31 changes: 17 additions & 14 deletions src/gui/socketapi/socketapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "socketapi.h"
#include "socketapi_p.h"

#include "gui/commonstrings.h"

#include "account.h"
#include "accountmanager.h"
#include "accountstate.h"
Expand Down Expand Up @@ -624,9 +626,11 @@ void SocketApi::fetchPrivateLinkUrlHelper(const QString &localFile, const std::f
return;
}

auto record = fileData.journalRecord();
if (!record.isValid())
return;
if (!fileData.isSyncFolder()) {
auto record = fileData.journalRecord();
if (!record.isValid())
return;
}

fetchPrivateLinkUrl(
fileData.folder->accountState()->account(),
Expand Down Expand Up @@ -966,6 +970,7 @@ void SocketApi::command_GET_MENU_ITEMS(const QString &argument, OCC::SocketListe
if (files.size() == 1) {
const FileData fileData = FileData::get(files.first());
if (fileData.folder->accountState()->isConnected()) {
const auto &capabilities = fileData.folder->accountState()->account()->capabilities();
if (!fileData.isSyncFolder()) {
const auto record = fileData.journalRecord();
const bool isOnTheServer = record.isValid();
Expand All @@ -976,18 +981,13 @@ void SocketApi::command_GET_MENU_ITEMS(const QString &argument, OCC::SocketListe
listener->sendMessage(QStringLiteral("MENU_ITEM:OPEN_APP_LINK") + flagString + tr("Open in %1").arg(app.defaultApplication));
}


sendSharingContextMenuOptions(fileData, listener);

const auto &capabilities = fileData.folder->accountState()->account()->capabilities();
if (capabilities.privateLinkPropertyAvailable()) {
listener->sendMessage(QLatin1String("MENU_ITEM:OPEN_PRIVATE_LINK") + flagString + tr("Open in browser"));
listener->sendMessage(QLatin1String("MENU_ITEM:OPEN_PRIVATE_LINK") + flagString + CommonStrings::showInWebBrowser());
}
// Add link to versions pane if possible
if (capabilities.versioningEnabled()
&& capabilities.privateLinkDetailsParamAvailable()
&& isOnTheServer
&& !record.isDirectory()) {
if (capabilities.versioningEnabled() && capabilities.privateLinkDetailsParamAvailable() && isOnTheServer && !record.isDirectory()) {
listener->sendMessage(QLatin1String("MENU_ITEM:OPEN_PRIVATE_LINK_VERSIONS") + flagString + tr("Show file versions in browser"));
}

Expand All @@ -1001,10 +1001,8 @@ void SocketApi::command_GET_MENU_ITEMS(const QString &argument, OCC::SocketListe
const bool canAddToDir = !parentRecord._remotePerm.isNull()
&& ((fileInfo.isFile() && parentRecord._remotePerm.hasPermission(RemotePermissions::CanAddFile))
|| (fileInfo.isDir() && parentRecord._remotePerm.hasPermission(RemotePermissions::CanAddSubDirectories)));
const bool canChangeFile =
!isOnTheServer
|| (record._remotePerm.hasPermission(RemotePermissions::CanDelete)
&& record._remotePerm.hasPermission(RemotePermissions::CanMove)
const bool canChangeFile = !isOnTheServer
|| (record._remotePerm.hasPermission(RemotePermissions::CanDelete) && record._remotePerm.hasPermission(RemotePermissions::CanMove)
&& record._remotePerm.hasPermission(RemotePermissions::CanRename));

if (isConflict && canChangeFile) {
Expand Down Expand Up @@ -1039,6 +1037,11 @@ void SocketApi::command_GET_MENU_ITEMS(const QString &argument, OCC::SocketListe
}
}
}
} else {
// we are a sync root
if (capabilities.privateLinkPropertyAvailable()) {
listener->sendMessage(QLatin1String("MENU_ITEM:OPEN_PRIVATE_LINK::") + CommonStrings::showInWebBrowser());
}
}
}
}
Expand Down

0 comments on commit f7dbf99

Please sign in to comment.