Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b2b1e7d
changelog deleted
Sep 6, 2022
1ee76d4
changelog added
Sep 6, 2022
671fc10
changelog added
Sep 6, 2022
0bf3ba0
changelog added
Sep 6, 2022
5c40a15
changelog added
Sep 6, 2022
8075912
Fix styling
emreakay Sep 6, 2022
67cc68f
contracts and exceptions created
Sep 6, 2022
dab5c82
Merge remote-tracking branch 'origin/development' into development
Sep 6, 2022
d90cc1f
Fix styling
emreakay Sep 6, 2022
5cc2199
test
nusinan Sep 6, 2022
a8274ba
contracts and exceptions created
Sep 6, 2022
514493d
Merge remote-tracking branch 'origin/development' into development
Sep 6, 2022
74507ae
Merge remote-tracking branch 'origin/development' into development
nusinan Sep 7, 2022
15628e7
test
nusinan Sep 7, 2022
5f32bc6
- tests created
Sep 7, 2022
6119021
- tests created
Sep 7, 2022
c16b669
Fix styling
emreakay Sep 7, 2022
b4b41f8
- AIssue class
Sep 7, 2022
484afd0
Merge remote-tracking branch 'origin/development' into development
Sep 7, 2022
fb71329
Fix styling
emreakay Sep 7, 2022
bac4df6
Aissue create test
nusinan Sep 8, 2022
c49b2a4
Fix styling
nusinan Sep 8, 2022
2de89a6
Aissue create test
nusinan Sep 8, 2022
cb3f057
Aissue can transition test
nusinan Sep 8, 2022
10b26b4
Fix styling
nusinan Sep 8, 2022
2b7dfe7
test
nusinan Sep 8, 2022
0f6b304
Fix styling
nusinan Sep 8, 2022
0b50286
test
nusinan Sep 9, 2022
832f645
Fix styling
nusinan Sep 9, 2022
524c4a7
- traits created
Sep 13, 2022
b28ce91
Fix styling
emreakay Sep 13, 2022
6050d6e
- traits fixed
Sep 14, 2022
f6381db
Merge remote-tracking branch 'origin/development' into development
Sep 14, 2022
92b2638
Fix styling
emreakay Sep 14, 2022
767db11
- traits fixed
Sep 14, 2022
c5835e5
- traits fixed
Sep 14, 2022
f622bfa
Merge remote-tracking branch 'origin/development' into development
Sep 14, 2022
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
28 changes: 28 additions & 0 deletions .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Update Changelog"

on:
release:
types: [released]

jobs:
update:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: main

- name: Update Changelog
uses: stefanzweifel/changelog-updater-action@v1
with:
latest-version: ${{ github.event.release.name }}
release-notes: ${{ github.event.release.body }}

- name: Commit updated CHANGELOG
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: main
commit_message: Update CHANGELOG
file_pattern: CHANGELOG.md
9 changes: 9 additions & 0 deletions README-contr.md
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
todo



```shell
composer analyse
composer test
composer test-coverage
composer format
```
7 changes: 7 additions & 0 deletions README-todo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- contract
- service
- trait
- config dosyası, status'ler, permissionlar, permiissoon policychecker
- publishler
- yetki konteolleri
- board
10 changes: 9 additions & 1 deletion config/aissue.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<?php

// config for AuroraWebSoftware/AIssue
return [

return [
'policyMethod' => fn ($permission): bool => true,
'issueTypes' => [
'task' => [
'todo' => ['sort' => 1, 'permission' => 'todo_perm'],
'in_progress' => ['sort' => 2, 'permission' => 'in_progress_perm'],
'done' => ['sort' => 3, 'permission' => 'done_perm'],
],
],
];
37 changes: 13 additions & 24 deletions database/migrations/create_aissue_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,29 @@

return new class extends Migration
{
public function up()
public function up(): void
{
Schema::create('aissue_issues', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('code')->nullable();
$table->string('model_type');
$table->bigIncrements('model_id');
$table->bigIncrements('assignee_id');
$table->bigIncrements('creater_id');
$table->bigIncrements('issue_type_id');
$table->bigInteger('model_id');
$table->bigInteger('assignee_id');
$table->bigInteger('creater_id');
$table->string('issue_type');
$table->string('summary');
$table->string('description');
$table->bigIncrements('priority');
$table->string('description')->nullable();
$table->bigInteger('priority')->default(1);
$table->string('status');
$table->dateTime('duedate');
$table->boolean('archived');
$table->bigIncrements('archived_by');
$table->dateTime('archived_at');
$table->dateTime('duedate')->nullable();
$table->boolean('archived')->default(false);
$table->bigInteger('archived_by')->nullable();
$table->dateTime('archived_at')->nullable();
$table->timestamps();
});

Schema::create('aissue_issue_types', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('workflow');
$table->string('name');
$table->string('description');
$table->timestamps();
});

}

public function down(){
public function down(): void
{
Schema::dropIfExists('aissue_issues');
Schema::dropIfExists('aissue_issue_types');
}

};
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
ports:
- "33062:3306"
volumes:
- ~/apps/mariadb-aissue:/var/lib/mysql
- ~/apps/mariadb-aissue2:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=aissue
- MYSQL_PASSWORD=aissue
Expand All @@ -17,4 +17,4 @@ networks:
driver: bridge
ipam:
config:
- subnet: 172.16.57.0/24
- subnet: 172.16.54.0/24
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ includes:
- phpstan-baseline.neon

parameters:
level: 4
level: 8
paths:
- src
- config
Expand Down
58 changes: 58 additions & 0 deletions src/AIssue.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,64 @@

namespace AuroraWebSoftware\AIssue;

