Skip to content

FoskyM/flarum-issue-tracking

Repository files navigation

Issue Tracking

License Latest Stable Version Total Downloads

A Flarum extension. Issue tracking in Flarum.

QQ_1721889365017

Installation

Install with composer:

composer require foskym/flarum-issue-tracking:"*"

Updating

composer update foskym/flarum-issue-tracking:"*"
php flarum migrate
php flarum cache:clear

Links

How To Use?

Install this, and then install the platform provider.

Available Platform Provider

Enable them and set the configs.

How to make an provider?

Require this package in your provider's composer.json

"require": {
    "flarum/core": "^1.8.0",
    "foskym/flarum-issue-tracking": "*"
}

Extend.php

use Flarum\Extend;

return [
    new Extend\Locales(__DIR__.'/locale'),

    (new \FoskyM\IssueTracking\Extend\PlatformProvider())
        ->provide(PlatformProvider::class)
];

Config in PlatformProvider.php

// ...
use FoskyM\IssueTracking\AbstractPlatformProvider;
use FoskyM\IssueTracking\AbstractIssue;
use FoskyM\IssueTracking\AbstractProgress;
// ...

class PlatformProvider extends AbstractPlatformProvider
{
    public $key = "foskym-issue-tracking-youtrack";
    public $name = "YouTrack";

    public function availableSettings(): array
    {
        return [
            'url' => 'required|url',
            'token' => 'required',
            'project' => 'required',
            'state_field' => 'required',
            'resolved_state' => 'required',
        ];
    }
    // ...
}

Locale

foskym-issue-tracking-youtrack:
  admin:
    fields:
      heading: "Issue Tracking: YouTrack"
      url_label: "YouTrack URL"
      token_label: "YouTrack Token"
      project_label: "YouTrack Project ID"
      state_field_label: "State Field"
      resolved_state_label: "Resolved State"
      # {$setting_key}_label: ...

      url_help: ...
      token_help: ...
      project_help: ...
      state_field_help: ...
      resolved_state_help: ...

      # {$setting_key}_help: ...
      # help text can be ignored

Implementation

See AbstractPlatformProvider.php

And see YouTrack's PlatformProvider.php

Events for Forum Quests and other extensions

Dispatch when user created an issue in Flarum

class IssueCreated
{
    /**
     * @var User
     */
    public $actor;

    /**
     * @var \FoskyM\IssueTracking\Model\Issue
     */
    public $issue;

    /**
     * @var Discussion
     */
    public $discussion;
}

Dispatch when user created an comment on issue in Flarum

class CommentPosted
{
    /**
     * @var User
     */
    public $actor;

    /**
     * @var CommentPost
     */
    public $post;

    /**
     * @var string
     */
    public $issueId;
}