Skip to content

Commit 824a298

Browse files
authored
Merge pull request #4 from AuroraWebSoftware/development
Development
2 parents f6df3ae + f622bfa commit 824a298

18 files changed

+410
-35
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "Update Changelog"
2+
3+
on:
4+
release:
5+
types: [released]
6+
7+
jobs:
8+
update:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v3
14+
with:
15+
ref: main
16+
17+
- name: Update Changelog
18+
uses: stefanzweifel/changelog-updater-action@v1
19+
with:
20+
latest-version: ${{ github.event.release.name }}
21+
release-notes: ${{ github.event.release.body }}
22+
23+
- name: Commit updated CHANGELOG
24+
uses: stefanzweifel/git-auto-commit-action@v4
25+
with:
26+
branch: main
27+
commit_message: Update CHANGELOG
28+
file_pattern: CHANGELOG.md

README-contr.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
11
todo
2+
3+
4+
5+
```shell
6+
composer analyse
7+
composer test
8+
composer test-coverage
9+
composer format
10+
```

README-todo.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
- contract
2+
- service
3+
- trait
4+
- config dosyası, status'ler, permissionlar, permiissoon policychecker
5+
- publishler
6+
- yetki konteolleri
7+
- board

config/aissue.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<?php
22

33
// config for AuroraWebSoftware/AIssue
4-
return [
54

5+
return [
6+
'policyMethod' => fn ($permission): bool => true,
7+
'issueTypes' => [
8+
'task' => [
9+
'todo' => ['sort' => 1, 'permission' => 'todo_perm'],
10+
'in_progress' => ['sort' => 2, 'permission' => 'in_progress_perm'],
11+
'done' => ['sort' => 3, 'permission' => 'done_perm'],
12+
],
13+
],
614
];

database/migrations/create_aissue_tables.php

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,29 @@
66

77
return new class extends Migration
88
{
9-
public function up()
9+
public function up(): void
1010
{
1111
Schema::create('aissue_issues', function (Blueprint $table) {
1212
$table->bigIncrements('id');
13-
$table->string('code')->nullable();
1413
$table->string('model_type');
15-
$table->bigIncrements('model_id');
16-
$table->bigIncrements('assignee_id');
17-
$table->bigIncrements('creater_id');
18-
$table->bigIncrements('issue_type_id');
14+
$table->bigInteger('model_id');
15+
$table->bigInteger('assignee_id');
16+
$table->bigInteger('creater_id');
17+
$table->string('issue_type');
1918
$table->string('summary');
20-
$table->string('description');
21-
$table->bigIncrements('priority');
19+
$table->string('description')->nullable();
20+
$table->bigInteger('priority')->default(1);
2221
$table->string('status');
23-
$table->dateTime('duedate');
24-
$table->boolean('archived');
25-
$table->bigIncrements('archived_by');
26-
$table->dateTime('archived_at');
22+
$table->dateTime('duedate')->nullable();
23+
$table->boolean('archived')->default(false);
24+
$table->bigInteger('archived_by')->nullable();
25+
$table->dateTime('archived_at')->nullable();
2726
$table->timestamps();
2827
});
29-
30-
Schema::create('aissue_issue_types', function (Blueprint $table) {
31-
$table->bigIncrements('id');
32-
$table->string('workflow');
33-
$table->string('name');
34-
$table->string('description');
35-
$table->timestamps();
36-
});
37-
3828
}
3929

40-
public function down(){
30+
public function down(): void
31+
{
4132
Schema::dropIfExists('aissue_issues');
42-
Schema::dropIfExists('aissue_issue_types');
4333
}
44-
4534
};

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
ports:
77
- "33062:3306"
88
volumes:
9-
- ~/apps/mariadb-aissue:/var/lib/mysql
9+
- ~/apps/mariadb-aissue2:/var/lib/mysql
1010
environment:
1111
- MYSQL_ROOT_PASSWORD=aissue
1212
- MYSQL_PASSWORD=aissue
@@ -17,4 +17,4 @@ networks:
1717
driver: bridge
1818
ipam:
1919
config:
20-
- subnet: 172.16.57.0/24
20+
- subnet: 172.16.54.0/24

phpstan.neon.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ includes:
22
- phpstan-baseline.neon
33

44
parameters:
5-
level: 4
5+
level: 8
66
paths:
77
- src
88
- config

src/AIssue.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,64 @@
22

33
namespace AuroraWebSoftware\AIssue;
44

5+
use AuroraWebSoftware\AIssue\Exceptions\TransitionPermissionException;
6+
57
class AIssue
68
{
9+
/**
10+
* @param array $data
11+
* @return Models\AIssue
12+
*/
13+
public function createIssue(array $data): Models\AIssue
14+
{
15+
return Models\AIssue::create($data);
16+
}
17+
18+
/**
19+
* @param Models\AIssue $issue
20+
* @param string $status
21+
* @return bool
22+
*/
23+
public function canMakeTransition(Models\AIssue $issue, string $status): bool
24+
{
25+
$permission = config('aissue')['issueTypes'][$issue->getIssueType()][$status]['permission'];
26+
if (config('aissue')['policyMethod']($permission)) {
27+
return true;
28+
}
29+
30+
return false;
31+
}
32+
33+
/**
34+
* @param Models\AIssue $issue
35+
* @param string $status
36+
* @return Models\AIssue
37+
*
38+
* @throws TransitionPermissionException
39+
*/
40+
public function makeTransition(Models\AIssue $issue, string $status): Models\AIssue
41+
{
42+
if ($this->canMakeTransition($issue, $status)) {
43+
$issue->status = $status;
44+
$issue->save();
45+
}
46+
47+
throw new TransitionPermissionException();
48+
}
49+
50+
/**
51+
* @param Models\AIssue $issue
52+
* @return array<string>
53+
*/
54+
public function getTransitionableStatuses(Models\AIssue $issue): array
55+
{
56+
$statuses = [];
57+
foreach (config('aissue')['issueTypes'][$issue->getIssueType()] as $index => $item) {
58+
if ($this->canMakeTransition($issue, $index)) {
59+
$statuses[] = $index;
60+
}
61+
}
62+
63+
return $statuses;
64+
}
765
}

src/AIssueServiceProvider.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ public function configurePackage(Package $package): void
2323
// ->hasCommand(AIssueCommand::class);
2424
}
2525

26-
public function boot()
26+
public function boot(): void
2727
{
2828
parent::boot();
29-
3029
// load packages migrations
31-
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
30+
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
3231

32+
$this->publishes([
33+
__DIR__.'/../config' => config_path(),
34+
], 'aissue-config');
3335
}
3436
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace AuroraWebSoftware\AIssue\Contracts;
4+
5+
/**
6+
* AIssueModelContract
7+
*/
8+
interface AIssueModelContract
9+
{
10+
/**
11+
* @param string $issueType
12+
* @return string
13+
*/
14+
public static function getAIssueDefaultStatus(string $issueType): string;
15+
16+
/**
17+
* @return string
18+
*/
19+
public static function getAIssueModelType(): string;
20+
21+
/**
22+
* @return int
23+
*/
24+
public function getAIssueModelId(): int;
25+
}

0 commit comments

Comments
 (0)