Skip to content

Commit

Permalink
Merge pull request #5900 from nextcloud/backport/5885/stable-3.9
Browse files Browse the repository at this point in the history
[stable-3.9] Disable share view completely when server does not support/has disabled file sharing
  • Loading branch information
claucambra authored Jul 18, 2023
2 parents 18b64d3 + cb58ff4 commit 21dc0ae
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 15 deletions.
48 changes: 33 additions & 15 deletions src/gui/filedetails/FileDetailsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@ Page {
Connections {
target: Systray
function onShowFileDetailsPage(fileLocalPath, page) {
if(fileLocalPath === root.localPath) {
if (!root.fileDetails.sharingAvailable && page == Systray.FileDetailsPage.Sharing) {
return;
}

if (fileLocalPath === root.localPath) {
switch(page) {
case Systray.FileDetailsPage.Activity:
swipeView.currentIndex = fileActivityView.swipeIndex;
break;
case Systray.FileDetailsPage.Sharing:
swipeView.currentIndex = shareView.swipeIndex;
swipeView.currentIndex = shareViewLoader.swipeIndex;
break;
}
}
Expand Down Expand Up @@ -218,6 +222,7 @@ Page {
Layout.rightMargin: root.intendedPadding

padding: 0
background: null

NCTabButton {
svgCustomColorSource: "image://svgimage-custom-color/activity.svg"
Expand All @@ -227,10 +232,13 @@ Page {
}

NCTabButton {
width: visible ? implicitWidth : 0
height: visible ? implicitHeight : 0
svgCustomColorSource: "image://svgimage-custom-color/share.svg"
text: qsTr("Sharing")
checked: swipeView.currentIndex === shareView.swipeIndex
onClicked: swipeView.currentIndex = shareView.swipeIndex
checked: swipeView.currentIndex === shareViewLoader.swipeIndex
onClicked: swipeView.currentIndex = shareViewLoader.swipeIndex
visible: root.fileDetails.sharingAvailable
}
}
}
Expand All @@ -244,7 +252,7 @@ Page {
FileActivityView {
id: fileActivityView

property int swipeIndex: SwipeView.index
readonly property int swipeIndex: SwipeView.index

delegateHorizontalPadding: root.intendedPadding

Expand All @@ -253,18 +261,28 @@ Page {
iconSize: root.iconSize
}

ShareView {
id: shareView
Loader {
id: shareViewLoader

property int swipeIndex: SwipeView.index
readonly property int swipeIndex: SwipeView.index

accountState: root.accountState
localPath: root.localPath
fileDetails: root.fileDetails
horizontalPadding: root.intendedPadding
iconSize: root.iconSize
rootStackView: root.rootStackView
backgroundsVisible: root.backgroundsVisible
width: swipeView.width
height: swipeView.height
active: root.fileDetails.sharingAvailable

sourceComponent: ShareView {
id: shareView

anchors.fill: parent

accountState: root.accountState
localPath: root.localPath
fileDetails: root.fileDetails
horizontalPadding: root.intendedPadding
iconSize: root.iconSize
rootStackView: root.rootStackView
backgroundsVisible: root.backgroundsVisible
}
}
}
}
12 changes: 12 additions & 0 deletions src/gui/filedetails/filedetails.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ void FileDetails::setLocalPath(const QString &localPath)
connect(&_fileWatcher, &QFileSystemWatcher::fileChanged, this, &FileDetails::refreshFileDetails);

const auto folder = FolderMan::instance()->folderForPath(_localPath);
if (!folder) {
qCWarning(lcFileDetails) << "No folder found for path:" << _localPath << "will not load file details.";
return;
}

const auto file = _localPath.mid(folder->cleanPath().length() + 1);

if (!folder->journalDb()->getFileRecord(file, &_fileRecord)) {
Expand All @@ -74,6 +79,8 @@ void FileDetails::setLocalPath(const QString &localPath)
updateLockExpireString();
updateFileTagModel(folder);

_sharingAvailable = folder->accountState()->account()->capabilities().shareAPI();

Q_EMIT fileChanged();
}

Expand Down Expand Up @@ -172,4 +179,9 @@ void FileDetails::updateFileTagModel(const Folder * const folder)
Q_EMIT fileTagModelChanged();
}

bool FileDetails::sharingAvailable() const
{
return _sharingAvailable;
}

} // namespace OCC
3 changes: 3 additions & 0 deletions src/gui/filedetails/filedetails.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class FileDetails : public QObject
Q_PROPERTY(QString lockExpireString READ lockExpireString NOTIFY lockExpireStringChanged)
Q_PROPERTY(bool isFolder READ isFolder NOTIFY isFolderChanged)
Q_PROPERTY(FileTagModel* fileTagModel READ fileTagModel NOTIFY fileTagModelChanged)
Q_PROPERTY(bool sharingAvailable READ sharingAvailable NOTIFY fileChanged)

public:
explicit FileDetails(QObject *parent = nullptr);
Expand All @@ -50,6 +51,7 @@ class FileDetails : public QObject
[[nodiscard]] QString lockExpireString() const;
[[nodiscard]] bool isFolder() const;
[[nodiscard]] FileTagModel *fileTagModel() const;
[[nodiscard]] bool sharingAvailable() const;

public slots:
void setLocalPath(const QString &localPath);
Expand Down Expand Up @@ -80,6 +82,7 @@ private slots:
QLocale _locale;

std::unique_ptr<FileTagModel> _fileTagModel;
bool _sharingAvailable = true;
};

} // namespace OCC

0 comments on commit 21dc0ae

Please sign in to comment.