Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee7dbd99b8 | ||
|
|
c2a3c24f82 | ||
|
|
bb6ebf194a | ||
|
|
5c186b565e | ||
|
|
39e9c6c2ea | ||
|
|
faf6b3305a | ||
|
|
88bd0e6aae | ||
|
|
39bb6c0d18 | ||
|
|
a8646e76a8 | ||
|
|
e8076700b0 | ||
|
|
f4739efd86 | ||
|
|
b9c2d061e5 | ||
|
|
4ec5d56055 |
@@ -10,3 +10,21 @@ Notifications keeps delivery state, and each domain module keeps its business
|
||||
objects and commands.
|
||||
|
||||
See [Tasks Domain And Unified Work Inbox](docs/TASKS_DOMAIN.md).
|
||||
|
||||
## Git-source WebUI package
|
||||
|
||||
The repository root exposes `@govoplan/tasks-webui` for Git-tagged release
|
||||
dependencies. It mirrors the owning `webui/package.json` version, public
|
||||
TypeScript/CSS exports and peer requirements, with entry paths under
|
||||
`webui/src`. Consumers provide the shared Core/React peers; the facade runs no
|
||||
development or install scripts. The source archive contains `webui/src`, this
|
||||
README and any repository license file. Run module development checks from `webui/`; Python
|
||||
installation remains governed by `pyproject.toml`.
|
||||
|
||||
Das Repository stellt `@govoplan/tasks-webui` am Wurzelpfad für versionierte
|
||||
Git-Abhängigkeiten bereit. Version, öffentliche TypeScript-/CSS-Exporte und
|
||||
Peer-Anforderungen entsprechen `webui/package.json`; die Einstiegspfade liegen
|
||||
unter `webui/src`. Gemeinsame Core-/React-Peers stellt die einbindende Anwendung
|
||||
bereit. Die Fassade führt keine Entwicklungs- oder Installationsskripte aus.
|
||||
Entwicklungsprüfungen bleiben in `webui/`, die Python-Installation weiterhin in
|
||||
`pyproject.toml` definiert.
|
||||
|
||||
+29
-3
@@ -1,8 +1,34 @@
|
||||
{
|
||||
"name": "@govoplan/tasks",
|
||||
"version": "0.1.19",
|
||||
"name": "@govoplan/tasks-webui",
|
||||
"version": "0.1.23",
|
||||
"private": true,
|
||||
"description": "Governed work items and unified work inbox for GovOPlaN.",
|
||||
"type": "module",
|
||||
"peerDependencies": {}
|
||||
"peerDependencies": {
|
||||
"@govoplan/core-webui": "^0.1.45",
|
||||
"lucide-react": "^1.23.0",
|
||||
"react": ">=19.2.7 <20",
|
||||
"react-dom": ">=19.2.7 <20",
|
||||
"react-router": ">=8.3.0 <9"
|
||||
},
|
||||
"main": "webui/src/index.ts",
|
||||
"module": "webui/src/index.ts",
|
||||
"types": "webui/src/index.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./webui/src/index.ts",
|
||||
"import": "./webui/src/index.ts"
|
||||
},
|
||||
"./styles/tasks.css": "./webui/src/styles/tasks.css"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@govoplan/core-webui": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"webui/src",
|
||||
"README.md",
|
||||
"LICENSE"
|
||||
]
|
||||
}
|
||||
|
||||
+2
-2
@@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "govoplan-tasks"
|
||||
version = "0.1.19"
|
||||
version = "0.1.23"
|
||||
description = "Governed work items and unified work inbox for GovOPlaN."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
authors = [{ name = "GovOPlaN" }]
|
||||
dependencies = [
|
||||
"govoplan-core>=0.1.18",
|
||||
"govoplan-core>=0.1.45",
|
||||
"govoplan-access>=0.1.18",
|
||||
]
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
"""GovOPlaN Tasks module."""
|
||||
|
||||
__version__ = "0.1.19"
|
||||
__version__ = "0.1.23"
|
||||
|
||||
@@ -0,0 +1,410 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Mapping, Sequence
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from sqlalchemy import or_
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from govoplan_core.core.dsar import (
|
||||
DsarErasureActionRef,
|
||||
DsarExecutionResultRef,
|
||||
DsarRecordRef,
|
||||
DsarSubjectRef,
|
||||
dsar_capability_name,
|
||||
)
|
||||
from govoplan_tasks.backend.db.models import TaskAssignment, TaskItem
|
||||
|
||||
|
||||
TASKS_DSAR_CAPABILITY = dsar_capability_name("tasks")
|
||||
_MAX_RECORDS = 5_000
|
||||
_MAX_SOURCES = 100
|
||||
_CONFLICT = object()
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class _SubjectSelectors:
|
||||
account_id: str | None
|
||||
actor_ids: tuple[str, ...]
|
||||
task_id: str | None
|
||||
|
||||
|
||||
class TasksDsarProvider:
|
||||
provider_id = "tasks"
|
||||
module_id = "tasks"
|
||||
|
||||
def search_subject(
|
||||
self,
|
||||
session: object,
|
||||
*,
|
||||
tenant_id: str,
|
||||
subject: DsarSubjectRef,
|
||||
) -> Sequence[DsarRecordRef]:
|
||||
db = _session(session)
|
||||
selectors = _subject_selectors(subject)
|
||||
if selectors is None:
|
||||
return ()
|
||||
|
||||
assigned_ids: set[str] = set()
|
||||
if selectors.account_id:
|
||||
assigned = (
|
||||
db.query(TaskAssignment.task_id)
|
||||
.join(TaskItem, TaskAssignment.task_id == TaskItem.id)
|
||||
.filter(
|
||||
TaskItem.tenant_id == tenant_id,
|
||||
TaskAssignment.tenant_id == tenant_id,
|
||||
TaskAssignment.assignment_kind == "account",
|
||||
TaskAssignment.assignment_id == selectors.account_id,
|
||||
)
|
||||
)
|
||||
if selectors.task_id:
|
||||
assigned = assigned.filter(TaskItem.id == selectors.task_id)
|
||||
rows = assigned.limit(_MAX_RECORDS + 1).all()
|
||||
if len(rows) > _MAX_RECORDS:
|
||||
raise ValueError(
|
||||
"Tasks DSAR assignment result limit exceeded; narrow the selectors."
|
||||
)
|
||||
assigned_ids = {str(task_id) for (task_id,) in rows}
|
||||
|
||||
actor_query = db.query(TaskItem.id).filter(
|
||||
TaskItem.tenant_id == tenant_id,
|
||||
or_(
|
||||
TaskItem.created_by.in_(selectors.actor_ids),
|
||||
TaskItem.updated_by.in_(selectors.actor_ids),
|
||||
TaskItem.completed_by.in_(selectors.actor_ids),
|
||||
),
|
||||
)
|
||||
if selectors.task_id:
|
||||
actor_query = actor_query.filter(TaskItem.id == selectors.task_id)
|
||||
actor_rows = actor_query.limit(_MAX_RECORDS + 1).all()
|
||||
if len(actor_rows) > _MAX_RECORDS:
|
||||
raise ValueError(
|
||||
"Tasks DSAR actor result limit exceeded; narrow the selectors."
|
||||
)
|
||||
actor_ids = {str(task_id) for (task_id,) in actor_rows}
|
||||
|
||||
task_ids = assigned_ids | actor_ids
|
||||
if len(task_ids) > _MAX_RECORDS:
|
||||
raise ValueError("Tasks DSAR result limit exceeded; narrow the selectors.")
|
||||
if not task_ids:
|
||||
return ()
|
||||
tasks = (
|
||||
db.query(TaskItem)
|
||||
.filter(
|
||||
TaskItem.tenant_id == tenant_id,
|
||||
TaskItem.id.in_(task_ids),
|
||||
)
|
||||
.order_by(TaskItem.created_at, TaskItem.id)
|
||||
.all()
|
||||
)
|
||||
return tuple(
|
||||
_assigned_task_record(
|
||||
task,
|
||||
account_id=selectors.account_id,
|
||||
actor_ids=selectors.actor_ids,
|
||||
)
|
||||
if task.id in assigned_ids
|
||||
else _actor_attribution_record(task, selectors.actor_ids)
|
||||
for task in tasks
|
||||
)
|
||||
|
||||
def plan_erasure(
|
||||
self,
|
||||
session: object,
|
||||
*,
|
||||
tenant_id: str,
|
||||
subject: DsarSubjectRef,
|
||||
records: Sequence[DsarRecordRef],
|
||||
) -> Sequence[DsarErasureActionRef]:
|
||||
del tenant_id
|
||||
_session(session)
|
||||
if _subject_selectors(subject) is None:
|
||||
raise ValueError("Tasks DSAR subject selectors conflict.")
|
||||
actions: list[DsarErasureActionRef] = []
|
||||
for record in records:
|
||||
_validate_record(record)
|
||||
if record.resource_type == "assigned_task":
|
||||
actions.append(
|
||||
DsarErasureActionRef(
|
||||
action_id=f"tasks:manual_review:assigned_task:{record.resource_id}",
|
||||
provider_id=self.provider_id,
|
||||
module_id=self.module_id,
|
||||
kind="manual_review",
|
||||
resource_type=record.resource_type,
|
||||
resource_id=record.resource_id,
|
||||
title=f"Review {record.title}",
|
||||
rationale=(
|
||||
"The account assignment and task content may be shared "
|
||||
"institutional work. Its source owner and retention state "
|
||||
"must be reviewed before detachment or minimization."
|
||||
),
|
||||
executable=False,
|
||||
)
|
||||
)
|
||||
else:
|
||||
actions.append(
|
||||
DsarErasureActionRef(
|
||||
action_id=(
|
||||
f"tasks:retain:task_actor_attribution:{record.resource_id}"
|
||||
),
|
||||
provider_id=self.provider_id,
|
||||
module_id=self.module_id,
|
||||
kind="retain",
|
||||
resource_type=record.resource_type,
|
||||
resource_id=record.resource_id,
|
||||
title=f"Retain {record.title}",
|
||||
rationale=record.retention_reason
|
||||
or "Task lifecycle attribution is accountability evidence.",
|
||||
executable=False,
|
||||
)
|
||||
)
|
||||
return tuple(actions)
|
||||
|
||||
def execute_erasure(
|
||||
self,
|
||||
session: object,
|
||||
*,
|
||||
tenant_id: str,
|
||||
subject: DsarSubjectRef,
|
||||
actions: Sequence[DsarErasureActionRef],
|
||||
request_id: str,
|
||||
) -> Sequence[DsarExecutionResultRef]:
|
||||
del tenant_id
|
||||
_session(session)
|
||||
if _subject_selectors(subject) is None:
|
||||
raise ValueError("Tasks DSAR subject selectors conflict.")
|
||||
results: list[DsarExecutionResultRef] = []
|
||||
for action in actions:
|
||||
_validate_action(action)
|
||||
if action.executable or action.kind not in {"retain", "manual_review"}:
|
||||
raise ValueError("Tasks DSAR publishes non-executable actions only.")
|
||||
results.append(
|
||||
DsarExecutionResultRef(
|
||||
action_id=action.action_id,
|
||||
status="blocked",
|
||||
summary=(
|
||||
"The Task remains unchanged pending its institutional "
|
||||
"retention and source-owner review."
|
||||
if action.kind == "manual_review"
|
||||
else "Task lifecycle attribution remains immutable evidence."
|
||||
),
|
||||
evidence={"request_id": request_id},
|
||||
)
|
||||
)
|
||||
return tuple(results)
|
||||
|
||||
|
||||
def _subject_selectors(subject: DsarSubjectRef) -> _SubjectSelectors | None:
|
||||
references = subject.external_references
|
||||
values = {
|
||||
"account_id": _coalesce(
|
||||
subject.account_id,
|
||||
references.get("tasks.account"),
|
||||
references.get("access.account"),
|
||||
),
|
||||
"membership_id": _coalesce(
|
||||
subject.membership_id,
|
||||
references.get("tasks.membership"),
|
||||
references.get("tenancy.membership"),
|
||||
),
|
||||
"identity_id": _coalesce(
|
||||
subject.identity_id,
|
||||
references.get("tasks.identity"),
|
||||
references.get("identity.id"),
|
||||
),
|
||||
"task_id": _coalesce(
|
||||
references.get("tasks.task"),
|
||||
references.get("tasks.item"),
|
||||
),
|
||||
}
|
||||
if any(value is _CONFLICT for value in values.values()):
|
||||
return None
|
||||
actor_ids = tuple(
|
||||
dict.fromkeys(
|
||||
value
|
||||
for key in ("account_id", "membership_id", "identity_id")
|
||||
if (value := _optional_string(values[key]))
|
||||
)
|
||||
)
|
||||
if not actor_ids:
|
||||
return None
|
||||
return _SubjectSelectors(
|
||||
account_id=_optional_string(values["account_id"]),
|
||||
actor_ids=actor_ids,
|
||||
task_id=_optional_string(values["task_id"]),
|
||||
)
|
||||
|
||||
|
||||
def _coalesce(*values: str | None) -> str | None | object:
|
||||
normalized = {str(value).strip() for value in values if str(value or "").strip()}
|
||||
if len(normalized) > 1:
|
||||
return _CONFLICT
|
||||
return next(iter(normalized), None)
|
||||
|
||||
|
||||
def _optional_string(value: object) -> str | None:
|
||||
return value if isinstance(value, str) and value else None
|
||||
|
||||
|
||||
def _assigned_task_record(
|
||||
task: TaskItem,
|
||||
*,
|
||||
account_id: str | None,
|
||||
actor_ids: Sequence[str],
|
||||
) -> DsarRecordRef:
|
||||
assignments = [
|
||||
{
|
||||
"id": assignment.id,
|
||||
"kind": assignment.assignment_kind,
|
||||
"assignment_id": assignment.assignment_id,
|
||||
"label": (assignment.assignment_label or "")[:500] or None,
|
||||
}
|
||||
for assignment in task.assignments
|
||||
if account_id
|
||||
and assignment.assignment_kind == "account"
|
||||
and assignment.assignment_id == account_id
|
||||
]
|
||||
if len(assignments) > 100:
|
||||
raise ValueError("Task account assignments exceed the DSAR bound.")
|
||||
return DsarRecordRef(
|
||||
provider_id="tasks",
|
||||
module_id="tasks",
|
||||
resource_type="assigned_task",
|
||||
resource_id=task.id,
|
||||
category="assigned_institutional_work",
|
||||
title=f"Assigned task: {task.title[:500]}",
|
||||
data={
|
||||
"title": task.title[:500],
|
||||
"summary": (task.summary or "")[:4_000] or None,
|
||||
"status": task.status,
|
||||
"priority": task.priority,
|
||||
"required_action": (task.required_action or "")[:500] or None,
|
||||
"action_url": (task.action_url or "")[:1_500] or None,
|
||||
"due_at": _iso(task.due_at),
|
||||
"deferred_until": _iso(task.deferred_until),
|
||||
"completed_at": _iso(task.completed_at),
|
||||
"cancelled_at": _iso(task.cancelled_at),
|
||||
"revision": task.revision,
|
||||
"assignments": assignments,
|
||||
"sources": _source_projection(task.sources),
|
||||
"actor_activities": _actor_activities(task, actor_ids),
|
||||
"created_at": _iso(task.created_at),
|
||||
"updated_at": _iso(task.updated_at),
|
||||
},
|
||||
observed_at=_aware(task.updated_at),
|
||||
retention_reason=(
|
||||
"The task may be shared institutional work and requires source-owner "
|
||||
"and retention review before its account assignment can be changed."
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def _actor_attribution_record(
|
||||
task: TaskItem,
|
||||
actor_ids: Sequence[str],
|
||||
) -> DsarRecordRef:
|
||||
return DsarRecordRef(
|
||||
provider_id="tasks",
|
||||
module_id="tasks",
|
||||
resource_type="task_actor_attribution",
|
||||
resource_id=task.id,
|
||||
category="operator_accountability_evidence",
|
||||
title="Task lifecycle attribution",
|
||||
data={
|
||||
"activities": _actor_activities(task, actor_ids),
|
||||
"status": task.status,
|
||||
"priority": task.priority,
|
||||
"source_module": task.source_module,
|
||||
"source_resource_type": task.source_resource_type,
|
||||
"source_resource_id": task.source_resource_id,
|
||||
"source_revision": task.source_revision,
|
||||
"revision": task.revision,
|
||||
"created_at": _iso(task.created_at),
|
||||
"updated_at": _iso(task.updated_at),
|
||||
"completed_at": _iso(task.completed_at),
|
||||
},
|
||||
observed_at=_aware(task.updated_at),
|
||||
immutable_evidence=True,
|
||||
retention_reason=(
|
||||
"Task creation, update, and completion attribution is immutable "
|
||||
"accountability evidence; task content and metadata are excluded."
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def _actor_activities(task: TaskItem, actor_ids: Sequence[str]) -> list[str]:
|
||||
actor_set = set(actor_ids)
|
||||
activities = []
|
||||
if task.created_by in actor_set:
|
||||
activities.append("created_task")
|
||||
if task.updated_by in actor_set:
|
||||
activities.append("updated_task")
|
||||
if task.completed_by in actor_set:
|
||||
activities.append("completed_task")
|
||||
return activities
|
||||
|
||||
|
||||
def _source_projection(value: object) -> list[dict[str, str | None]]:
|
||||
if not isinstance(value, list) or len(value) > _MAX_SOURCES:
|
||||
raise ValueError("Tasks source references exceed the DSAR bound.")
|
||||
projected: list[dict[str, str | None]] = []
|
||||
for item in value:
|
||||
if not isinstance(item, Mapping):
|
||||
raise ValueError("Task source reference is invalid.")
|
||||
projected.append(
|
||||
{
|
||||
"module_id": _bounded(item.get("module_id"), 100),
|
||||
"resource_type": _bounded(item.get("resource_type"), 100),
|
||||
"resource_id": _bounded(item.get("resource_id"), 255),
|
||||
"revision": _bounded(item.get("revision"), 255),
|
||||
"url": _bounded(item.get("url"), 1_500),
|
||||
"label": _bounded(item.get("label"), 500),
|
||||
}
|
||||
)
|
||||
return projected
|
||||
|
||||
|
||||
def _bounded(value: object, limit: int) -> str | None:
|
||||
return str(value)[:limit] if value is not None else None
|
||||
|
||||
|
||||
def _iso(value: datetime | None) -> str | None:
|
||||
aware = _aware(value)
|
||||
return aware.isoformat() if aware else None
|
||||
|
||||
|
||||
def _aware(value: datetime | None) -> datetime | None:
|
||||
if value is None or value.tzinfo is not None:
|
||||
return value
|
||||
return value.replace(tzinfo=timezone.utc)
|
||||
|
||||
|
||||
def _session(value: object) -> Session:
|
||||
if not isinstance(value, Session):
|
||||
raise TypeError("Tasks DSAR requires a SQLAlchemy Session.")
|
||||
return value
|
||||
|
||||
|
||||
def _validate_record(record: DsarRecordRef) -> None:
|
||||
if record.provider_id != "tasks" or record.module_id != "tasks":
|
||||
raise ValueError("Tasks DSAR cannot plan a foreign provider record.")
|
||||
if (
|
||||
record.resource_type
|
||||
not in {
|
||||
"assigned_task",
|
||||
"task_actor_attribution",
|
||||
}
|
||||
or not record.resource_id
|
||||
):
|
||||
raise ValueError("Tasks DSAR record identity is invalid.")
|
||||
|
||||
|
||||
def _validate_action(action: DsarErasureActionRef) -> None:
|
||||
if action.provider_id != "tasks" or action.module_id != "tasks":
|
||||
raise ValueError("Tasks DSAR cannot execute a foreign provider action.")
|
||||
if not action.action_id.startswith("tasks:"):
|
||||
raise ValueError("Tasks DSAR action identity is invalid.")
|
||||
|
||||
|
||||
__all__ = ["TASKS_DSAR_CAPABILITY", "TasksDsarProvider"]
|
||||
@@ -0,0 +1,29 @@
|
||||
"""German translations for public structured documentation metadata."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
|
||||
GERMAN_STRUCTURED_TRANSLATIONS: dict[str, dict[str, Any]] = {'tasks.data-subject-requests': {'consequence_classes': {'export_assigned_task': 'Gibt nur '
|
||||
'eingeschränkte '
|
||||
'aufgabeneigene '
|
||||
'Daten und genaue '
|
||||
'Kontozuweisung '
|
||||
'zurück.',
|
||||
'retain_actor_attribution': 'Bewahrt '
|
||||
'minimierte '
|
||||
'Task-Lifecycle-Rechenschaftsnachweise '
|
||||
'vor.',
|
||||
'review_assignment_erasure': 'Benötigt '
|
||||
'den '
|
||||
'Besitzer '
|
||||
'der '
|
||||
'Task-Quelle '
|
||||
'und die '
|
||||
'Aufbewahrungsberechtigung, '
|
||||
'bevor Sie '
|
||||
'die '
|
||||
'freigegebene '
|
||||
'Arbeit '
|
||||
'ändern.'}}}
|
||||
@@ -1,5 +1,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from govoplan_core.core.modules import with_documentation_structured_translations
|
||||
from govoplan_tasks.backend.german_structured_documentation import GERMAN_STRUCTURED_TRANSLATIONS
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from govoplan_core.core.access import (
|
||||
@@ -12,6 +15,7 @@ from govoplan_core.core.module_guards import (
|
||||
)
|
||||
from govoplan_core.core.modules import (
|
||||
CapabilityDocumentation,
|
||||
DocumentationCondition,
|
||||
DocumentationLink,
|
||||
DocumentationTopic,
|
||||
FrontendModule,
|
||||
@@ -22,7 +26,9 @@ from govoplan_core.core.modules import (
|
||||
ModuleManifest,
|
||||
NavItem,
|
||||
PermissionDefinition,
|
||||
ProductAvailabilityExplanation,
|
||||
ProductAreaContribution,
|
||||
ProductSurfaceContribution,
|
||||
QuickAccessTool,
|
||||
RoleTemplate,
|
||||
)
|
||||
@@ -34,12 +40,16 @@ from govoplan_core.core.tasks import (
|
||||
from govoplan_core.core.views import ViewSurface
|
||||
from govoplan_core.db.base import Base
|
||||
from govoplan_tasks.backend.db import models as task_models
|
||||
from govoplan_tasks.backend.dsar_provider import (
|
||||
TASKS_DSAR_CAPABILITY,
|
||||
TasksDsarProvider,
|
||||
)
|
||||
from govoplan_tasks.backend.service import SqlTaskService
|
||||
|
||||
|
||||
MODULE_ID = "tasks"
|
||||
MODULE_NAME = "Tasks"
|
||||
MODULE_VERSION = "0.1.19"
|
||||
MODULE_VERSION = "0.1.23"
|
||||
READ_SCOPE = "tasks:item:read"
|
||||
WRITE_SCOPE = "tasks:item:write"
|
||||
ADMIN_SCOPE = "tasks:item:admin"
|
||||
@@ -69,6 +79,10 @@ def _service(context: ModuleContext) -> SqlTaskService:
|
||||
return SqlTaskService(context.registry)
|
||||
|
||||
|
||||
def _dsar_provider(_context: ModuleContext) -> TasksDsarProvider:
|
||||
return TasksDsarProvider()
|
||||
|
||||
|
||||
def _tenant_summary(session, tenant_id: str) -> dict[str, int]:
|
||||
total = (
|
||||
session.query(task_models.TaskItem)
|
||||
@@ -122,14 +136,107 @@ ROLE_TEMPLATES = (
|
||||
)
|
||||
|
||||
DOCUMENTATION = (
|
||||
DocumentationTopic(
|
||||
id="tasks.workspace-layout",
|
||||
title="Tasks workspace actions",
|
||||
summary="Find collection-wide commands in their consistent workspace position.",
|
||||
body="Documentation books sit immediately beside the visible heading or contextual label for "
|
||||
"Tasks, not among operational action buttons. Field help remains beside its label. "
|
||||
"Reload and Create task use the persistent full-width workspace header at the upper right; Reload sits immediately before creation. Selecting a record, changing filters, or opening an editor does not move these collection-wide commands into the left pane. Search and status filters stay in the task list; completion, ownership, and other task-specific actions remain with the selected task. Existing permissions, disabled-state rules, and unsaved-change guards still apply. Administrators configure authority through the existing permission system; no new permission or automatic operation is introduced.",
|
||||
layer="static",
|
||||
documentation_types=("user", "admin"),
|
||||
audience=("user", "module_admin", "operator"),
|
||||
order=5,
|
||||
translations={"de": {
|
||||
"title": "Aufgaben: Aktionen im Arbeitsbereich",
|
||||
"summary": "Sammlungsweite Aktionen an ihrer einheitlichen Position im Arbeitsbereich finden.",
|
||||
"body": "Dokumentationsbücher stehen unmittelbar neben der sichtbaren Überschrift oder "
|
||||
"Kontextbezeichnung für Aufgaben, nicht zwischen ausführbaren Aktionsschaltflächen. Feldhilfe "
|
||||
"bleibt neben der Feldbezeichnung. "
|
||||
"Neu laden und Aufgabe anlegen stehen oben rechts in der dauerhaft sichtbaren, arbeitsbereichsweiten Leiste; Neu laden steht unmittelbar vor dem Anlegen. Auswahl, Filterwechsel und Bearbeitung verschieben diese sammlungsweiten Aktionen nicht in den linken Bereich. Suche und Statusfilter bleiben in der Aufgabenliste; Abschluss, Zuständigkeit und weitere aufgabenspezifische Aktionen bleiben bei der ausgewählten Aufgabe. Bestehende Berechtigungen, Deaktivierungsregeln und der Schutz ungespeicherter Änderungen gelten weiterhin. Administratoren konfigurieren Rechte im bestehenden Berechtigungssystem; es entstehen weder neue Rechte noch automatische Vorgänge.",
|
||||
}},
|
||||
),
|
||||
DocumentationTopic(
|
||||
id="tasks.data-subject-requests",
|
||||
title="Task data-subject requests",
|
||||
summary=(
|
||||
"Export account-assigned task data and lifecycle attribution while "
|
||||
"keeping shared institutional work under owner review."
|
||||
),
|
||||
body=(
|
||||
"Tasks correlates exact account and actor identifiers only inside the "
|
||||
"active tenant. Account-assigned explicit Tasks contribute bounded "
|
||||
"title, summary, required action, lifecycle state, due dates, the exact "
|
||||
"matching account assignment, source references, and any create, update, "
|
||||
"or completion activities performed by the subject. Group, role, function, "
|
||||
"and anyone visibility is not inferred from external directories and other "
|
||||
"assignment targets are excluded. When the subject acted on a Task without "
|
||||
"being its direct account assignee, only minimized lifecycle attribution "
|
||||
"and source identity are exported. Provenance, arbitrary metadata, request "
|
||||
"hashes, idempotency keys, and source-module payloads are excluded; source "
|
||||
"references are never traversed. Task attribution is retained as immutable "
|
||||
"accountability evidence. Assignment or content erasure requires manual "
|
||||
"source-owner and retention review because a Task can be shared institutional "
|
||||
"work; the provider performs no automatic mutation."
|
||||
),
|
||||
layer="configured",
|
||||
documentation_types=("admin", "user"),
|
||||
audience=("user", "tenant_admin", "operator", "auditor"),
|
||||
related_modules=("core", "workflow_engine", "approvals", "notifications"),
|
||||
translations={
|
||||
"de": {
|
||||
"title": "Betroffenenanfragen für Aufgaben",
|
||||
"summary": (
|
||||
"Kontobezogene Aufgabendaten und Lebenszykluszuordnungen exportieren, "
|
||||
"während gemeinsam verantwortete institutionelle Arbeit der fachlichen Prüfung unterliegt."
|
||||
),
|
||||
"body": (
|
||||
"Tasks gleicht ausschließlich exakte Konto- und Akteurskennungen innerhalb des aktiven Mandanten ab. "
|
||||
"Direkt einem Konto zugewiesene Aufgaben tragen begrenzte Angaben zu Titel, Zusammenfassung, erforderlicher "
|
||||
"Handlung, Lebenszyklusstatus, Fristen, exakter Kontozuweisung, Quellverweisen sowie vom Betroffenen ausgeführten "
|
||||
"Erstellungs-, Änderungs- oder Abschlussaktivitäten bei. Sichtbarkeit für Gruppen, Rollen, Funktionen oder alle "
|
||||
"wird nicht aus externen Verzeichnissen abgeleitet; andere Zuweisungsziele bleiben ausgeschlossen. Hat die "
|
||||
"betroffene Person an einer Aufgabe gehandelt, ohne deren direkte Kontozuweisung zu sein, werden nur minimierte "
|
||||
"Lebenszykluszuordnung und Quellidentität exportiert. Herkunftsmetadaten, beliebige Metadaten, Anfrage-Hashes, "
|
||||
"Idempotenzschlüssel und Nutzdaten des Quellmoduls bleiben ausgeschlossen; Quellverweise werden niemals verfolgt. "
|
||||
"Aufgabenzuordnungen bleiben als unveränderlicher Verantwortungsnachweis erhalten. Die Löschung einer Zuweisung "
|
||||
"oder von Inhalten erfordert eine manuelle Prüfung durch Quellverantwortliche und Aufbewahrungsstelle, da eine "
|
||||
"Aufgabe gemeinsam verantwortete institutionelle Arbeit sein kann; der Anbieter nimmt keine automatische Änderung vor."
|
||||
),
|
||||
}
|
||||
},
|
||||
metadata={
|
||||
"help_contexts": [
|
||||
"tasks.page.inbox",
|
||||
"tasks.page.detail",
|
||||
"tasks.field.assignment",
|
||||
"privacy.data-subject-requests",
|
||||
],
|
||||
"consequence_classes": {
|
||||
"export_assigned_task": (
|
||||
"Returns bounded Task-owned data and exact account assignment only."
|
||||
),
|
||||
"review_assignment_erasure": (
|
||||
"Requires the Task source owner and retention authority before "
|
||||
"changing shared work."
|
||||
),
|
||||
"retain_actor_attribution": (
|
||||
"Preserves minimized Task lifecycle accountability evidence."
|
||||
),
|
||||
},
|
||||
},
|
||||
),
|
||||
DocumentationTopic(
|
||||
id="tasks.quick-access-and-product-area",
|
||||
title="Work in product navigation and Quick Access",
|
||||
summary="Keep assigned work available in the Work area and the optional right-side Quick Access rail.",
|
||||
body=(
|
||||
"Tasks contributes its authorized workspace to the Work product area. When Quick Access is enabled, "
|
||||
"the same provider-owned open-work summary can appear beside the current page. Views may hide or reorder "
|
||||
"the contribution, but neither presentation grants task access or changes completion state."
|
||||
"Tasks contributes its authorized workspace to the stable Work destination at /work. The owner route "
|
||||
"/tasks remains available through All available tools and as a compatible deep link. When Quick Access is enabled, "
|
||||
"a bounded seven-item authorized inbox and detail can appear beside the current page. Explicit Tasks can be "
|
||||
"started or completed there; work from another provider exposes only that provider's launch path. Every load "
|
||||
"and command is rechecked by Tasks, and completion returns a typed work-item reference to the host. Views may "
|
||||
"hide or reorder the contribution, but neither presentation grants task access or copies completion state."
|
||||
),
|
||||
layer="configured",
|
||||
documentation_types=("user", "admin"),
|
||||
@@ -140,9 +247,12 @@ DOCUMENTATION = (
|
||||
"title": "Arbeit in Produktnavigation und Schnellzugriff",
|
||||
"summary": "Zugewiesene Arbeit im Produktbereich Arbeit und optional in der rechten Schnellzugriffsleiste verwenden.",
|
||||
"body": (
|
||||
"Tasks ordnet den berechtigten Arbeitsbereich dem Produktbereich Arbeit zu. Ist der Schnellzugriff aktiviert, "
|
||||
"kann dieselbe vom Modul verantwortete Zusammenfassung offener Arbeit neben der aktuellen Seite erscheinen. "
|
||||
"Ansichten dürfen den Beitrag ausblenden oder ordnen, erteilen aber keine Aufgabenberechtigung."
|
||||
"Tasks ordnet den berechtigten Arbeitsbereich dem stabilen Produktziel Arbeit unter /work zu. Der Eigentümerpfad "
|
||||
"/tasks bleibt unter Alle verfügbaren Werkzeuge und als kompatibler Direktlink erreichbar. Ist der Schnellzugriff aktiviert, "
|
||||
"kann ein begrenzter, berechtigungsgeprüfter Arbeitsvorrat mit sieben Einträgen und Details neben der "
|
||||
"aktuellen Seite erscheinen. Explizite Tasks lassen sich dort beginnen oder abschließen; fremde Quellen "
|
||||
"behalten ihre eigenen Befehle und Startpfade. Jeder Aufruf wird erneut durch Tasks geprüft. Ansichten "
|
||||
"dürfen den Beitrag ausblenden oder ordnen, erteilen aber keine Aufgabenberechtigung."
|
||||
),
|
||||
}
|
||||
},
|
||||
@@ -170,6 +280,12 @@ DOCUMENTATION = (
|
||||
"views",
|
||||
"dashboard",
|
||||
),
|
||||
conditions=(
|
||||
DocumentationCondition(
|
||||
required_modules=("tasks",),
|
||||
required_scopes=(READ_SCOPE,),
|
||||
),
|
||||
),
|
||||
links=(
|
||||
DocumentationLink(
|
||||
label="Tasks domain",
|
||||
@@ -180,16 +296,17 @@ DOCUMENTATION = (
|
||||
translations={
|
||||
"de": {
|
||||
"title": "Gemeinsamer Arbeitsvorrat",
|
||||
"summary": "Explizite Aufgaben und Arbeitsvorgaenge anderer Module sicher fortsetzen.",
|
||||
"summary": "Explizite Aufgaben und Arbeitsvorgänge anderer Module sicher fortsetzen.",
|
||||
"body": (
|
||||
"Der Arbeitsvorrat verbindet explizite Aufgaben mit Arbeitsobjekten aktivierter Module. "
|
||||
"Jede Quelle behaelt die Verantwortung fuer Befehle und Abschlussstatus. Tasks kopiert "
|
||||
"keine Workflow-Uebergabe, Postfachnachricht, Freigabe oder Benachrichtigung in einen "
|
||||
"zweiten Fachzustand. Filter, Fristen, Prioritaeten und Quellverweise helfen beim sicheren Fortsetzen."
|
||||
"Jede Quelle behält die Verantwortung für Befehle und Abschlussstatus. Tasks kopiert "
|
||||
"keine Workflow-Übergabe, Postfachnachricht, Freigabe oder Benachrichtigung in einen "
|
||||
"zweiten Fachzustand. Filter, Fristen, Prioritäten und Quellverweise helfen beim sicheren Fortsetzen."
|
||||
),
|
||||
}
|
||||
},
|
||||
metadata={
|
||||
"kind": "workflow",
|
||||
"help_contexts": [
|
||||
"tasks.route.work",
|
||||
"tasks.page.inbox",
|
||||
@@ -228,6 +345,7 @@ manifest = ModuleManifest(
|
||||
provides_interfaces=(
|
||||
ModuleInterfaceProvider(name=CAPABILITY_TASK_COMMANDS, version="1.0.0"),
|
||||
ModuleInterfaceProvider(name="tasks.work_items", version="1.0.0"),
|
||||
ModuleInterfaceProvider(name=TASKS_DSAR_CAPABILITY, version="0.1.0"),
|
||||
),
|
||||
permissions=PERMISSIONS,
|
||||
role_templates=ROLE_TEMPLATES,
|
||||
@@ -313,6 +431,30 @@ manifest = ModuleManifest(
|
||||
order=10,
|
||||
),
|
||||
),
|
||||
product_surfaces=(
|
||||
ProductSurfaceContribution(
|
||||
id="work.items",
|
||||
module_id=MODULE_ID,
|
||||
label="i18n:govoplan-core.product_surface.work",
|
||||
description="i18n:govoplan-core.product_surface.work_description",
|
||||
icon="list-checks",
|
||||
entry_path="/work",
|
||||
route_path="/tasks",
|
||||
surface_ids=("tasks.route.work",),
|
||||
presentations=("task", "reader"),
|
||||
help_context_ids=("tasks.route.work",),
|
||||
documentation_topic_ids=("tasks.quick-access-and-product-area",),
|
||||
required_any=(READ_SCOPE,),
|
||||
order=10,
|
||||
unavailable=ProductAvailabilityExplanation(
|
||||
reason="authorization",
|
||||
title="i18n:govoplan-core.product_surface.unavailable",
|
||||
description="i18n:govoplan-core.product_surface.unavailable_description",
|
||||
resolution="i18n:govoplan-core.product_surface.unavailable_resolution",
|
||||
responsible_role="i18n:govoplan-core.access_administrator",
|
||||
),
|
||||
),
|
||||
),
|
||||
quick_access_tools=(
|
||||
QuickAccessTool(
|
||||
id="tasks.work",
|
||||
@@ -326,17 +468,30 @@ manifest = ModuleManifest(
|
||||
required_any=(READ_SCOPE,),
|
||||
order=10,
|
||||
modes=("browse", "resume"),
|
||||
returned_reference_kinds=("tasks.work-item",),
|
||||
help_context_id="tasks.quick_access.work",
|
||||
),
|
||||
),
|
||||
),
|
||||
tenant_summary_providers=(_tenant_summary,),
|
||||
capability_factories={CAPABILITY_TASK_COMMANDS: _service},
|
||||
capability_factories={
|
||||
CAPABILITY_TASK_COMMANDS: _service,
|
||||
TASKS_DSAR_CAPABILITY: _dsar_provider,
|
||||
},
|
||||
capability_documentation={
|
||||
CAPABILITY_TASK_COMMANDS: CapabilityDocumentation(
|
||||
label="Task commands",
|
||||
summary="Creates replay-safe explicit tasks without importing the Tasks implementation.",
|
||||
contract_version="1.0.0",
|
||||
)
|
||||
),
|
||||
TASKS_DSAR_CAPABILITY: CapabilityDocumentation(
|
||||
label="Tasks data-subject request provider",
|
||||
summary=(
|
||||
"Exports account-assigned Tasks and minimized actor attribution "
|
||||
"with governed non-executable erasure outcomes."
|
||||
),
|
||||
contract_version="0.1.0",
|
||||
),
|
||||
},
|
||||
work_item_providers=(
|
||||
WorkItemProviderRegistration(id="tasks.explicit", factory=_service, order=10),
|
||||
@@ -388,6 +543,11 @@ manifest = ModuleManifest(
|
||||
)
|
||||
|
||||
|
||||
manifest = with_documentation_structured_translations(
|
||||
manifest, locale="de", translations=GERMAN_STRUCTURED_TRANSLATIONS
|
||||
)
|
||||
|
||||
|
||||
def get_manifest() -> ModuleManifest:
|
||||
return manifest
|
||||
|
||||
|
||||
@@ -0,0 +1,376 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import unittest
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from govoplan_core.core.dsar import (
|
||||
DsarErasureActionRef,
|
||||
DsarProvider,
|
||||
DsarRecordRef,
|
||||
DsarSubjectRef,
|
||||
)
|
||||
from govoplan_core.db.base import Base
|
||||
from govoplan_core.privacy.dsar_workflow import (
|
||||
create_data_subject_request,
|
||||
search_data_subject_request,
|
||||
)
|
||||
from govoplan_tasks.backend.db.models import TaskAssignment, TaskItem
|
||||
from govoplan_tasks.backend.dsar_provider import (
|
||||
TASKS_DSAR_CAPABILITY,
|
||||
TasksDsarProvider,
|
||||
)
|
||||
from govoplan_tasks.backend.manifest import manifest
|
||||
|
||||
|
||||
class _Registry:
|
||||
def __init__(self, provider: TasksDsarProvider, *, active: bool = True) -> None:
|
||||
self.provider = provider
|
||||
self.active = active
|
||||
|
||||
def capability_names(self):
|
||||
return (TASKS_DSAR_CAPABILITY,)
|
||||
|
||||
def capability_owner(self, name):
|
||||
self._assert_capability(name)
|
||||
return "tasks"
|
||||
|
||||
def tenant_entitlement_resolver(self):
|
||||
active = self.active
|
||||
|
||||
class _Resolver:
|
||||
@staticmethod
|
||||
def resolve(session, tenant_id):
|
||||
del session, tenant_id
|
||||
return type(
|
||||
"State",
|
||||
(),
|
||||
{"effective_modules": ("tasks",) if active else ()},
|
||||
)()
|
||||
|
||||
return _Resolver()
|
||||
|
||||
def require_tenant_capability(self, name, session, **kwargs):
|
||||
del session, kwargs
|
||||
self._assert_capability(name)
|
||||
return self.provider
|
||||
|
||||
def manifests(self):
|
||||
return (type("Manifest", (), {"id": "tasks"})(),)
|
||||
|
||||
@staticmethod
|
||||
def _assert_capability(name: str) -> None:
|
||||
if name != TASKS_DSAR_CAPABILITY:
|
||||
raise KeyError(name)
|
||||
|
||||
|
||||
class TasksDsarProviderTests(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.engine = create_engine("sqlite+pysqlite:///:memory:")
|
||||
Base.metadata.create_all(self.engine)
|
||||
self.session = Session(self.engine)
|
||||
self.provider = TasksDsarProvider()
|
||||
self.assertIsInstance(self.provider, DsarProvider)
|
||||
self._seed()
|
||||
self.session.commit()
|
||||
|
||||
def tearDown(self) -> None:
|
||||
self.session.close()
|
||||
self.engine.dispose()
|
||||
|
||||
def _task(
|
||||
self,
|
||||
task_id: str,
|
||||
*,
|
||||
tenant_id: str = "tenant-1",
|
||||
created_by: str = "account-other",
|
||||
updated_by: str = "account-other",
|
||||
completed_by: str | None = None,
|
||||
) -> TaskItem:
|
||||
return TaskItem(
|
||||
id=task_id,
|
||||
tenant_id=tenant_id,
|
||||
title=f"Private title for {task_id}",
|
||||
summary=f"Private summary for {task_id}",
|
||||
status="completed" if completed_by else "open",
|
||||
priority="high",
|
||||
required_action="Review the source decision",
|
||||
action_url="/cases/case-1",
|
||||
source_module="cases",
|
||||
source_resource_type="case",
|
||||
source_resource_id="case-1",
|
||||
source_revision="4",
|
||||
sources=[
|
||||
{
|
||||
"module_id": "cases",
|
||||
"resource_type": "case",
|
||||
"resource_id": "case-1",
|
||||
"revision": "4",
|
||||
"url": "/cases/case-1",
|
||||
"label": "Case reference",
|
||||
}
|
||||
],
|
||||
provenance={"secret": "provenance-secret-do-not-export"},
|
||||
metadata_={"secret": "metadata-secret-do-not-export"},
|
||||
revision=2,
|
||||
idempotency_key=f"idempotency-{task_id}-do-not-export",
|
||||
request_sha256="a" * 64,
|
||||
created_by=created_by,
|
||||
updated_by=updated_by,
|
||||
completed_by=completed_by,
|
||||
)
|
||||
|
||||
def _seed(self) -> None:
|
||||
assigned = self._task("task-assigned")
|
||||
assigned.assignments.extend(
|
||||
(
|
||||
TaskAssignment(
|
||||
id="assignment-account",
|
||||
tenant_id="tenant-1",
|
||||
assignment_kind="account",
|
||||
assignment_id="account-1",
|
||||
assignment_label="Resident account",
|
||||
),
|
||||
TaskAssignment(
|
||||
id="assignment-group",
|
||||
tenant_id="tenant-1",
|
||||
assignment_kind="group",
|
||||
assignment_id="group-private",
|
||||
assignment_label="Private group label do not export",
|
||||
),
|
||||
)
|
||||
)
|
||||
actor_only = self._task(
|
||||
"task-actor-only",
|
||||
created_by="account-1",
|
||||
updated_by="account-1",
|
||||
completed_by="account-1",
|
||||
)
|
||||
actor_only.assignments.append(
|
||||
TaskAssignment(
|
||||
id="assignment-other",
|
||||
tenant_id="tenant-1",
|
||||
assignment_kind="account",
|
||||
assignment_id="account-other",
|
||||
assignment_label="Other account",
|
||||
)
|
||||
)
|
||||
other = self._task("task-other")
|
||||
other.assignments.append(
|
||||
TaskAssignment(
|
||||
id="assignment-other-task",
|
||||
tenant_id="tenant-1",
|
||||
assignment_kind="account",
|
||||
assignment_id="account-other",
|
||||
)
|
||||
)
|
||||
other_tenant = self._task(
|
||||
"task-other-tenant",
|
||||
tenant_id="tenant-2",
|
||||
created_by="account-1",
|
||||
updated_by="account-1",
|
||||
)
|
||||
other_tenant.assignments.append(
|
||||
TaskAssignment(
|
||||
id="assignment-other-tenant",
|
||||
tenant_id="tenant-2",
|
||||
assignment_kind="account",
|
||||
assignment_id="account-1",
|
||||
)
|
||||
)
|
||||
self.session.add_all((assigned, actor_only, other, other_tenant))
|
||||
|
||||
@staticmethod
|
||||
def _subject() -> DsarSubjectRef:
|
||||
return DsarSubjectRef(account_id="account-1")
|
||||
|
||||
def test_search_exports_assigned_task_and_minimized_actor_attribution(self) -> None:
|
||||
records = self.provider.search_subject(
|
||||
self.session,
|
||||
tenant_id="tenant-1",
|
||||
subject=self._subject(),
|
||||
)
|
||||
|
||||
by_id = {record.resource_id: record for record in records}
|
||||
self.assertEqual(
|
||||
{"task-assigned", "task-actor-only"},
|
||||
set(by_id),
|
||||
)
|
||||
self.assertEqual("assigned_task", by_id["task-assigned"].resource_type)
|
||||
self.assertEqual(
|
||||
"task_actor_attribution",
|
||||
by_id["task-actor-only"].resource_type,
|
||||
)
|
||||
exported = json.dumps([record.to_dict() for record in records])
|
||||
self.assertIn("Private summary for task-assigned", exported)
|
||||
self.assertIn('"module_id": "cases"', exported)
|
||||
self.assertIn('"resource_id": "case-1"', exported)
|
||||
self.assertIn("completed_task", exported)
|
||||
self.assertNotIn("Private summary for task-actor-only", exported)
|
||||
self.assertNotIn("Private group label do not export", exported)
|
||||
self.assertNotIn("group-private", exported)
|
||||
self.assertNotIn("provenance-secret-do-not-export", exported)
|
||||
self.assertNotIn("metadata-secret-do-not-export", exported)
|
||||
self.assertNotIn("idempotency-task-assigned-do-not-export", exported)
|
||||
self.assertNotIn("task-other-tenant", exported)
|
||||
|
||||
def test_exact_task_reference_narrows_and_conflicts_fail_closed(self) -> None:
|
||||
narrowed = self.provider.search_subject(
|
||||
self.session,
|
||||
tenant_id="tenant-1",
|
||||
subject=DsarSubjectRef(
|
||||
account_id="account-1",
|
||||
external_references={"tasks.task": "task-assigned"},
|
||||
),
|
||||
)
|
||||
conflict = self.provider.search_subject(
|
||||
self.session,
|
||||
tenant_id="tenant-1",
|
||||
subject=DsarSubjectRef(
|
||||
account_id="account-1",
|
||||
external_references={"tasks.account": "account-other"},
|
||||
),
|
||||
)
|
||||
reference_only = self.provider.search_subject(
|
||||
self.session,
|
||||
tenant_id="tenant-1",
|
||||
subject=DsarSubjectRef(external_references={"tasks.task": "task-assigned"}),
|
||||
)
|
||||
|
||||
self.assertEqual(["task-assigned"], [item.resource_id for item in narrowed])
|
||||
self.assertEqual((), conflict)
|
||||
self.assertEqual((), reference_only)
|
||||
|
||||
def test_erasure_requires_review_or_retention_and_changes_nothing(self) -> None:
|
||||
subject = self._subject()
|
||||
records = self.provider.search_subject(
|
||||
self.session,
|
||||
tenant_id="tenant-1",
|
||||
subject=subject,
|
||||
)
|
||||
actions = self.provider.plan_erasure(
|
||||
self.session,
|
||||
tenant_id="tenant-1",
|
||||
subject=subject,
|
||||
records=records,
|
||||
)
|
||||
self.assertEqual(
|
||||
{"manual_review", "retain"},
|
||||
{action.kind for action in actions},
|
||||
)
|
||||
self.assertTrue(all(not action.executable for action in actions))
|
||||
|
||||
results = self.provider.execute_erasure(
|
||||
self.session,
|
||||
tenant_id="tenant-1",
|
||||
subject=subject,
|
||||
actions=actions,
|
||||
request_id="dsar-1",
|
||||
)
|
||||
self.assertTrue(all(result.status == "blocked" for result in results))
|
||||
self.assertIsNotNone(self.session.get(TaskItem, "task-assigned"))
|
||||
self.assertIsNotNone(self.session.get(TaskAssignment, "assignment-account"))
|
||||
|
||||
def test_foreign_records_and_actions_are_rejected(self) -> None:
|
||||
subject = self._subject()
|
||||
with self.assertRaisesRegex(ValueError, "foreign provider record"):
|
||||
self.provider.plan_erasure(
|
||||
self.session,
|
||||
tenant_id="tenant-1",
|
||||
subject=subject,
|
||||
records=(
|
||||
DsarRecordRef(
|
||||
provider_id="workflow_engine",
|
||||
module_id="workflow_engine",
|
||||
resource_type="assigned_task",
|
||||
resource_id="task-assigned",
|
||||
category="work",
|
||||
title="Foreign task",
|
||||
),
|
||||
),
|
||||
)
|
||||
with self.assertRaisesRegex(ValueError, "foreign provider action"):
|
||||
self.provider.execute_erasure(
|
||||
self.session,
|
||||
tenant_id="tenant-1",
|
||||
subject=subject,
|
||||
actions=(
|
||||
DsarErasureActionRef(
|
||||
action_id="workflow_engine:retain:task:task-assigned",
|
||||
provider_id="workflow_engine",
|
||||
module_id="workflow_engine",
|
||||
kind="retain",
|
||||
resource_type="task_actor_attribution",
|
||||
resource_id="task-assigned",
|
||||
title="Retain task",
|
||||
rationale="Foreign action",
|
||||
executable=False,
|
||||
),
|
||||
),
|
||||
request_id="dsar-1",
|
||||
)
|
||||
|
||||
def test_core_workflow_and_manifest_register_provider(self) -> None:
|
||||
row = create_data_subject_request(
|
||||
self.session,
|
||||
tenant_id="tenant-1",
|
||||
reference="DSAR-TASKS-1",
|
||||
request_kind="access",
|
||||
subject=self._subject(),
|
||||
purpose="Respond to a verified request.",
|
||||
legal_basis="Article 15 GDPR",
|
||||
due_at=None,
|
||||
requested_by_account_id="privacy-officer",
|
||||
)
|
||||
self.session.commit()
|
||||
search_data_subject_request(
|
||||
self.session,
|
||||
registry=_Registry(self.provider),
|
||||
row=row,
|
||||
expected_revision=1,
|
||||
)
|
||||
self.assertEqual([TASKS_DSAR_CAPABILITY], row.coverage["provider_capabilities"])
|
||||
self.assertEqual(2, row.search_result["record_count"])
|
||||
|
||||
inactive = create_data_subject_request(
|
||||
self.session,
|
||||
tenant_id="tenant-1",
|
||||
reference="DSAR-TASKS-2",
|
||||
request_kind="access",
|
||||
subject=self._subject(),
|
||||
purpose="Respond to a verified request.",
|
||||
legal_basis="Article 15 GDPR",
|
||||
due_at=None,
|
||||
requested_by_account_id="privacy-officer",
|
||||
)
|
||||
self.session.commit()
|
||||
search_data_subject_request(
|
||||
self.session,
|
||||
registry=_Registry(self.provider, active=False),
|
||||
row=inactive,
|
||||
expected_revision=1,
|
||||
)
|
||||
self.assertEqual(
|
||||
[TASKS_DSAR_CAPABILITY],
|
||||
inactive.coverage["inactive_provider_capabilities"],
|
||||
)
|
||||
|
||||
self.assertIn(TASKS_DSAR_CAPABILITY, manifest.capability_factories)
|
||||
self.assertIn(TASKS_DSAR_CAPABILITY, manifest.capability_documentation)
|
||||
self.assertIn(
|
||||
TASKS_DSAR_CAPABILITY,
|
||||
{item.name for item in manifest.provides_interfaces},
|
||||
)
|
||||
self.assertTrue(
|
||||
any(
|
||||
topic.id == "tasks.data-subject-requests"
|
||||
and {"admin", "user"}.issubset(topic.documentation_types)
|
||||
for topic in manifest.documentation
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,59 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
from govoplan_tasks.backend.manifest import get_manifest
|
||||
|
||||
|
||||
REPOSITORY_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
class TasksQuickAccessContractTests(unittest.TestCase):
|
||||
def test_public_topics_have_complete_german_workflow_and_reference_coverage(
|
||||
self,
|
||||
) -> None:
|
||||
topics = get_manifest().documentation
|
||||
kinds = {topic.metadata.get("kind", "system") for topic in topics}
|
||||
|
||||
self.assertEqual({
|
||||
"tasks.workspace-layout",
|
||||
"tasks.data-subject-requests",
|
||||
"tasks.quick-access-and-product-area",
|
||||
"tasks.work-inbox",
|
||||
}, {topic.id for topic in topics})
|
||||
self.assertTrue({"workflow", "reference"}.issubset(kinds))
|
||||
for topic in topics:
|
||||
translation = topic.translations["de"]
|
||||
self.assertEqual({"title", "summary", "body"}, set(translation))
|
||||
self.assertTrue(
|
||||
all(str(translation[field]).strip() for field in translation)
|
||||
)
|
||||
|
||||
def test_manifest_declares_typed_work_result_and_help(self) -> None:
|
||||
tool = get_manifest().frontend.quick_access_tools[0]
|
||||
|
||||
self.assertEqual("tasks.work", tool.id)
|
||||
self.assertEqual(("tasks.work-item",), tool.returned_reference_kinds)
|
||||
self.assertEqual("tasks.quick_access.work", tool.help_context_id)
|
||||
self.assertEqual("/tasks", tool.full_page_path)
|
||||
|
||||
def test_renderer_is_bounded_and_keeps_commands_source_owned(self) -> None:
|
||||
source = (
|
||||
REPOSITORY_ROOT
|
||||
/ "webui"
|
||||
/ "src"
|
||||
/ "features"
|
||||
/ "tasks"
|
||||
/ "TasksQuickAccess.tsx"
|
||||
).read_text()
|
||||
|
||||
self.assertIn("limit: 7", source)
|
||||
self.assertIn('selected.provider_id !== "tasks.explicit"', source)
|
||||
self.assertIn("transitionTask(settings, selected, action)", source)
|
||||
self.assertIn("quickAccessLaunchState(launchContext)", source)
|
||||
self.assertIn('kind: "work-item"', source)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@govoplan/tasks-webui",
|
||||
"version": "0.1.19",
|
||||
"version": "0.1.23",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
@@ -14,7 +14,7 @@
|
||||
"./styles/tasks.css": "./src/styles/tasks.css"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@govoplan/core-webui": "^0.1.18",
|
||||
"@govoplan/core-webui": "^0.1.45",
|
||||
"lucide-react": "^1.23.0",
|
||||
"react": ">=19.2.7 <20",
|
||||
"react-dom": ">=19.2.7 <20",
|
||||
|
||||
@@ -6,24 +6,27 @@ import {
|
||||
ExternalLink,
|
||||
ListChecks,
|
||||
Plus,
|
||||
RefreshCw,
|
||||
RotateCcw,
|
||||
Search,
|
||||
XCircle
|
||||
} from "lucide-react";
|
||||
import { Link } from "react-router";
|
||||
import {
|
||||
AdminIconButton,
|
||||
import { FormGrid,
|
||||
Button,
|
||||
DateTimeField,
|
||||
Dialog,
|
||||
DismissibleAlert,
|
||||
DocumentationHelpLink,
|
||||
FormField,
|
||||
FilterBar,
|
||||
SegmentedControl,
|
||||
SelectionList,
|
||||
SelectionListItem,
|
||||
StatePanel,
|
||||
StatusBadge,
|
||||
WorkspaceActionBar,
|
||||
WorkspaceFrame,
|
||||
WorkspaceLayout,
|
||||
hasScope,
|
||||
type ApiSettings,
|
||||
type AuthInfo
|
||||
@@ -120,30 +123,39 @@ export default function TasksPage({ settings, auth }: { settings: ApiSettings; a
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="tasks-page" data-help-context-id="tasks.page.inbox">
|
||||
<div className="tasks-shell">
|
||||
<aside className="tasks-sidebar">
|
||||
<div className="tasks-sidebar-bar">
|
||||
<span className="tasks-title"><ListChecks size={18} /><strong>i18n:govoplan-tasks.work</strong></span>
|
||||
<span className="tasks-toolbar-actions">
|
||||
<AdminIconButton
|
||||
label="i18n:govoplan-tasks.refresh"
|
||||
icon={<RefreshCw size={16} aria-hidden="true" />}
|
||||
onClick={() => void load()}
|
||||
disabled={loading || busy}
|
||||
/>
|
||||
{canWrite ? (
|
||||
<AdminIconButton
|
||||
label="i18n:govoplan-tasks.create_task"
|
||||
icon={<Plus size={16} aria-hidden="true" />}
|
||||
<WorkspaceFrame as="main" height="viewport" surface="plain" className="tasks-page" label="Task inbox" data-help-context-id="tasks.page.inbox">
|
||||
<WorkspaceActionBar
|
||||
scope="workspace"
|
||||
variant="collection"
|
||||
refreshable
|
||||
reloadAction={{ onReload: () => void load(), loading: loading || busy, label: "i18n:govoplan-tasks.refresh" }}
|
||||
contextActions={<span className="tasks-title"><ListChecks size={18} /><strong>i18n:govoplan-tasks.work</strong></span>}
|
||||
createAction={canWrite ? (
|
||||
<Button
|
||||
variant="primary"
|
||||
onClick={() => setCreateOpen(true)}
|
||||
disabled={busy}
|
||||
helpContextId="tasks.action.create"
|
||||
>
|
||||
<Plus size={16} aria-hidden="true" /> i18n:govoplan-tasks.create_task
|
||||
</Button>
|
||||
) : undefined}
|
||||
/>
|
||||
) : null}
|
||||
</span>
|
||||
</div>
|
||||
<form className="tasks-search" onSubmit={submitSearch} role="search">
|
||||
<WorkspaceLayout
|
||||
variant="split"
|
||||
primarySize="default"
|
||||
primaryScrollable={false}
|
||||
contentScrollable={false}
|
||||
surface="contained"
|
||||
primaryClassName="tasks-sidebar"
|
||||
contentClassName="tasks-workspace"
|
||||
primaryLabel="i18n:govoplan-tasks.work"
|
||||
contentLabel="i18n:govoplan-tasks.work_details"
|
||||
interfaceId="tasks.inbox.workspace"
|
||||
helpContextId="tasks.page.inbox"
|
||||
helpModuleId="tasks"
|
||||
primary={<>
|
||||
<FilterBar as="form" surface="control" wrap="never" className="tasks-search" onSubmit={submitSearch} role="search">
|
||||
<Search size={15} aria-hidden="true" />
|
||||
<input
|
||||
value={searchDraft}
|
||||
@@ -151,7 +163,7 @@ export default function TasksPage({ settings, auth }: { settings: ApiSettings; a
|
||||
placeholder="i18n:govoplan-tasks.search_placeholder"
|
||||
aria-label="i18n:govoplan-tasks.search"
|
||||
/>
|
||||
</form>
|
||||
</FilterBar>
|
||||
<SegmentedControl
|
||||
className="tasks-status-filter"
|
||||
options={[
|
||||
@@ -168,7 +180,7 @@ export default function TasksPage({ settings, auth }: { settings: ApiSettings; a
|
||||
{loading ? <p className="tasks-note">i18n:govoplan-tasks.loading</p> : null}
|
||||
{!loading && items.length === 0 ? <p className="tasks-note">i18n:govoplan-tasks.empty</p> : null}
|
||||
{items.length ? (
|
||||
<SelectionList label="i18n:govoplan-tasks.work_items">
|
||||
<SelectionList variant="navigation" label="i18n:govoplan-tasks.work_items">
|
||||
{items.map((item) => (
|
||||
<SelectionListItem
|
||||
key={`${item.provider_id}:${item.id}`}
|
||||
@@ -183,25 +195,31 @@ export default function TasksPage({ settings, auth }: { settings: ApiSettings; a
|
||||
</SelectionList>
|
||||
) : null}
|
||||
</div>
|
||||
</aside>
|
||||
</>}
|
||||
>
|
||||
|
||||
<section className="tasks-workspace" data-help-context-id="tasks.page.detail">
|
||||
<div className="tasks-topbar">
|
||||
<span className="tasks-detail-title"><ListChecks size={18} /><strong>{selected?.title ?? "i18n:govoplan-tasks.work_details"}</strong></span>
|
||||
<span className="tasks-toolbar-actions">
|
||||
<DocumentationHelpLink reference={DOCUMENTATION} />
|
||||
{selected?.provider_id === "tasks.explicit" && canWrite ? <TaskActions item={selected} busy={busy} onAction={(action) => action === "defer" ? setDeferOpen(true) : void runAction(action)} /> : null}
|
||||
</span>
|
||||
</div>
|
||||
<WorkspaceActionBar
|
||||
scope="detail-pane"
|
||||
variant="detail"
|
||||
className="tasks-topbar"
|
||||
data-help-context-id="tasks.page.detail"
|
||||
title={<span className="tasks-detail-title"><ListChecks size={18} aria-hidden="true" /><strong>{selected?.title ?? "i18n:govoplan-tasks.work_details"}</strong></span>}
|
||||
titleHelp={<DocumentationHelpLink reference={DOCUMENTATION} />}
|
||||
primaryActions={selected?.provider_id === "tasks.explicit" && canWrite ? (
|
||||
<TaskPrimaryActions item={selected} busy={busy} onAction={(action) => action === "defer" ? setDeferOpen(true) : void runAction(action)} />
|
||||
) : undefined}
|
||||
destructiveActions={selected?.provider_id === "tasks.explicit" && canWrite && !["completed", "cancelled"].includes(selected.status) ? (
|
||||
<Button variant="danger" onClick={() => void runAction("cancel")} disabled={busy}><XCircle size={15} /> i18n:govoplan-tasks.cancel_task</Button>
|
||||
) : undefined}
|
||||
/>
|
||||
|
||||
{error ? <DismissibleAlert tone="danger" compact resetKey={error}>{error}</DismissibleAlert> : null}
|
||||
{diagnostics.map((message) => <DismissibleAlert key={message} tone="warning" compact resetKey={message}>{message}</DismissibleAlert>)}
|
||||
|
||||
{selected ? <TaskDetails item={selected} /> : (
|
||||
<div className="tasks-empty-detail"><ListChecks size={24} /><h1>i18n:govoplan-tasks.work</h1><p>i18n:govoplan-tasks.select_help</p></div>
|
||||
<StatePanel size="fill" icon={<ListChecks size={24} />} title="i18n:govoplan-tasks.work" description="i18n:govoplan-tasks.select_help" />
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
</WorkspaceLayout>
|
||||
|
||||
<CreateTaskDialog
|
||||
open={createOpen}
|
||||
@@ -230,11 +248,11 @@ export default function TasksPage({ settings, auth }: { settings: ApiSettings; a
|
||||
<DateTimeField value={deferredUntil} onChange={setDeferredUntil} min={localDateTime(new Date())} />
|
||||
</FormField>
|
||||
</Dialog>
|
||||
</main>
|
||||
</WorkspaceFrame>
|
||||
);
|
||||
}
|
||||
|
||||
function TaskActions({ item, busy, onAction }: { item: WorkItem; busy: boolean; onAction: (action: "start" | "complete" | "defer" | "reopen" | "cancel") => void }) {
|
||||
function TaskPrimaryActions({ item, busy, onAction }: { item: WorkItem; busy: boolean; onAction: (action: "start" | "complete" | "defer" | "reopen") => void }) {
|
||||
if (["completed", "cancelled"].includes(item.status)) {
|
||||
return <Button onClick={() => onAction("reopen")} disabled={busy}><RotateCcw size={15} /> i18n:govoplan-tasks.reopen</Button>;
|
||||
}
|
||||
@@ -243,7 +261,6 @@ function TaskActions({ item, busy, onAction }: { item: WorkItem; busy: boolean;
|
||||
{["open", "deferred"].includes(item.status) ? <Button onClick={() => onAction("start")} disabled={busy}><CirclePlay size={15} /> i18n:govoplan-tasks.start</Button> : null}
|
||||
<Button variant="primary" onClick={() => onAction("complete")} disabled={busy}><Check size={15} /> i18n:govoplan-tasks.complete</Button>
|
||||
<Button onClick={() => onAction("defer")} disabled={busy}><CalendarClock size={15} /> i18n:govoplan-tasks.defer</Button>
|
||||
<Button variant="danger" onClick={() => onAction("cancel")} disabled={busy}><XCircle size={15} /> i18n:govoplan-tasks.cancel_task</Button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -323,10 +340,10 @@ function CreateTaskDialog({ open, busy, settings, auth, onClose, onCreated, onEr
|
||||
<form id="tasks-create-form" className="tasks-create-form" onSubmit={submit}>
|
||||
<FormField label="i18n:govoplan-tasks.title"><input value={title} onChange={(event) => setTitle(event.target.value)} maxLength={500} autoFocus required /></FormField>
|
||||
<FormField label="i18n:govoplan-tasks.summary"><textarea value={summary} onChange={(event) => setSummary(event.target.value)} maxLength={4000} rows={4} /></FormField>
|
||||
<div className="tasks-create-grid">
|
||||
<FormGrid columns={2} gap="small" collapseAt="workspace" className="tasks-create-grid">
|
||||
<FormField label="i18n:govoplan-tasks.priority" helpContextId="tasks.field.priority"><select value={priority} onChange={(event) => setPriority(event.target.value as WorkPriority)}><option value="low">i18n:govoplan-tasks.priority.low</option><option value="normal">i18n:govoplan-tasks.priority.normal</option><option value="high">i18n:govoplan-tasks.priority.high</option><option value="urgent">i18n:govoplan-tasks.priority.urgent</option></select></FormField>
|
||||
<FormField label="i18n:govoplan-tasks.due_at" helpContextId="tasks.field.due-at"><DateTimeField value={dueAt} onChange={setDueAt} min={localDateTime(new Date())} /></FormField>
|
||||
</div>
|
||||
</FormGrid>
|
||||
<FormField label="i18n:govoplan-tasks.required_action"><input value={requiredAction} onChange={(event) => setRequiredAction(event.target.value)} maxLength={500} /></FormField>
|
||||
<p className="tasks-assignment-note">i18n:govoplan-tasks.assigned_to_you</p>
|
||||
</form>
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
import { Check, CirclePlay, ExternalLink, ListChecks } from "lucide-react";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { Link } from "react-router";
|
||||
import {
|
||||
Button,
|
||||
DismissibleAlert,
|
||||
LoadingFrame,
|
||||
SelectionList,
|
||||
SelectionListItem,
|
||||
SelectionListItemContent,
|
||||
StatusBadge,
|
||||
hasScope,
|
||||
quickAccessLaunchState,
|
||||
useDashboardWidgetData,
|
||||
type QuickAccessToolRenderContext
|
||||
} from "@govoplan/core-webui";
|
||||
import {
|
||||
listWork,
|
||||
transitionTask,
|
||||
type WorkItem,
|
||||
type WorkStatus
|
||||
} from "../../api/tasks";
|
||||
|
||||
const ACTIVE_STATUSES: WorkStatus[] = [
|
||||
"open",
|
||||
"in_progress",
|
||||
"deferred",
|
||||
"blocked"
|
||||
];
|
||||
|
||||
type Props = Pick<
|
||||
QuickAccessToolRenderContext,
|
||||
"settings" | "auth" | "launchContext" | "complete"
|
||||
>;
|
||||
|
||||
/**
|
||||
* A bounded projection of the unified inbox. Every load and command goes back
|
||||
* through Tasks, so optional providers retain ownership of visibility and
|
||||
* completion semantics.
|
||||
*/
|
||||
export default function TasksQuickAccess({
|
||||
settings,
|
||||
auth,
|
||||
launchContext,
|
||||
complete
|
||||
}: Props) {
|
||||
const [refreshKey, setRefreshKey] = useState(0);
|
||||
const [selectedKey, setSelectedKey] = useState("");
|
||||
const [commandError, setCommandError] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const load = useCallback(
|
||||
() => listWork(settings, { statuses: ACTIVE_STATUSES, limit: 7 }),
|
||||
[settings]
|
||||
);
|
||||
const { data, loading, error } = useDashboardWidgetData(load, refreshKey);
|
||||
const items = data?.items ?? [];
|
||||
const selected = useMemo(
|
||||
() => items.find((item) => workKey(item) === selectedKey) ?? items[0] ?? null,
|
||||
[items, selectedKey]
|
||||
);
|
||||
const canWrite = hasScope(auth, "tasks:item:write");
|
||||
|
||||
useEffect(() => {
|
||||
if (!selectedKey && items[0]) setSelectedKey(workKey(items[0]));
|
||||
if (selectedKey && !items.some((item) => workKey(item) === selectedKey)) {
|
||||
setSelectedKey(items[0] ? workKey(items[0]) : "");
|
||||
}
|
||||
}, [items, selectedKey]);
|
||||
|
||||
async function runCommand(action: "start" | "complete") {
|
||||
if (!selected || selected.provider_id !== "tasks.explicit" || !canWrite) return;
|
||||
setBusy(true);
|
||||
setCommandError("");
|
||||
try {
|
||||
const updated = await transitionTask(settings, selected, action);
|
||||
if (action === "complete") {
|
||||
complete(workResult(updated, "completed"));
|
||||
return;
|
||||
}
|
||||
setRefreshKey((value) => value + 1);
|
||||
} catch (reason) {
|
||||
setCommandError(errorMessage(reason));
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
function selectForHost(item: WorkItem) {
|
||||
complete(workResult(item, "selected"));
|
||||
}
|
||||
|
||||
const actionPath = selected ? safeActionUrl(selected.action_url) : null;
|
||||
|
||||
return (
|
||||
<LoadingFrame loading={loading} label="i18n:govoplan-tasks.loading">
|
||||
{error ? <DismissibleAlert tone="warning" resetKey={error}>{error}</DismissibleAlert> : null}
|
||||
{commandError ? <DismissibleAlert tone="danger" resetKey={commandError}>{commandError}</DismissibleAlert> : null}
|
||||
{data?.diagnostics.map((diagnostic) => (
|
||||
<DismissibleAlert
|
||||
key={`${diagnostic.provider_id}:${diagnostic.code}`}
|
||||
tone="warning"
|
||||
resetKey={`${diagnostic.provider_id}:${diagnostic.code}:${diagnostic.message}`}
|
||||
>
|
||||
{diagnostic.message}
|
||||
</DismissibleAlert>
|
||||
))}
|
||||
|
||||
{items.length ? (
|
||||
<SelectionList variant="navigation" label="i18n:govoplan-tasks.work_items">
|
||||
{items.map((item) => (
|
||||
<SelectionListItem
|
||||
key={workKey(item)}
|
||||
selected={selected ? workKey(item) === workKey(selected) : false}
|
||||
onClick={() => setSelectedKey(workKey(item))}
|
||||
>
|
||||
<SelectionListItemContent
|
||||
leading={<ListChecks size={16} aria-hidden="true" />}
|
||||
title={item.title}
|
||||
description={item.required_action || item.summary || moduleLabel(item.owner_module)}
|
||||
/>
|
||||
<StatusBadge status={item.status} label={statusLabel(item.status)} />
|
||||
</SelectionListItem>
|
||||
))}
|
||||
</SelectionList>
|
||||
) : !loading && !error ? (
|
||||
<p className="muted">i18n:govoplan-tasks.empty</p>
|
||||
) : null}
|
||||
|
||||
{selected ? (
|
||||
<section className="tasks-quick-detail" aria-label="i18n:govoplan-tasks.work_details">
|
||||
<div className="tasks-quick-detail-heading">
|
||||
<strong>{selected.title}</strong>
|
||||
<span>{moduleLabel(selected.owner_module)} · {dueLabel(selected.due_at)}</span>
|
||||
</div>
|
||||
{selected.summary ? <p>{selected.summary}</p> : null}
|
||||
{selected.required_action ? (
|
||||
<p><strong>i18n:govoplan-tasks.required_action:</strong> {selected.required_action}</p>
|
||||
) : null}
|
||||
<div className="button-row compact-actions">
|
||||
{selected.provider_id === "tasks.explicit" && canWrite && ["open", "deferred"].includes(selected.status) ? (
|
||||
<Button onClick={() => void runCommand("start")} disabled={busy}>
|
||||
<CirclePlay size={15} aria-hidden="true" /> i18n:govoplan-tasks.start
|
||||
</Button>
|
||||
) : null}
|
||||
{selected.provider_id === "tasks.explicit" && canWrite ? (
|
||||
<Button variant="primary" onClick={() => void runCommand("complete")} disabled={busy}>
|
||||
<Check size={15} aria-hidden="true" /> i18n:govoplan-tasks.complete
|
||||
</Button>
|
||||
) : null}
|
||||
{actionPath ? (
|
||||
<Link
|
||||
className="btn btn-secondary"
|
||||
to={actionPath}
|
||||
state={quickAccessLaunchState(launchContext)}
|
||||
onClick={() => selectForHost(selected)}
|
||||
>
|
||||
<ExternalLink size={15} aria-hidden="true" /> i18n:govoplan-tasks.open_work
|
||||
</Link>
|
||||
) : (
|
||||
<Button onClick={() => selectForHost(selected)}>
|
||||
i18n:govoplan-tasks.select_help
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
) : null}
|
||||
|
||||
{data && data.total > items.length ? (
|
||||
<p className="muted small-note">
|
||||
{items.length} / {data.total} · i18n:govoplan-tasks.open_work_inbox
|
||||
</p>
|
||||
) : null}
|
||||
</LoadingFrame>
|
||||
);
|
||||
}
|
||||
|
||||
function workResult(item: WorkItem, action: "selected" | "completed") {
|
||||
return {
|
||||
contractVersion: "1" as const,
|
||||
outcome: "completed" as const,
|
||||
action,
|
||||
reference: {
|
||||
ownerModule: "tasks",
|
||||
kind: "work-item",
|
||||
objectId: `${item.provider_id}:${item.id}`,
|
||||
tenantId: item.tenant_id,
|
||||
label: item.title,
|
||||
version: item.revision,
|
||||
path: safeActionUrl(item.action_url) || "/tasks"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function workKey(item: WorkItem): string {
|
||||
return `${item.provider_id}:${item.id}`;
|
||||
}
|
||||
|
||||
function safeActionUrl(value?: string | null): string | null {
|
||||
if (!value || !value.startsWith("/") || value.startsWith("//") || value.includes("\\")) return null;
|
||||
return value;
|
||||
}
|
||||
|
||||
function statusLabel(value: string): string {
|
||||
return `i18n:govoplan-tasks.status.${value}`;
|
||||
}
|
||||
|
||||
function moduleLabel(value: string): string {
|
||||
return value.replaceAll("_", " ").replace(/\b\w/g, (letter) => letter.toUpperCase());
|
||||
}
|
||||
|
||||
function dueLabel(value?: string | null): string {
|
||||
if (!value) return "i18n:govoplan-tasks.no_due_date";
|
||||
const parsed = new Date(value);
|
||||
if (Number.isNaN(parsed.getTime())) return value;
|
||||
return new Intl.DateTimeFormat(undefined, { dateStyle: "medium", timeStyle: "short" }).format(parsed);
|
||||
}
|
||||
|
||||
function errorMessage(reason: unknown): string {
|
||||
return reason instanceof Error ? reason.message : "i18n:govoplan-tasks.request_failed";
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { MetricGrid } from "@govoplan/core-webui";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Link } from "react-router";
|
||||
import {
|
||||
@@ -35,11 +36,11 @@ export default function TasksSummaryWidget({ settings, refreshKey }: { settings:
|
||||
return (
|
||||
<LoadingFrame loading={loading} label="i18n:govoplan-tasks.loading_summary">
|
||||
{error ? <DismissibleAlert tone="warning" resetKey={error}>{error}</DismissibleAlert> : null}
|
||||
<div className="metric-grid inside dashboard-widget-metrics">
|
||||
<MetricGrid columns={3} spacing="none">
|
||||
<MetricCard label="i18n:govoplan-tasks.open" value={(summary?.open ?? 0) + (summary?.in_progress ?? 0)} tone="info" detail="i18n:govoplan-tasks.actionable_work" />
|
||||
<MetricCard label="i18n:govoplan-tasks.overdue" value={summary?.overdue ?? 0} tone={summary?.overdue ? "danger" : "good"} detail="i18n:govoplan-tasks.due_date_passed" />
|
||||
<MetricCard label="i18n:govoplan-tasks.blocked" value={summary?.blocked ?? 0} tone={summary?.blocked ? "warning" : "good"} detail="i18n:govoplan-tasks.needs_resolution" />
|
||||
</div>
|
||||
</MetricGrid>
|
||||
<div className="tasks-widget-actions"><Link className="btn btn-secondary" to="/tasks">i18n:govoplan-tasks.open_work_inbox</Link></div>
|
||||
</LoadingFrame>
|
||||
);
|
||||
|
||||
+9
-6
@@ -4,12 +4,18 @@ import type {
|
||||
PlatformWebModule,
|
||||
QuickAccessToolsUiCapability
|
||||
} from "@govoplan/core-webui";
|
||||
import { generatedTranslations as productSurfaceTranslations } from "@govoplan/core-webui/outcome-product-surface-translations";
|
||||
import TasksSummaryWidget from "./features/tasks/TasksSummaryWidget";
|
||||
import TasksQuickAccess from "./features/tasks/TasksQuickAccess";
|
||||
import { generatedTranslations } from "./i18n/generatedTranslations";
|
||||
import "./styles/tasks.css";
|
||||
|
||||
const TasksPage = lazy(() => import("./features/tasks/TasksPage"));
|
||||
const readScope = ["tasks:item:read"];
|
||||
const translations = {
|
||||
en: { ...generatedTranslations.en, ...productSurfaceTranslations.en },
|
||||
de: { ...generatedTranslations.de, ...productSurfaceTranslations.de }
|
||||
};
|
||||
|
||||
const dashboardWidgets: DashboardWidgetsUiCapability = {
|
||||
widgets: [
|
||||
@@ -35,10 +41,7 @@ const quickAccessTools: QuickAccessToolsUiCapability = {
|
||||
tools: [
|
||||
{
|
||||
id: "tasks.work",
|
||||
render: ({ settings }) => createElement(TasksSummaryWidget, {
|
||||
settings,
|
||||
refreshKey: 0
|
||||
})
|
||||
render: (context) => createElement(TasksQuickAccess, context)
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -46,10 +49,10 @@ const quickAccessTools: QuickAccessToolsUiCapability = {
|
||||
export const tasksModule: PlatformWebModule = {
|
||||
id: "tasks",
|
||||
label: "i18n:govoplan-tasks.work",
|
||||
version: "0.1.19",
|
||||
version: "0.1.22",
|
||||
dependencies: ["access"],
|
||||
optionalDependencies: ["idm", "organizations", "workflow_engine", "workflow", "notifications", "postbox", "approvals", "views", "dashboard", "search"],
|
||||
translations: generatedTranslations,
|
||||
translations,
|
||||
navItems: [
|
||||
{
|
||||
to: "/tasks",
|
||||
|
||||
+24
-90
@@ -1,28 +1,3 @@
|
||||
.tasks-page {
|
||||
box-sizing: border-box;
|
||||
height: calc(100vh - 115px);
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
color: var(--text);
|
||||
background: var(--bg);
|
||||
}
|
||||
|
||||
.tasks-page *,
|
||||
.tasks-page *::before,
|
||||
.tasks-page *::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.tasks-shell {
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(285px, 350px) minmax(0, 1fr);
|
||||
border: var(--border-line);
|
||||
background: var(--panel);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.tasks-sidebar,
|
||||
.tasks-workspace {
|
||||
min-width: 0;
|
||||
@@ -32,13 +7,6 @@
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.tasks-sidebar {
|
||||
border-right: var(--border-line);
|
||||
background: var(--panel-soft);
|
||||
}
|
||||
|
||||
.tasks-sidebar-bar,
|
||||
.tasks-topbar,
|
||||
.tasks-title,
|
||||
.tasks-detail-title,
|
||||
.tasks-toolbar-actions,
|
||||
@@ -51,15 +19,6 @@
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.tasks-sidebar-bar,
|
||||
.tasks-topbar {
|
||||
min-height: 54px;
|
||||
justify-content: space-between;
|
||||
border-bottom: var(--border-line);
|
||||
background: var(--panel-header);
|
||||
padding: 9px 12px;
|
||||
}
|
||||
|
||||
.tasks-detail-title {
|
||||
min-width: 0;
|
||||
}
|
||||
@@ -82,19 +41,7 @@
|
||||
}
|
||||
|
||||
.tasks-search {
|
||||
height: 36px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
border: var(--border-line);
|
||||
border-radius: 5px;
|
||||
background: var(--surface);
|
||||
margin: 8px 8px 0;
|
||||
padding: 0 9px;
|
||||
}
|
||||
|
||||
.tasks-search:focus-within {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.tasks-search input {
|
||||
@@ -168,7 +115,7 @@
|
||||
}
|
||||
|
||||
.tasks-detail-main > p {
|
||||
max-width: 850px;
|
||||
max-width: 900px;
|
||||
line-height: 1.55;
|
||||
white-space: pre-line;
|
||||
}
|
||||
@@ -179,7 +126,7 @@
|
||||
}
|
||||
|
||||
.tasks-required-action {
|
||||
max-width: 850px;
|
||||
max-width: 900px;
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
border-left: 3px solid var(--accent);
|
||||
@@ -232,22 +179,6 @@
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.tasks-empty-detail {
|
||||
min-height: 100%;
|
||||
display: grid;
|
||||
place-content: center;
|
||||
justify-items: center;
|
||||
color: var(--muted);
|
||||
text-align: center;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.tasks-empty-detail h1 {
|
||||
margin: 10px 0 0;
|
||||
color: var(--text-strong);
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.tasks-create-form {
|
||||
width: min(620px, 75vw);
|
||||
display: grid;
|
||||
@@ -259,9 +190,7 @@
|
||||
}
|
||||
|
||||
.tasks-create-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(150px, .75fr) minmax(260px, 1.25fr);
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.tasks-assignment-note {
|
||||
@@ -276,32 +205,37 @@
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
@media (max-width: 820px) {
|
||||
.tasks-shell {
|
||||
grid-template-columns: minmax(230px, 42%) minmax(0, 1fr);
|
||||
}
|
||||
.tasks-quick-detail {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
margin-top: 12px;
|
||||
border-top: var(--border-line);
|
||||
padding-top: 12px;
|
||||
}
|
||||
|
||||
.tasks-quick-detail-heading {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.tasks-quick-detail-heading span,
|
||||
.tasks-quick-detail > p {
|
||||
margin: 0;
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.tasks-topbar {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.tasks-properties dl,
|
||||
.tasks-create-grid {
|
||||
.tasks-properties dl {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 620px) {
|
||||
.tasks-shell {
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-rows: minmax(250px, 44%) minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.tasks-sidebar {
|
||||
border-right: 0;
|
||||
border-bottom: var(--border-line);
|
||||
}
|
||||
|
||||
@media (max-width: 680px) {
|
||||
.tasks-create-form {
|
||||
width: min(100%, 88vw);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user