Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,6 @@
<file>src/gui/macOS/ui/FileProviderSettings.qml</file>
<file>src/gui/macOS/ui/FileProviderFileDelegate.qml</file>
<file>src/gui/integration/FileActionsWindow.qml</file>
<file>src/gui/GovernanceLabelsDialog.qml</file>
</qresource>
</RCC>
21 changes: 21 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,27 @@ set(client_SRCS
filedetails/shareemodel.cpp
filedetails/sortedsharemodel.h
filedetails/sortedsharemodel.cpp
governance/governancenetworkjob.h
governance/governancenetworkjob.cpp
governance/getgovernancelabels.h
governance/getgovernancelabels.cpp
governance/getavailablegovernancelabels.h
governance/getavailablegovernancelabels.cpp
governance/applygovernancelabel.h
governance/applygovernancelabel.cpp
governance/deletegovernancelabel.h
governance/deletegovernancelabel.cpp
governance/typedgovernancenetworkjob.h
governance/typedgovernancenetworkjob.cpp
governance/ocsgovernancejob.h
governance/ocsgovernancejob.cpp
governance/typedwithlabelidgovernancenetworkjob.h
governance/typedwithlabelidgovernancenetworkjob.cpp
governance/governancelabelinfo.h
governance/governancelabelinfo.cpp
governance/governancelabelslistmodel.h
governance/governancelabelslistmodel.cpp
governance/governancetypes.h
tray/svgimageprovider.h
tray/svgimageprovider.cpp
tray/syncstatussummary.h
Expand Down
119 changes: 119 additions & 0 deletions src/gui/GovernanceLabelsDialog.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: GPL-2.0-or-later
*/

import QtQml
import QtQuick
import QtQuick.Window as QtWindow
import QtQuick.Layouts
import QtQuick.Controls
import QtQml.Models
import Style
import com.nextcloud.desktopclient
import "./tray"

ApplicationWindow {
id: governanceLabelsDialog

required property var fileName
required property var fileId
required property var account

flags: Qt.Window | Qt.Dialog
visible: true

LayoutMirroring.enabled: Application.layoutDirection === Qt.RightToLeft
LayoutMirroring.childrenInherit: true

width: Style.minimumWidthResolveConflictsDialog
height: Style.minimumHeightResolveConflictsDialog
minimumWidth: Style.minimumWidthResolveConflictsDialog
minimumHeight: Style.minimumHeightResolveConflictsDialog
title: qsTr('Applys labels')

onClosing: function(close) {
Systray.destroyDialog(self);
close.accepted = true
}

GetAvailableGovernanceLabels {
id: getAvailableGovernanceLabelsForSensitivity

account: governanceLabelsDialog.account

labelType: GovernanceNetworkJob.Sensitivity
entityId: governanceLabelsDialog.fileId

onFinished: function(reply) {
labelsModel.setAvailableLabelsJsonData(reply)
}
}

GovernanceLabelsListModel {
id: labelsModel

entityId: governanceLabelsDialog.fileId
labelType: GovernanceNetworkJob.Sensitivity

onRefreshData: function(labelType, entityId) {
getAvailableGovernanceLabelsForSensitivity.start(labelType, entityId)
}
}

ColumnLayout {
anchors.fill: parent
anchors.leftMargin: 10
anchors.rightMargin: 10
anchors.bottomMargin: 5
anchors.topMargin: 10
spacing: 15
z: 2

EnforcedPlainTextLabel {
text: 'Sensitivity label:'

font.pixelSize: Style.pixelSize + 2
}

ComboBox {
id: selectedNewSensitivityLabel

font.pixelSize: Style.pixelSize + 2
Accessible.role: Accessible.ComboBox
Accessible.name: qsTr("Select sensitivity label")

model: labelsModel
textRole: 'name'
valueRole: 'id'
}

DialogButtonBox {
Layout.fillWidth: true

Button {
text: qsTr("Apply")
DialogButtonBox.buttonRole: DialogButtonBox.ApplyRole
}

Button {
text: qsTr("Cancel")
DialogButtonBox.buttonRole: DialogButtonBox.RejectRole
}

onAccepted: function() {
Systray.destroyDialog(governanceLabelsDialog)
}

onRejected: function() {
Systray.destroyDialog(governanceLabelsDialog)
}
}
}

Rectangle {
color: palette.base
anchors.fill: parent
z: 1
}
}
3 changes: 3 additions & 0 deletions src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,9 @@ Application::Application(int &argc, char **argv)
connect(FolderMan::instance()->socketApi(), &SocketApi::shareCommandReceived,
_gui.data(), &ownCloudGui::slotShowShareDialog);

connect(FolderMan::instance()->socketApi(), &SocketApi::governanceLabelsCommandReceived,
_gui.data(), &ownCloudGui::slotShowGovernanceLabelsDialog);

connect(FolderMan::instance()->socketApi(), &SocketApi::fileActivityCommandReceived,
_gui.data(), &ownCloudGui::slotShowFileActivityDialog);

Expand Down
57 changes: 57 additions & 0 deletions src/gui/governance/applygovernancelabel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: GPL-2.0-or-later
*/

#include "applygovernancelabel.h"

#include "ocsgovernancejob.h"

namespace OCC
{

ApplyGovernanceLabel::ApplyGovernanceLabel(QObject *parent)
: OCC::TypedWithLabelIdGovernanceNetworkJob{parent}
{
connect(this, &ApplyGovernanceLabel::apiVersionChanged, this, &ApplyGovernanceLabel::initialize);
connect(this, &ApplyGovernanceLabel::entityTypeChanged, this, &ApplyGovernanceLabel::initialize);
connect(this, &ApplyGovernanceLabel::customEntityTypeChanged, this, &ApplyGovernanceLabel::initialize);
connect(this, &ApplyGovernanceLabel::entityIdChanged, this, &ApplyGovernanceLabel::initialize);
connect(this, &ApplyGovernanceLabel::accountChanged, this, &ApplyGovernanceLabel::initialize);
connect(this, &ApplyGovernanceLabel::labelTypeChanged, this, &ApplyGovernanceLabel::initialize);
connect(this, &ApplyGovernanceLabel::labelIdChanged, this, &ApplyGovernanceLabel::initialize);
}

void ApplyGovernanceLabel::start()
{
if (!checkParameters()) {
Q_EMIT finishedWitherror(500, {});
return;
}

setOcsGovernanceJob(QPointer<OcsGovernanceJob>{new OcsGovernanceJob{account()}});

connect(ocsGovernanceJob().data(), &OcsJob::jobFinished,
this, &ApplyGovernanceLabel::jobDone);
connect(ocsGovernanceJob().data(), &OcsJob::ocsError,
this, &ApplyGovernanceLabel::finishedWitherror);

ocsGovernanceJob()->setPath(buildPath());
ocsGovernanceJob()->setMethod("POST");

ocsGovernanceJob()->start();
}

void ApplyGovernanceLabel::jobDone(QJsonDocument reply, [[maybe_unused]] int statusCode)
{
Q_EMIT finished(reply);
}

void ApplyGovernanceLabel::initialize()
{
if (checkParameters()) {
start();
}
}

} // namespace OCC
36 changes: 36 additions & 0 deletions src/gui/governance/applygovernancelabel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: GPL-2.0-or-later
*/

#ifndef APPLYGOVERNANCELABEL_H
#define APPLYGOVERNANCELABEL_H

#include "typedwithlabelidgovernancenetworkjob.h"

#include <QObject>
#include <QQmlEngine>
#include <QJsonDocument>

namespace OCC
{

class ApplyGovernanceLabel : public OCC::TypedWithLabelIdGovernanceNetworkJob
{
Q_OBJECT
QML_ELEMENT
public:
explicit ApplyGovernanceLabel(QObject *parent = nullptr);

public Q_SLOTS:
void start();

private Q_SLOTS:
void jobDone(QJsonDocument reply, int statusCode);

void initialize();
};

} // namespace OCC

#endif // APPLYGOVERNANCELABEL_H
57 changes: 57 additions & 0 deletions src/gui/governance/deletegovernancelabel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: GPL-2.0-or-later
*/

#include "deletegovernancelabel.h"

#include "ocsgovernancejob.h"

namespace OCC
{

DeleteGovernanceLabel::DeleteGovernanceLabel(QObject *parent)
: OCC::TypedWithLabelIdGovernanceNetworkJob{parent}
{
connect(this, &DeleteGovernanceLabel::apiVersionChanged, this, &DeleteGovernanceLabel::initialize);
connect(this, &DeleteGovernanceLabel::entityTypeChanged, this, &DeleteGovernanceLabel::initialize);
connect(this, &DeleteGovernanceLabel::customEntityTypeChanged, this, &DeleteGovernanceLabel::initialize);
connect(this, &DeleteGovernanceLabel::entityIdChanged, this, &DeleteGovernanceLabel::initialize);
connect(this, &DeleteGovernanceLabel::accountChanged, this, &DeleteGovernanceLabel::initialize);
connect(this, &DeleteGovernanceLabel::labelTypeChanged, this, &DeleteGovernanceLabel::initialize);
connect(this, &DeleteGovernanceLabel::labelIdChanged, this, &DeleteGovernanceLabel::initialize);
}

void DeleteGovernanceLabel::start()
{
if (!checkParameters()) {
Q_EMIT finishedWitherror(500, {});
return;
}

setOcsGovernanceJob(QPointer<OcsGovernanceJob>{new OcsGovernanceJob{account()}});

connect(ocsGovernanceJob().data(), &OcsJob::jobFinished,
this, &DeleteGovernanceLabel::jobDone);
connect(ocsGovernanceJob().data(), &OcsJob::ocsError,
this, &DeleteGovernanceLabel::finishedWitherror);

ocsGovernanceJob()->setPath(buildPath());
ocsGovernanceJob()->setMethod("DELETE");

ocsGovernanceJob()->start();
}

void DeleteGovernanceLabel::jobDone(QJsonDocument reply, [[maybe_unused]] int statusCode)
{
Q_EMIT finished(reply);
}

void DeleteGovernanceLabel::initialize()
{
if (checkParameters()) {
start();
}
}

} // namespace OCC
36 changes: 36 additions & 0 deletions src/gui/governance/deletegovernancelabel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: GPL-2.0-or-later
*/

#ifndef DELETEGOVERNANCELABEL_H
#define DELETEGOVERNANCELABEL_H

#include "typedwithlabelidgovernancenetworkjob.h"

#include <QObject>
#include <QQmlEngine>
#include <QJsonDocument>

namespace OCC
{

class DeleteGovernanceLabel : public OCC::TypedWithLabelIdGovernanceNetworkJob
{
Q_OBJECT
QML_ELEMENT
public:
explicit DeleteGovernanceLabel(QObject *parent = nullptr);

public Q_SLOTS:
void start();

private Q_SLOTS:
void jobDone(QJsonDocument reply, int statusCode);

void initialize();
};

} // namespace OCC

#endif // DELETEGOVERNANCELABEL_H
Loading