use AuroraWebSoftware\AIssue\Exceptions\TransitionPermissionException;

class AIssue
{
/**
* @param array $data
* @return Models\AIssue
*/
public function createIssue(array $data): Models\AIssue
{
return Models\AIssue::create($data);
}

/**
* @param Models\AIssue $issue
* @param string $status
* @return bool
*/
public function canMakeTransition(Models\AIssue $issue, string $status): bool
{
$permission = config('aissue')['issueTypes'][$issue->getIssueType()][$status]['permission'];
if (config('aissue')['policyMethod']($permission)) {
return true;
}

return false;
}

/**
* @param Models\AIssue $issue
* @param string $status
* @return Models\AIssue
*
* @throws TransitionPermissionException
*/
public function makeTransition(Models\AIssue $issue, string $status): Models\AIssue
{
if ($this->canMakeTransition($issue, $status)) {
$issue->status = $status;
$issue->save();
}

throw new TransitionPermissionException();
}

/**
* @param Models\AIssue $issue
* @return array<string>
*/
public function getTransitionableStatuses(Models\AIssue $issue): array
{
$statuses = [];
foreach (config('aissue')['issueTypes'][$issue->getIssueType()] as $index => $item) {
if ($this->canMakeTransition($issue, $index)) {
$statuses[] = $index;
}
}

return $statuses;
}
}
8 changes: 5 additions & 3 deletions src/AIssueServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ public function configurePackage(Package $package): void
// ->hasCommand(AIssueCommand::class);
}

public function boot()
public function boot(): void
{
parent::boot();

// load packages migrations
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');

$this->publishes([
__DIR__.'/../config' => config_path(),
], 'aissue-config');
}
}
25 changes: 25 additions & 0 deletions src/Contracts/AIssueModelContract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace AuroraWebSoftware\AIssue\Contracts;

/**
* AIssueModelContract
*/
interface AIssueModelContract
{
/**
* @param string $issueType
* @return string
*/
public static function getAIssueDefaultStatus(string $issueType): string;

/**
* @return string
*/
public static function getAIssueModelType(): string;

/**
* @return int
*/
public function getAIssueModelId(): int;
}
9 changes: 9 additions & 0 deletions src/Exceptions/TransitionPermissionException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace AuroraWebSoftware\AIssue\Exceptions;

use Illuminate\Auth\AuthenticationException;

class TransitionPermissionException extends AuthenticationException
{
}
9 changes: 9 additions & 0 deletions src/Exceptions/TransitionStatusNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace AuroraWebSoftware\AIssue\Exceptions;

use Illuminate\Auth\AuthenticationException;

class TransitionStatusNotFoundException extends AuthenticationException
{
}
5 changes: 5 additions & 0 deletions src/Facades/AIssue.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

/**
* @see \AuroraWebSoftware\AIssue\AIssue
*
* @method static createIssue($data): \AuroraWebSoftware\AIssue\Models\AIssue
* @method static canMakeTransition(\AuroraWebSoftware\AIssue\Models\AIssue $issue, $status): bool
* @method static makeTransition(\AuroraWebSoftware\AIssue\Models\AIssue $issue, $status): \AuroraWebSoftware\AIssue\Models\AIssue
* @method static getTransitionableStatuses(\AuroraWebSoftware\AIssue\Models\AIssue $issue)
*/
class AIssue extends Facade
{
Expand Down
54 changes: 54 additions & 0 deletions src/Models/AIssue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace AuroraWebSoftware\AIssue\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

/**
* @property string $status
* @property-read string $issue_type
*/
class AIssue extends Model
{
use HasFactory;

public $guarded = [];

protected $table = 'aissue_issues';

/**
* @return string
*/
public function getIssueType(): string
{
return $this->issue_type;
}

/**
* @param string $status
* @return bool
*/
public function canMakeTransition(string $status): bool
{
return \AuroraWebSoftware\AIssue\Facades\AIssue::canMakeTransition($this, $status);
}

/**
* @param string $status
* @return AIssue
*/
public function makeTransition(string $status): AIssue
{
return \AuroraWebSoftware\AIssue\Facades\AIssue::makeTransition($this, $status);
}

/**
* @param AIssue $issue
* @return array
*/
public function getTransitionableStatuses(AIssue $issue): array
{
return \AuroraWebSoftware\AIssue\Facades\AIssue::getTransitionableStatuses($this);
}
}
47 changes: 47 additions & 0 deletions src/Traits/AIssueModelTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace AuroraWebSoftware\AIssue\Traits;

use AuroraWebSoftware\AIssue\Facades\AIssue;
use Illuminate\Support\Carbon;

trait AIssueModelTrait
{
/**
* @param int $assigneeId
* @param int $createrId
* @param string $issueType
* @param string $summary
* @param string $description
* @param int $priority
* @param Carbon $duedate
* @return \AuroraWebSoftware\AIssue\Models\AIssue
*/
public function createIssue(
int $assigneeId,
int $createrId,
string $issueType,
string $summary,
string $description,
int $priority,
Carbon $duedate,
): \AuroraWebSoftware\AIssue\Models\AIssue {
// todo issueType Kontrolü
// todo status yetki kontrolü

$data = [
'model_type' => static::getAIssueModelType(),
'model_id' => $this->getAIssueModelId(),
'assignee_id' => $assigneeId,
'creater_id' => $createrId,
'issue_type' => $issueType,
'summary' => $summary,
'description' => $description,
'priority' => $priority,
'status' => static::getAIssueDefaultStatus($issueType),
'duedate' => $duedate,
];

return AIssue::createIssue($data);
}
}
Loading