Skip to content

Commit

Permalink
NXDRIVE-2912: Display Drive notification for document review --02/04
Browse files Browse the repository at this point in the history
  • Loading branch information
gitofanindya committed Apr 2, 2024
1 parent 30b7b93 commit ef421e2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 14 deletions.
1 change: 1 addition & 0 deletions docs/changes/5.5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Release date: `2024-xx-xx`
## Core

- [NXDRIVE-2882](https://jira.nuxeo.com/browse/NXDRIVE-2882): fix_db should create dump.sql in same dir as db
- [NXDRIVE-2912](https://jira.nuxeo.com/browse/NXDRIVE-2912): Display Drive notification for document review
- [NXDRIVE-2](https://jira.nuxeo.com/browse/NXDRIVE-2):

### Direct Edit
Expand Down
4 changes: 2 additions & 2 deletions nxdrive/data/qml/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ QtObject {

signal appUpdate(string version)
signal getLastFiles(string uid)
signal setStatus(string sync, string error, string update)
signal setStatus(string sync, string error, string update, string tasks)
signal updateAvailable()
signal updateProgress(int progress)

onSetStatus: systray.setStatus(sync, error, update)
onSetStatus: systray.setStatus(sync, error, update, tasks)
onUpdateAvailable: systray.updateAvailable()
onUpdateProgress: systray.updateProgress(progress)

Expand Down
15 changes: 9 additions & 6 deletions nxdrive/data/qml/Systray.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Rectangle {

signal appUpdate(string version)
signal getLastFiles(string uid)
signal setStatus(string sync, string error, string update)
signal setStatus(string sync, string error, string update, string tasks)
signal updateAvailable()
signal updateProgress(int progress)

Expand Down Expand Up @@ -73,6 +73,9 @@ Rectangle {
syncState.state = sync
errorState.state = error
updateState.state = update
if (tasks == "tasks_available") {
taskState.visible = true
}

// Force the counts update at the end of the sync
if (sync == "") {
Expand Down Expand Up @@ -379,9 +382,9 @@ Rectangle {

// Pending Tasks
SystrayStatus {
id: pendingTasks
id: taskState
state: "pending_tasks"
visible: (state == "pending_tasks")
visible: false
color: progressFilledLight
textColor: lightTheme
icon: MdiFont.Icon.bell
Expand All @@ -390,9 +393,9 @@ Rectangle {
State {
name: "pending_tasks"
PropertyChanges {
target: updateState
text: qsTr("PENDING_DOCUMENT_REVIEWS").arg(api.fetch_pending_tasks(accountSelect.getRole("uid"))) + tl.tr
// onClicked: updatePopup.open()
target: taskState
text: qsTr("PENDING_DOCUMENT_REVIEWS").arg(api.tasks_remaining(accountSelect.getRole("uid"))) + tl.tr
onClicked: api.open_tasks_window(accountSelect.getRole("uid"))
}
}
]
Expand Down
16 changes: 11 additions & 5 deletions nxdrive/gui/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,19 @@ def get_completed_sessions_count(self, uid: str, /) -> int:
return 0

@pyqtSlot(str, result=int)
def fetch_pending_tasks(self, uid: str, /) -> str:
def tasks_remaining(self, uid: str, /) -> int:
"""Return pending tasks count for Drive notification."""
"""engine = self._manager.engines.get(uid)
engine = self._manager.engines.get(uid)
if engine:
workflow = self.application.workflow
workflow.get_pending_tasks(uid, engine)"""
return 2
tasks = self.application.fetch_pending_tasks(engine)
return len(tasks)
log.info("Engine not vailable")
return

Check warning on line 247 in nxdrive/gui/api.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/api.py#L242-L247

Added lines #L242 - L247 were not covered by tests

@pyqtSlot(str)
def open_tasks_window(self, uid: str, /) -> None:
self.application.hide_systray()
print(f">>>>>> opening task window [engine_id: {uid!r}]")

Check warning on line 252 in nxdrive/gui/api.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/api.py#L251-L252

Added lines #L251 - L252 were not covered by tests

@pyqtSlot(str, str, int, float, bool)
def pause_transfer(
Expand Down
16 changes: 15 additions & 1 deletion nxdrive/gui/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -1828,6 +1828,12 @@ def ctx_direct_transfer(self, path: Path, /) -> None:
else:
self.show_server_folders(engine, path)

def fetch_pending_tasks(self, engine: Engine, /) -> list:
remote = engine.remote
user = {"userId": remote.user_id}
tasks = remote.tasks.get(user)
return tasks

Check warning on line 1835 in nxdrive/gui/application.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/application.py#L1831-L1835

Added lines #L1831 - L1835 were not covered by tests

def update_status(self, engine: Engine, /) -> None:
"""
Update the systray status for synchronization,
Expand All @@ -1841,6 +1847,12 @@ def update_status(self, engine: Engine, /) -> None:

update_state = self.manager.updater.status

tasks = self.fetch_pending_tasks(engine)
task_state = "no_tasks_available"
if len(tasks) > 0:
task_state = "tasks_available"

Check warning on line 1853 in nxdrive/gui/application.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/application.py#L1850-L1853

Added lines #L1850 - L1853 were not covered by tests
# task_state = "no_tasks_available"

# Check synchronization state
if self.manager.restart_needed:
sync_state = "restart"
Expand All @@ -1860,8 +1872,10 @@ def update_status(self, engine: Engine, /) -> None:
elif self.errors_model.count:
error_state = "error"

print(f">>>>>> task_state{task_state!r}")

Check warning on line 1875 in nxdrive/gui/application.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/gui/application.py#L1875

Added line #L1875 was not covered by tests

self._window_root(self.systray_window).setStatus.emit(
sync_state, error_state, update_state
sync_state, error_state, update_state, task_state
)

@pyqtSlot(object)
Expand Down

0 comments on commit ef421e2

Please sign in to comment.