protonsystems / pm-tasks
Drupal 11 module with a widget that reports bugs and pending items to each user's project management system through pluggable providers (SD App first).
Package info
gitlab.com/Proton.Systems/drupal/pm-tasks
Type:drupal-module
pkg:composer/protonsystems/pm-tasks
Requires
- php: ^8.3
- drupal/core: ^11.3
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Reusable Drupal 11 module with a floating widget that lets editors and developers report a bug or a pending item from any page, straight into the project management (PM) system each user works with. SD App is the first supported system; others are added as provider plugins.
Purpose
Reporting a problem should take seconds and not lose the context: the widget sends the page address and title, the browser and the screen size with what the user typed. Each user decides where their reports go, with their own credentials, so a team can share one site while every person reports to their own PM system.
Requirements
- Drupal 11.3+
- PHP 8.3+
Features
- Floating report button (bottom-left by default) on every page for users with the
report pm taskspermission; optional on administration pages - Native
<dialog>form: type (bug or pending item), title and description; the page URL, page title, viewport, browser, site, language and reporter are added automatically - Per-user setup on the account's PM tasks tab (
/user/{uid}/pm-tasks): choose a provider and enter its settings; secrets never render back into the form - Settings stored in core's
user.data, not configuration or fields: tokens stay out of config exports, Views and REST, and core removes them when the user is deleted - Provider plugins (
#[PmTaskProvider]attribute) so other PM systems can be added by any module; see docs/adding-a-provider.md - Shipped providers: SD App (REST API
/api/v1/tasks, personal access token, optional project and tags) and Site log (writes to thepm_taskslog channel; for trying the widget) - Site settings at
/admin/config/development/pm-tasks: which providers users may choose, widget on/off, admin pages, corner - Theming through
--pm-tasks-*CSS custom properties and an overridablepm-tasks-widget.html.twig - CSRF-protected JSON endpoint and a limit of 30 reports per user per hour
Structure
src/PmTaskProviderInterface.php,src/PmTaskProviderBase.php,src/PmTaskProviderManager.php,src/Attribute/define the provider plugin type.src/Plugin/PmTaskProvider/contains the SD App and Site log providers.src/TaskReport.phpandsrc/ReportResult.phpare the value objects passed to and returned by providers.src/UserSettings.phpstores each user's provider choice and configuration;src/TaskReporter.phpsends a report to the user's provider.src/Controller/ReportController.phpis the endpoint the widget posts to;src/WidgetBuilder.phprenders the widget per user.src/Form/contains the site settings form and the user's PM tasks tab.src/Hook/contains the OOP hook implementations (theme, page bottom).templates/,css/andjs/contain the widget.docs/module-architecture.mddocuments how the module is built.
Installation
composer require protonsystems/pm-tasks
drush en pm_tasks
- Grant Report tasks with the widget (
report pm tasks) to the roles that should see the widget. - Optionally adjust
/admin/config/development/pm-tasks(permissionadminister pm tasks) anddrush cex. - Each user opens their account's PM tasks tab, picks a PM system and saves its settings. Until they do, the widget links to that tab.
SD App
Each user needs an SD App personal access token (sdt_...). An SD App administrator creates one with:
php bin/console app:api-token create user@example.com --name=drupal
On the PM tasks tab, choose SD App and enter the token, the API URL (default https://app.seriousdesign.net/api/v1), the project ID new tasks go to (empty for personal tasks) and extra tags. Each task gets the tags plus bug or task, the page URL as a link, and a description with the page context.
Theming
Override the custom properties on .pm-tasks, for example in the theme's CSS:
.pm-tasks {
--pm-tasks-accent: var(--color-primary);
--pm-tasks-radius: 0;
--pm-tasks-font: var(--font-body);
}
Available properties: --pm-tasks-accent, --pm-tasks-accent-text, --pm-tasks-bg, --pm-tasks-text, --pm-tasks-muted, --pm-tasks-border, --pm-tasks-error, --pm-tasks-success, --pm-tasks-radius, --pm-tasks-font, --pm-tasks-font-size, --pm-tasks-offset, --pm-tasks-z. The widget keeps clear of toolbars that use Drupal.displace() (such as the admin navigation). For markup changes, copy templates/pm-tasks-widget.html.twig into the theme and keep its data-pm-tasks-* attributes.
Testing
Unit and kernel tests run from a Drupal site that has the module installed:
vendor/bin/phpunit -c web/core web/modules/contrib/pm-tasks/tests
Kernel tests need SIMPLETEST_DB, for example sqlite://localhost//tmp/pm_tasks.sqlite.