diff --git a/app/Http/Controllers/Back/GitlabProjectController.php b/app/Http/Controllers/Back/GitlabProjectController.php deleted file mode 100644 index 83cf044..0000000 --- a/app/Http/Controllers/Back/GitlabProjectController.php +++ /dev/null @@ -1,249 +0,0 @@ -authorizeResource(GitlabProject::class); - $this->modelName = GitlabProject::modelName(); - $this->modelPage = GitlabProject::modelPage(); - } - - /** - * Display a listing of the resource. - * - * @param \Illuminate\Http\Request $request - * @return \Inertia\Response - */ - public function index(Request $request): \Inertia\Response - { - /** @var \Illuminate\Database\Eloquent\Builder<\App\Models\GitlabProject> $query */ - $query = GitlabProject::query(); - - if ($request->routeIs("{$this->routeName}{$this->modelName}.trash")) { - $query = $query->onlyTrashed(); - } - - /** @var string $search Search field */ - $search = $request->search; - if ($search) { - $this->searchQuery( - $query, - $search, - null, - 'name', - ); - } - $searchFields = \implode(', ', [ - trans('validation.attributes.name'), - ]); - - /** Sort columns with a query */ - $this->sortQuery($query); - - /** Custom pagination */ - $models = $this->paginate($query); - - return $this->inertiaRender("back/Pages/$this->modelPage/Index", [ - 'models' => CommonResource::collection($models), - 'search' => $search, - 'searchFields' => $searchFields, - ]); - } - - /** - * Show the form for creating a new resource. - * - * @param \App\Models\GitlabProject $gitlab_project - * @return \Inertia\Response - */ - public function create(GitlabProject $gitlab_project): \Inertia\Response - { - return $this->inertiaRender("back/Pages/$this->modelPage/Create", [ - 'data' => CommonResource::make($gitlab_project), - ]); - } - - /** - * Show a specific resource. - * - * @param \App\Models\GitlabProject $gitlab_project - * @return \Inertia\Response - */ - public function show(GitlabProject $gitlab_project): \Inertia\Response - { - return $this->inertiaRender("back/Pages/$this->modelPage/Show", [ - 'data' => CommonResource::make($gitlab_project), - ]); - } - - /** - * Store a newly created resource. - * - * @param \App\Http\Requests\Back\GitlabProjects\StoreGitlabProjectRequest $request - * @return \Illuminate\Http\RedirectResponse - */ - public function store(StoreGitlabProjectRequest $request): \Illuminate\Http\RedirectResponse - { - return DB::transaction(function () use ($request) { - $gitlab_project = new GitlabProject(); - $gitlab_project->fill($request->validated()); - - if ($gitlab_project->saveOrFail()) { - return redirect()->route("{$this->routeName}{$this->modelName}.edit", $gitlab_project) - ->with('success', trans('uwil-backend::crud.messages.has_been_created', [ - 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), - ])); - } - return redirect()->back() - ->with('error', trans('uwil-backend::crud.messages.cannot_be_created', [ - 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), - ])); - }); - } - - /** - * Show the form for editing the specified resource. - * - * @param \App\Models\GitlabProject $gitlab_project - * @return \Inertia\Response - */ - public function edit(GitlabProject $gitlab_project): \Inertia\Response - { - return $this->inertiaRender("back/Pages/$this->modelPage/Edit", [ - 'data' => CommonResource::make($gitlab_project), - ]); - } - - /** - * Update the specified resource. - * - * @param \App\Http\Requests\Back\GitlabProjects\UpdateGitlabProjectRequest $request - * @param \App\Models\GitlabProject $gitlab_project - * @return \Illuminate\Http\RedirectResponse - */ - public function update( - UpdateGitlabProjectRequest $request, - GitlabProject $gitlab_project - ): \Illuminate\Http\RedirectResponse { - return DB::transaction(function () use ($request, $gitlab_project) { - $gitlab_project->fill($request->validated()); - - if ($gitlab_project->saveOrFail()) { - return redirect()->route("{$this->routeName}{$this->modelName}.edit", $gitlab_project) - ->with('success', trans('uwil-backend::crud.messages.has_been_updated', [ - 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), - ])); - } - return redirect()->route("{$this->routeName}{$this->modelName}.edit", $gitlab_project) - ->with('error', trans('uwil-backend::crud.messages.cannot_be_updated', [ - 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), - ])); - }); - } - - /** - * Duplicate the specified resource. - * - * @param \App\Models\GitlabProject $gitlab_project - * @return \Inertia\Response - */ - public function duplicate(GitlabProject $gitlab_project): \Inertia\Response - { - $gitlab_project->loadMissing(GitlabProject::$cacheRelations ?? []); - $replica = $gitlab_project->replicate(); - collect($gitlab_project->getRelations())->each(fn($value, $relation) => $replica->setRelation($relation, $value)); - return $this->create($replica); - } - - /** - * Restore the specified resource. - * - * @param integer $gitlab_project - * @return \Illuminate\Http\RedirectResponse - */ - public function restore(int $gitlab_project): \Illuminate\Http\RedirectResponse - { - $gitlab_project = GitlabProject::withTrashed()->findOrFail($gitlab_project); - /** @var array */ - $previousQueries = []; - \parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); - if ($gitlab_project->restore()) { - return redirect()->route("{$this->routeName}{$this->modelName}.trash", $previousQueries) - ->with('success', trans('uwil-backend::crud.messages.has_been_restored', [ - 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), - ])); - } - return redirect()->back() - ->with('error', trans('uwil-backend::crud.messages.cannot_be_restored', [ - 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), - ])); - } - - /** - * Destroy the specified resource. - * - * @param \App\Models\GitlabProject $gitlab_project - * @return \Illuminate\Http\RedirectResponse - */ - public function destroy(GitlabProject $gitlab_project): \Illuminate\Http\RedirectResponse - { - /** @var array */ - $previousQueries = []; - \parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); - if ($gitlab_project->delete()) { - return redirect()->route("{$this->routeName}{$this->modelName}.index", $previousQueries) - ->with('success', trans('uwil-backend::crud.messages.has_been_deleted', [ - 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), - ])); - } - return redirect()->back() - ->with('error', trans('uwil-backend::crud.messages.cannot_be_deleted', [ - 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), - ])); - } - - /** - * Destroy the specified resource. - * - * @param \App\Models\GitlabProject|integer $gitlab_project - * @return \Illuminate\Http\RedirectResponse - */ - public function forceDestroy(GitlabProject|int $gitlab_project): \Illuminate\Http\RedirectResponse - { - if (is_int($gitlab_project)) { - $gitlab_project = GitlabProject::withTrashed()->findOrFail($gitlab_project); - } - /** @var array */ - $previousQueries = []; - \parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); - if ($gitlab_project->forceDelete()) { - return redirect()->route("{$this->routeName}{$this->modelName}.trash", $previousQueries) - ->with('success', trans('uwil-backend::crud.messages.has_been_deleted', [ - 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), - ])); - } - return redirect()->back() - ->with('error', trans('uwil-backend::crud.messages.cannot_be_deleted', [ - 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), - ])); - } -} diff --git a/app/Http/Requests/Back/GitlabProjects/StoreGitlabProjectRequest.php b/app/Http/Requests/Back/GitlabProjects/StoreGitlabProjectRequest.php deleted file mode 100644 index 401c10e..0000000 --- a/app/Http/Requests/Back/GitlabProjects/StoreGitlabProjectRequest.php +++ /dev/null @@ -1,51 +0,0 @@ - - */ - public function rules(): array - { - return [ - 'name' => 'required|string|between:3,255', - 'url' => 'required|string|url:http,https|unique:gitlab_projects,url', - 'gitlab_id' => 'required|integer|unique:gitlab_projects,gitlab_id', - ]; - } - - /** - * Get custom attributes for validator errors. - * - * @return array - */ - public function attributes(): array - { - return [ - 'name' => trans('validation.custom.name'), - 'url' => trans('validation.custom.url'), - 'gitlab_id' => trans('validation.custom.gitlab_id'), - ]; - } -} diff --git a/app/Http/Requests/Back/GitlabProjects/UpdateGitlabProjectRequest.php b/app/Http/Requests/Back/GitlabProjects/UpdateGitlabProjectRequest.php deleted file mode 100644 index b3a3f87..0000000 --- a/app/Http/Requests/Back/GitlabProjects/UpdateGitlabProjectRequest.php +++ /dev/null @@ -1,48 +0,0 @@ -route('gitlab_project')); - } - - /** - * Get the validation rules that apply to the request. - * - * @return array - */ - #[\Override] - public function rules(): array - { - /** @var \App\Models\GitlabProject $gitlab_project */ - $gitlab_project = $this->route('gitlab_project'); - return array_merge(parent::rules(), [ - 'url' => [ - 'required', - 'string', - 'url:http,https', - Rule::unique('gitlab_projects', 'url')->ignore($gitlab_project->getRouteKey()), - ], - 'gitlab_id' => [ - 'required', - 'integer', - Rule::unique('gitlab_projects', 'gitlab_id')->ignore($gitlab_project->getRouteKey()), - ], - ]); - } -} diff --git a/app/Models/Brand.php b/app/Models/Brand.php index 9aa6a8e..7152ce5 100644 --- a/app/Models/Brand.php +++ b/app/Models/Brand.php @@ -11,11 +11,11 @@ use Uwil\LaravelBackend\Traits\Models\HasModelNaming; use Uwil\LaravelI18n\Traits\Models\HasTranslations; /** - * @property integer $id Id of the brand. - * @property string $name Name of the brand. - * @property-read \Illuminate\Support\Carbon $created_at Date the Brand was created. - * @property-read \Illuminate\Support\Carbon $updated_at Date the Brand was updated. - * @property-read \Illuminate\Support\Carbon $deleted_at Date the Brand was deleted. + * @property integer $id Primary key of the brand. + * @property string $name Name of the brand. + * @property-read \Illuminate\Support\Carbon $created_at Date the brand was created. + * @property-read \Illuminate\Support\Carbon $updated_at Date the brand was updated. + * @property-read \Illuminate\Support\Carbon $deleted_at Date the brand was deleted. */ class Brand extends Model { diff --git a/app/Models/GitlabIssue.php b/app/Models/GitlabIssue.php new file mode 100644 index 0000000..7f8b368 --- /dev/null +++ b/app/Models/GitlabIssue.php @@ -0,0 +1,105 @@ + */ + use HasFactory; + use HasTranslations; + + /** + * The attributes that are mass assignable. + * + * @var list + */ + protected $fillable = [ + "title", + "url", + "estimate_time", + "spent_time", + "is_closed", + "gitlab_id", + "gitlab_iid", + "milestone_iid", + "gitlab_project_id", + "g_created_at", + "g_updated_at", + "g_closed_at", + "g_due_date", + ]; + + /** + * The translatable columns. + * + * @var list + */ + public $translatable = [ + "title", + ]; + + /** + * The attributes that should be cast. + * + * @var array + */ + protected $casts = [ + 'is_closed' => 'boolean', + ]; + + /** + * Perform any actions required after the model boots. + * + * @return void + */ + protected static function booted(): void + { + static::creating(function (self $model) { + self::manageFields($model); + }); + static::updating(function (self $model) { + self::manageFields($model); + }); + } + + // * METHODS. + + /** + * Manage model fields. + * + * @param self $model + * @return void + */ + private static function manageFields(self $model): void + { + TranslationHelper::assertTranslationFieldIsUnique($model, $model->title, 'title'); + TranslationHelper::validateFallbackTranslations($model); + } +} diff --git a/app/Models/GitlabIssueLabel.php b/app/Models/GitlabIssueLabel.php new file mode 100644 index 0000000..c4dfe4d --- /dev/null +++ b/app/Models/GitlabIssueLabel.php @@ -0,0 +1,38 @@ + */ + use HasFactory; + + /** + * The table associated with the model. + * + * @var string|null + */ + protected $table = 'gitlab_issues_labels'; + + /** + * The attributes that are mass assignable. + * + * @var list + */ + protected $fillable = [ + 'issue_id', + 'label_id', + ]; +} diff --git a/app/Models/GitlabLabel.php b/app/Models/GitlabLabel.php new file mode 100644 index 0000000..77bc446 --- /dev/null +++ b/app/Models/GitlabLabel.php @@ -0,0 +1,74 @@ + */ + use HasFactory; + use HasTranslations; + + /** + * The attributes that are mass assignable. + * + * @var list + */ + protected $fillable = [ + 'name', + 'gitlab_id', + ]; + + /** + * The translatable columns. + * + * @var list + */ + public $translatable = [ + 'name', + ]; + + /** + * Perform any actions required after the model boots. + * + * @return void + */ + protected static function booted(): void + { + static::creating(function (self $model) { + self::manageFields($model); + }); + static::updating(function (self $model) { + self::manageFields($model); + }); + } + + // * METHODS. + + /** + * Manage model fields. + * + * @param self $model + * @return void + */ + private static function manageFields(self $model): void + { + TranslationHelper::assertTranslationFieldIsUnique($model, $model->name, 'name'); + TranslationHelper::validateFallbackTranslations($model); + } +} diff --git a/app/Models/GitlabMilestone.php b/app/Models/GitlabMilestone.php new file mode 100644 index 0000000..d57ffd1 --- /dev/null +++ b/app/Models/GitlabMilestone.php @@ -0,0 +1,99 @@ + */ + use HasFactory; + use HasTranslations; + + /** + * The attributes that are mass assignable. + * + * @var list + */ + protected $fillable = [ + "title", + "url", + "is_closed", + "gitlab_id", + "gitlab_iid", + "gitlab_project_id", + "g_created_at", + "g_updated_at", + "g_closed_at", + "g_due_date", + ]; + + /** + * The translatable columns. + * + * @var list + */ + public $translatable = [ + "title", + ]; + + /** + * The attributes that should be cast. + * + * @var array + */ + protected $casts = [ + 'is_closed' => 'boolean', + ]; + + /** + * Perform any actions required after the model boots. + * + * @return void + */ + protected static function booted(): void + { + static::creating(function (self $model) { + self::manageFields($model); + }); + static::updating(function (self $model) { + self::manageFields($model); + }); + } + + // * METHODS. + + /** + * Manage model fields. + * + * @param self $model + * @return void + */ + private static function manageFields(self $model): void + { + TranslationHelper::assertTranslationFieldIsUnique($model, $model->title, 'title'); + TranslationHelper::validateFallbackTranslations($model); + } +} diff --git a/app/Models/GitlabProject.php b/app/Models/GitlabProject.php index d4980de..7146b9a 100644 --- a/app/Models/GitlabProject.php +++ b/app/Models/GitlabProject.php @@ -4,30 +4,27 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\SoftDeletes; use Uwil\LaravelActivityLogs\Traits\HasActivityLog; -use Uwil\LaravelBackend\Traits\Models\HasCache; -use Uwil\LaravelBackend\Traits\Models\HasModelNaming; +use Uwil\LaravelI18n\Helpers\TranslationHelper; +use Uwil\LaravelI18n\Interfaces\TranslatableModel; use Uwil\LaravelI18n\Traits\Models\HasTranslations; /** - * @property integer $id Primary key of the gitlab project relation. - * @property string $name Name of the gitlab project. - * @property string $url Url of the gitlab project. - * @property \App\Models\User $gitlab_id Gitlab id of the gitlab project. - * @property-read \Illuminate\Support\Carbon $created_at Date the gitlab project was created. - * @property-read \Illuminate\Support\Carbon $updated_at Date the gitlab project was updated. - * @property-read \Illuminate\Support\Carbon $deleted_at Date the gitlab project was deleted. + * @property integer $id Primary key of the gitlab project. + * @property string $name Name of the gitlab project. + * @property string $url Url of the gitlab project. + * @property string $is_archived Archived status of the gitlab project. + * @property integer $gitlab_id Gitlab id of the gitlab project. + * @property-read \Illuminate\Support\Carbon $created_at Date the gitlab project was created. + * @property-read \Illuminate\Support\Carbon $updated_at Date the gitlab project was updated. + * @property-read \Illuminate\Support\Carbon $deleted_at Date the gitlab project was deleted. */ -class GitlabProject extends Model +class GitlabProject extends Model implements TranslatableModel { use HasActivityLog; - use HasCache; /** @use \Illuminate\Database\Eloquent\Factories\HasFactory<\Database\Factories\GitlabProjectFactory> */ use HasFactory; - use HasModelNaming; use HasTranslations; - use SoftDeletes; /** * The attributes that are mass assignable. @@ -37,6 +34,7 @@ class GitlabProject extends Model protected $fillable = [ 'name', 'url', + 'is_archived', 'gitlab_id', ]; @@ -48,4 +46,42 @@ class GitlabProject extends Model public $translatable = [ 'name', ]; + + /** + * The attributes that should be cast. + * + * @var array + */ + protected $casts = [ + 'is_archived' => 'boolean', + ]; + + /** + * Perform any actions required after the model boots. + * + * @return void + */ + protected static function booted(): void + { + static::creating(function (self $model) { + self::manageFields($model); + }); + static::updating(function (self $model) { + self::manageFields($model); + }); + } + + // * METHODS. + + /** + * Manage model fields. + * + * @param self $model + * @return void + */ + private static function manageFields(self $model): void + { + TranslationHelper::assertTranslationFieldIsUnique($model, $model->name, 'name'); + TranslationHelper::validateFallbackTranslations($model); + } } diff --git a/app/Models/GitlabUser.php b/app/Models/GitlabUser.php index a20f297..876e911 100644 --- a/app/Models/GitlabUser.php +++ b/app/Models/GitlabUser.php @@ -6,7 +6,7 @@ use App\Models\User; use Illuminate\Database\Eloquent\Model; /** - * @property integer $id Id of the gitlab user. + * @property integer $id Primary key of the gitlab user. * @property integer $user_id Gitlab id of the user. * @property integer $gitlab_id Id of the user. * @property-read \Illuminate\Support\Carbon $created_at Date the gitlab user was created. diff --git a/app/Models/InvoiceCompany.php b/app/Models/InvoiceCompany.php index bcc5775..c1520d1 100644 --- a/app/Models/InvoiceCompany.php +++ b/app/Models/InvoiceCompany.php @@ -11,7 +11,7 @@ use Uwil\LaravelBackend\Traits\Models\HasModelNaming; use Uwil\LaravelI18n\Traits\Models\HasTranslations; /** - * @property integer $id Id of the invoice company. + * @property integer $id Primary key of the invoice company. * @property string $name Name of the invoice company. * @property-read \Illuminate\Support\Carbon $created_at Date the invoice company was created. * @property-read \Illuminate\Support\Carbon $updated_at Date the invoice company was updated. diff --git a/app/Models/InvoicePackage.php b/app/Models/InvoicePackage.php index 32dd8b3..33129bc 100644 --- a/app/Models/InvoicePackage.php +++ b/app/Models/InvoicePackage.php @@ -11,7 +11,7 @@ use Uwil\LaravelBackend\Traits\Models\HasModelNaming; use Uwil\LaravelI18n\Traits\Models\HasTranslations; /** - * @property integer $id Id of the invoice package. + * @property integer $id Primary key of the invoice package. * @property string $name Name of the invoice package. * @property string $amount Amount of the invoice package. * @property string $published Published status of the invoice package. diff --git a/app/Models/Notice.php b/app/Models/Notice.php index f22f991..27184a0 100644 --- a/app/Models/Notice.php +++ b/app/Models/Notice.php @@ -12,7 +12,7 @@ use Uwil\LaravelBackend\Traits\Models\HasModelNaming; use Uwil\LaravelI18n\Traits\Models\HasTranslations; /** - * @property integer $id Id of the notice. + * @property integer $id Primary key of the notice. * @property string $title Title of the notice. * @property string $message Message of the notice. * @property integer $type Type of the notice. diff --git a/app/Models/Site.php b/app/Models/Site.php index 668ef20..d0fa2f5 100644 --- a/app/Models/Site.php +++ b/app/Models/Site.php @@ -12,7 +12,7 @@ use Uwil\LaravelCommon\Helpers\ToolboxHelper; use Uwil\LaravelI18n\Traits\Models\HasTranslations; /** - * @property integer $id Id of the site. + * @property integer $id Primary key of the site. * @property string $name Name of the site. * @property string $url_re7 Re7 url of the site. * @property string $url_prod Prod url of the site. diff --git a/app/Models/UserPassword.php b/app/Models/UserPassword.php index 0528ec4..465dfe5 100644 --- a/app/Models/UserPassword.php +++ b/app/Models/UserPassword.php @@ -5,7 +5,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; /** - * @property integer $id Id of the user password. + * @property integer $id Primary key of the user password. * @property \App\Models\User $user_id Associated user. * @property string $password Password of the user. * @property-read \Illuminate\Support\Carbon $created_at Date on which the password was created. diff --git a/app/Policies/GitlabProjectPolicy.php b/app/Policies/GitlabProjectPolicy.php deleted file mode 100644 index e25dd58..0000000 --- a/app/Policies/GitlabProjectPolicy.php +++ /dev/null @@ -1,112 +0,0 @@ -value); - } - - /** - * Determine whether the user can view trash models. - * - * @param \Illuminate\Database\Eloquent\Model $authModel - * @return boolean - */ - public function viewTrash(Model $authModel): bool - { - return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('conceptor')->value); - } - - /** - * Determine whether the user can view the model. - * - * @param \Illuminate\Database\Eloquent\Model $authModel - * @return boolean - */ - public function view(Model $authModel): bool - { - return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('conceptor')->value); - } - - /** - * Determine whether the user can create models. - * - * @param \Illuminate\Database\Eloquent\Model $authModel - * @return boolean - */ - public function create(Model $authModel): bool - { - return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('conceptor')->value); - } - - /** - * Determine whether the user can update the model. - * - * @param \Illuminate\Database\Eloquent\Model $authModel - * @return boolean - */ - public function update(Model $authModel): bool - { - return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('conceptor')->value); - } - - /** - * Determine whether the user can duplicate the model. - * - * @param \Illuminate\Database\Eloquent\Model $authModel - * @return boolean - */ - public function duplicate(Model $authModel): bool - { - return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('conceptor')->value); - } - - /** - * Determine whether the user can restore the model. - * - * @param \Illuminate\Database\Eloquent\Model $authModel - * @return boolean - */ - public function restore(Model $authModel): bool - { - return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('conceptor')->value); - } - - /** - * Determine whether the user can soft delete the model. - * - * @param \Illuminate\Database\Eloquent\Model $authModel - * @return boolean - */ - public function delete(Model $authModel): bool - { - return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('conceptor')->value); - } - - /** - * Determine whether the user can permanently delete the model. - * - * @param \Illuminate\Database\Eloquent\Model $authModel - * @return boolean - */ - public function forceDelete(Model $authModel): bool - { - return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('conceptor')->value); - } -} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 2a7d1d0..b700654 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -4,6 +4,8 @@ namespace App\Providers; use App\Enums\NoticeTypeEnum; use App\Models\Brand; +use App\Models\GitlabIssue; +use App\Models\GitlabLabel; use App\Models\GitlabProject; use App\Models\InvoiceCompany; use App\Models\InvoicePackage; @@ -49,11 +51,6 @@ class AppServiceProvider extends ServiceProvider 'viewTrash' => Gate::allows('viewTrash', InvoiceCompany::class), 'create' => Gate::allows('create', InvoiceCompany::class), ]); - InertiaSharedRegistry::add('auth.policies.gitlabProjects', fn () => [ - 'viewAny' => Gate::allows('viewAny', GitlabProject::class), - 'viewTrash' => Gate::allows('viewTrash', GitlabProject::class), - 'create' => Gate::allows('create', GitlabProject::class), - ]); InertiaSharedRegistry::add('auth.policies.sites', fn () => [ 'viewAny' => Gate::allows('viewAny', Site::class), 'viewTrash' => Gate::allows('viewTrash', Site::class), diff --git a/composer.json b/composer.json index 5d3ccfb..2993ec7 100644 --- a/composer.json +++ b/composer.json @@ -31,6 +31,34 @@ "slevomat/coding-standard": "^8.22" }, "repositories": [ + { + "type": "path", + "url": "packages/laravel-common", + "options": { + "symlink": true + } + }, + { + "type": "path", + "url": "packages/laravel-backend", + "options": { + "symlink": true + } + }, + { + "type": "path", + "url": "packages/laravel-i18n", + "options": { + "symlink": true + } + }, + { + "type": "path", + "url": "packages/laravel-activity-logs", + "options": { + "symlink": true + } + }, { "type": "composer", "url": "https://lab.s-web.fr/api/v4/group/23/-/packages/composer/packages.json" diff --git a/database/factories/GitlabIssueFactory.php b/database/factories/GitlabIssueFactory.php new file mode 100644 index 0000000..5aa4bfd --- /dev/null +++ b/database/factories/GitlabIssueFactory.php @@ -0,0 +1,44 @@ + + */ + protected $model = GitlabIssue::class; + + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + $isClosed = fake()->boolean(25); + return [ + "title" => fake()->unique()->words(3, true), + "url" => fake()->unique()->url(), + "estimate_time" => fake()->boolean(75) ? fake()->numberBetween(1, 32) * 900 : 0, + "spent_time" => fake()->boolean(75) ? fake()->numberBetween(1, 32) * 900 : 0, + "is_closed" => $isClosed, + "gitlab_id" => fake()->unique()->numberBetween(1, 1000), + "gitlab_iid" => fake()->numberBetween(1, 1000), + "milestone_iid" => fake()->boolean(75) ? fake()->numberBetween(1, 1000) : null, + "gitlab_project_id" => fake()->unique()->numberBetween(1, 1000), + "g_created_at" => fake()->date(), + "g_updated_at" => fake()->date(), + "g_closed_at" => $isClosed ? fake()->date() : null, + "g_due_date" => fake()->boolean(25) ? fake()->date() : null, + ]; + } +} diff --git a/database/factories/GitlabIssueLabelFactory.php b/database/factories/GitlabIssueLabelFactory.php new file mode 100644 index 0000000..f86b7ad --- /dev/null +++ b/database/factories/GitlabIssueLabelFactory.php @@ -0,0 +1,34 @@ + + */ + protected $model = GitlabIssueLabel::class; + + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'issue_id' => GitlabIssue::factory(), + 'label_id' => GitlabLabel::factory(), + ]; + } +} diff --git a/database/factories/GitlabLabelFactory.php b/database/factories/GitlabLabelFactory.php new file mode 100644 index 0000000..75d63e2 --- /dev/null +++ b/database/factories/GitlabLabelFactory.php @@ -0,0 +1,32 @@ + + */ + protected $model = GitlabLabel::class; + + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + "name" => fake()->unique()->words(3, true), + "gitlab_id" => fake()->unique()->numberBetween(1, 1000), + ]; + } +} diff --git a/database/factories/GitlabMilestoneFactory.php b/database/factories/GitlabMilestoneFactory.php new file mode 100644 index 0000000..2073caa --- /dev/null +++ b/database/factories/GitlabMilestoneFactory.php @@ -0,0 +1,41 @@ + + */ + protected $model = GitlabMilestone::class; + + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + $isClosed = fake()->boolean(25); + return [ + "title" => fake()->words(3, true), + "url" => fake()->url(), + "is_closed" => $isClosed, + "gitlab_id" => fake()->numberBetween(1, 1000), + "gitlab_iid" => fake()->numberBetween(1, 1000), + "gitlab_project_id" => fake()->numberBetween(1, 1000), + "g_created_at" => fake()->date(), + "g_updated_at" => fake()->date(), + "g_closed_at" => $isClosed ? fake()->date() : null, + "g_due_date" => fake()->boolean(25) ? fake()->date() : null, + ]; + } +} diff --git a/database/factories/GitlabProjectFactory.php b/database/factories/GitlabProjectFactory.php index d698b8e..61ed011 100644 --- a/database/factories/GitlabProjectFactory.php +++ b/database/factories/GitlabProjectFactory.php @@ -25,9 +25,10 @@ class GitlabProjectFactory extends Factory public function definition(): array { return [ - "name" => fake()->unique()->words(3, true), - "url" => fake()->unique()->url(), - "gitlab_id" => fake()->unique()->numberBetween(1, 1000), + "name" => fake()->unique()->words(3, true), + "url" => fake()->unique()->url(), + "is_archived" => fake()->boolean(25), + "gitlab_id" => fake()->unique()->numberBetween(1, 1000), ]; } } diff --git a/database/factories/SiteFactory.php b/database/factories/SiteFactory.php index d827579..025c3ad 100644 --- a/database/factories/SiteFactory.php +++ b/database/factories/SiteFactory.php @@ -43,7 +43,7 @@ class SiteFactory extends Factory "url_re7" => fake()->boolean(75) ? fake()->unique()->url() : null, "url_prod" => fake()->boolean(75) ? fake()->unique()->url() : null, "project_manager_id" => fake()->boolean(75) ? $projectManager->getKey() : null, - "gitlab_project_id" => fake()->unique()->randomElement(GitlabProject::pluck("id")), + "gitlab_project_id" => GitlabProject::factory(), ]; } } diff --git a/database/migrations/2026_04_30_155423_create_gitlab_projects_table.php b/database/migrations/2026_04_30_155423_create_gitlab_projects_table.php index 3de26d2..70bdda1 100644 --- a/database/migrations/2026_04_30_155423_create_gitlab_projects_table.php +++ b/database/migrations/2026_04_30_155423_create_gitlab_projects_table.php @@ -17,10 +17,10 @@ return new class extends Migration $table->id()->comment('Primary key of the gitlab project relation.'); $table->string('name')->comment('Name of the gitlab project.'); $table->string('url')->unique()->comment('Url of the gitlab project.'); + $table->unsignedTinyInteger('is_archived')->comment('Archived status of the gitlab project.'); $table->unsignedBigInteger('gitlab_id')->unique()->comment('Gitlab id of the gitlab project.'); $table->timestamp('created_at')->nullable()->comment('Date the gitlab project was created.'); $table->timestamp('updated_at')->nullable()->comment('Date the gitlab project was updated.'); - $table->timestamp('deleted_at')->nullable()->comment('Date the gitlab project was deleted.'); }); } diff --git a/database/migrations/2026_05_26_093500_create_gitlab_labels_table.php b/database/migrations/2026_05_26_093500_create_gitlab_labels_table.php new file mode 100644 index 0000000..67aa2ab --- /dev/null +++ b/database/migrations/2026_05_26_093500_create_gitlab_labels_table.php @@ -0,0 +1,34 @@ +id()->comment('Id of the gitlab label.'); + $table->string('name')->unique()->comment('Name of the gitlab label.'); + $table->unsignedBigInteger('gitlab_id')->unique()->comment('Gitlab id of the gitlab label.'); + $table->timestamp('created_at')->nullable()->comment('Date the gitlab label was created.'); + $table->timestamp('updated_at')->nullable()->comment('Date the gitlab label was updated.'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void + { + Schema::dropIfExists('gitlab_labels'); + } +}; diff --git a/database/migrations/2026_05_26_100638_create_gitlab_issues_table.php b/database/migrations/2026_05_26_100638_create_gitlab_issues_table.php new file mode 100644 index 0000000..0397a28 --- /dev/null +++ b/database/migrations/2026_05_26_100638_create_gitlab_issues_table.php @@ -0,0 +1,45 @@ +id()->comment('Id of the gitlab issue.'); + $table->string('title')->comment('Title of the gitlab issue.'); + $table->string('url')->unique()->comment('Url of the gitlab issue.'); + $table->unsignedInteger('estimate_time')->default(0)->comment('Estimate time of the gitlab issue.'); + $table->unsignedInteger('spent_time')->default(0)->comment('Spend time of the gitlab issue.'); + $table->unsignedTinyInteger('is_closed')->comment('Closed status of the gitlab issue.'); + $table->unsignedInteger('gitlab_id')->unique()->comment('Gitlab id of the gitlab issue.'); + $table->unsignedInteger('gitlab_iid')->comment('Gitlab iid of the gitlab issue.'); + $table->unsignedInteger('milestone_iid')->nullable()->comment('Milestone iid of the gitlab issue.'); + $table->unsignedInteger('gitlab_project_id')->comment('Gitlab project id of the gitlab issue.'); + $table->date('g_created_at')->comment('Created at date of the gitlab issue.'); + $table->date('g_updated_at')->comment('Updated at date of the gitlab issue.'); + $table->date('g_closed_at')->nullable()->comment('Closed at date of the gitlab issue.'); + $table->date('g_due_date')->nullable()->comment('Due at date of the gitlab issue.'); + $table->timestamp('created_at')->nullable()->comment('Date the gitlab issue was created.'); + $table->timestamp('updated_at')->nullable()->comment('Date the gitlab issue was updated.'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void + { + Schema::dropIfExists('gitlab_issues'); + } +}; diff --git a/database/migrations/2026_05_26_104912_create_gitlab_milestones_table.php b/database/migrations/2026_05_26_104912_create_gitlab_milestones_table.php new file mode 100644 index 0000000..ca0d9c9 --- /dev/null +++ b/database/migrations/2026_05_26_104912_create_gitlab_milestones_table.php @@ -0,0 +1,42 @@ +id()->comment('Id of the gitlab milestone.'); + $table->string('title')->comment('Title of the gitlab milestone.'); + $table->string('url')->comment('Url of the gitlab milestone.'); + $table->unsignedTinyInteger('is_closed')->comment('Closed status of the gitlab milestone.'); + $table->unsignedInteger('gitlab_id')->comment('Gitlab id of the gitlab milestone.'); + $table->unsignedInteger('gitlab_iid')->comment('Gitlab iid of the gitlab milestone.'); + $table->unsignedInteger('gitlab_project_id')->comment('Gitlab project id of the gitlab milestone.'); + $table->date('g_created_at')->comment('Created at date of the gitlab milestone.'); + $table->date('g_updated_at')->comment('Updated at date of the gitlab milestone.'); + $table->date('g_closed_at')->nullable()->comment('Closed at date of the gitlab milestone.'); + $table->date('g_due_date')->nullable()->comment('Due at date of the gitlab milestone.'); + $table->timestamp('created_at')->nullable()->comment('Date the gitlab milestone was created.'); + $table->timestamp('updated_at')->nullable()->comment('Date the gitlab milestone was updated.'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void + { + Schema::dropIfExists('gitlab_milestones'); + } +}; diff --git a/database/migrations/2026_05_26_110633_create_gitlab_issue_labels_table.php b/database/migrations/2026_05_26_110633_create_gitlab_issue_labels_table.php new file mode 100644 index 0000000..e28ba19 --- /dev/null +++ b/database/migrations/2026_05_26_110633_create_gitlab_issue_labels_table.php @@ -0,0 +1,36 @@ +id()->comment('Id of the relation.'); + $table->foreignId('issue_id')->comment('Gitlab issue id of the relation.') + ->constrained('gitlab_issues')->onUpdate('no action')->onDelete('cascade'); + $table->foreignId('label_id')->comment('Gitlab label id of the relation.') + ->constrained('gitlab_labels')->onUpdate('no action')->onDelete('cascade'); + $table->timestamp('created_at')->nullable()->comment('Date the relation was created.'); + $table->timestamp('updated_at')->nullable()->comment('Date the relation was updated.'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void + { + Schema::dropIfExists('gitlab_issues_labels'); + } +}; diff --git a/database/seeders/Classic/GitlabIssueLabelSeeder.php b/database/seeders/Classic/GitlabIssueLabelSeeder.php new file mode 100644 index 0000000..8ff409b --- /dev/null +++ b/database/seeders/Classic/GitlabIssueLabelSeeder.php @@ -0,0 +1,25 @@ +create(); + } +} diff --git a/database/seeders/Classic/GitlabIssueSeeder.php b/database/seeders/Classic/GitlabIssueSeeder.php new file mode 100644 index 0000000..19eb696 --- /dev/null +++ b/database/seeders/Classic/GitlabIssueSeeder.php @@ -0,0 +1,25 @@ +create(); + } +} diff --git a/database/seeders/Classic/GitlabLabelSeeder.php b/database/seeders/Classic/GitlabLabelSeeder.php new file mode 100644 index 0000000..5d47449 --- /dev/null +++ b/database/seeders/Classic/GitlabLabelSeeder.php @@ -0,0 +1,25 @@ +create(); + } +} diff --git a/database/seeders/Classic/GitlabMilestoneSeeder.php b/database/seeders/Classic/GitlabMilestoneSeeder.php new file mode 100644 index 0000000..4627b66 --- /dev/null +++ b/database/seeders/Classic/GitlabMilestoneSeeder.php @@ -0,0 +1,25 @@ +create(); + } +} diff --git a/lang/fr/models.php b/lang/fr/models.php index 40bf8b1..282ca20 100644 --- a/lang/fr/models.php +++ b/lang/fr/models.php @@ -8,6 +8,8 @@ return [ "invoice-packages" => "devis - forfait|devis - forfaits", "invoice-companies" => "devis - société|devis - sociétés", "gitlab-projects" => "gitlab - projet|gitlab - projets", + "gitlab-labels" => "gitlab - libellé|gitlab - libellés", + "gitlab-issues" => "gitlab - issue|gitlab - issues", "sites" => "site|sites", "brands" => "marque|marques", ], diff --git a/resources/ts/back/Components/Layout/Sidebar/Links/GitlabProjects.tsx b/resources/ts/back/Components/Layout/Sidebar/Links/GitlabProjects.tsx deleted file mode 100644 index aca01e6..0000000 --- a/resources/ts/back/Components/Layout/Sidebar/Links/GitlabProjects.tsx +++ /dev/null @@ -1,79 +0,0 @@ -// * Packages -import { FolderGit2Icon } from "lucide-react"; -import { route } from "ziggy-js"; -import { Link } from "@inertiajs/react"; -// * Components shadcn -import { DropdownMenuItem } from "@/components/ui/dropdown-menu"; -import { Button } from "@/components/ui/button"; -// * Other -import { - filterActions, - NavListLinksProps, -} from "@/back/Components/Layout/Sidebar/AppSidebar"; -import { SidebarGroupLink } from "@/back/Components/Layout/Sidebar/SidebarRegistry"; -import { AuthProp } from "@/back/types/global"; -import str from "@/hooks/use-string"; -import { GetTranslation } from "@/lib/utils"; -import useTrans from "@/hooks/use-translations"; -import Views from "@/back/lib/actions"; -import { AppEnv } from "@/types/global"; - -export default function SidebarLinkGitlabProjects( - auth: AuthProp, - appEnv: AppEnv, -): SidebarGroupLink { - const modelName = "gitlab-projects"; - const routeName = appEnv.routes.name; - - // Translations. - const transModel = GetTranslation(`models.classes.${modelName}`, { - choice: 2, - }); - const transCreate = str( - useTrans(`uwil-backend::crud.actions.${Views.CREATION.label}`), - ) - .ucFirst() - .value(); - const transArchives = str(useTrans("uwil-backend::back.archives")) - .ucFirst() - .value(); - - const link: NavListLinksProps = { - title: str(transModel).ucFirst().value(), - model: modelName, - icon: FolderGit2Icon, - show: auth.policies.gitlabProjects.viewAny, - actions: (model: string) => - filterActions({ - auth, - appEnv, - model, - items: [ - auth.policies.gitlabProjects.create && ( - - - - ), - auth.policies.gitlabProjects.viewTrash && ( - - - - ), - ], - }), - }; - - return { link, group: "modules" }; -} diff --git a/resources/ts/back/Pages/GitlabProjects/Create.tsx b/resources/ts/back/Pages/GitlabProjects/Create.tsx deleted file mode 100644 index f4f9fc7..0000000 --- a/resources/ts/back/Pages/GitlabProjects/Create.tsx +++ /dev/null @@ -1,67 +0,0 @@ -// * Packages -import { usePage } from "@inertiajs/react"; -import { route } from "ziggy-js"; -import { ArrowLeftIcon } from "lucide-react"; -// * Other -import AuthenticatedLayout from "@/back/Layouts/AuthenticatedLayout"; -import Form from "@/back/Pages/GitlabProjects/Form"; -import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; -import useTrans from "@/hooks/use-translations"; -import { Actions, Methods } from "@/back/lib/enums"; -import { AuthProp, SingleResource } from "@/back/types/global"; -import { GitlabProjectModel } from "@/back/types/project"; -import { AppEnv } from "@/types/global"; - -export default function Create({ - data, - modelName, -}: { - data: SingleResource; - modelName: string; -}) { - const routeName = (usePage().props.appEnv as AppEnv).routes.name; - const { viewAny } = (usePage().props.auth as AuthProp).policies - .gitlabProjects; - const model = data.data as GitlabProjectModel; - - // Translations. - const transBackToList = useTrans("uwil-backend::back.crud_back_to_list"); - const transTitle = useTrans( - route().current(`${routeName}${modelName}.duplicate`) - ? "uwil-backend::crud.helpers.duplication_model" - : "uwil-backend::crud.helpers.creation_model", - { - params: { - model: useTrans(`models.classes.${modelName}`, { - choice: 1, - }), - }, - }, - ); - - const beforeNode = () => { - return ( - viewAny && ( -
- } - tooltipContent={

{transBackToList}

} - /> -
- ) - ); - }; - - return ( - -
- - ); -} diff --git a/resources/ts/back/Pages/GitlabProjects/Edit.tsx b/resources/ts/back/Pages/GitlabProjects/Edit.tsx deleted file mode 100644 index ffcb036..0000000 --- a/resources/ts/back/Pages/GitlabProjects/Edit.tsx +++ /dev/null @@ -1,75 +0,0 @@ -// * Packages -import { usePage } from "@inertiajs/react"; -import { route } from "ziggy-js"; -import { ArrowLeftIcon } from "lucide-react"; -// * Other -import AuthenticatedLayout from "@/back/Layouts/AuthenticatedLayout"; -import ModelActions from "@/back/Components/ModelActions"; -import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; -import Form from "@/back/Pages/GitlabProjects/Form"; -import useTrans from "@/hooks/use-translations"; -import { Actions, Methods } from "@/back/lib/enums"; -import { Views } from "@/back/lib/actions"; -import { AuthProp, SingleResource } from "@/back/types/global"; -import { GitlabProjectModel } from "@/back/types/project"; -import { AppEnv } from "@/types/global"; - -export default function Edit({ - data, - modelName, -}: { - data: SingleResource; - modelName: string; -}) { - const routeName = (usePage().props.appEnv as AppEnv).routes.name; - const { viewAny } = (usePage().props.auth as AuthProp).policies - .gitlabProjects; - const model = data.data as GitlabProjectModel; - const actionModels = [ - Views.VISUALIZATION, - Views.DUPLICATION, - Views.ARCHIVATION, - ]; - - // Translations. - const transBackToList = useTrans("uwil-backend::back.crud_back_to_list"); - const transTitle = useTrans("uwil-backend::crud.helpers.edition_model", { - params: { - model: useTrans(`models.classes.${modelName}`, { - choice: 1, - }), - }, - }); - - const beforeNode = () => { - return ( - viewAny && ( -
- } - tooltipContent={

{transBackToList}

} - /> -
- ) - ); - }; - - return ( - - - - - ); -} diff --git a/resources/ts/back/Pages/GitlabProjects/Form.tsx b/resources/ts/back/Pages/GitlabProjects/Form.tsx deleted file mode 100644 index ebce579..0000000 --- a/resources/ts/back/Pages/GitlabProjects/Form.tsx +++ /dev/null @@ -1,137 +0,0 @@ -// * Packages -import { useForm, usePage } from "@inertiajs/react"; -import { BookTextIcon, ExternalLinkIcon } from "lucide-react"; -// * Components shadcn -// -// * Other -import FieldsetWrapper from "@/back/Components/FieldsetWrapper"; -import useTrans from "@/hooks/use-translations"; -import InputError from "@/back/Components/InputError"; -import { GitlabProjectModel } from "@/back/types/project"; -import SubmitButton from "@/back/Components/SubmitButton"; -import useCrudSubmit from "@/back/hooks/use-crud-submit"; -import { AppEnv } from "@/types/global"; -import SimpleString from "@/back/Components/Inputs/SimpleString"; -import str from "@/hooks/use-string"; -import { GetTranslation, isAValidUrl } from "@/lib/utils"; -import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; -import SimpleNumber from "@/back/Components/Inputs/SimpleNumber"; - -export default function Form({ - model, - modelName, - modelRoute, - action, - method, -}: { - model?: GitlabProjectModel; - modelName: string; - modelRoute: string; - action: string; - method: number; -}) { - const { appEnv } = usePage().props as unknown as { - appEnv: AppEnv; - }; - - // Form section. - const { post, setData, data } = useForm({ - name: model?.name ? model?.name[appEnv.locale] : undefined, - url: model?.url ?? undefined, - gitlab_id: model?.gitlab_id ?? undefined, - }); - - const submit = useCrudSubmit({ - method, - modelRoute, - modelName, - action, - model, - post, - data, - modelNameTrans: useTrans(`models.classes.${modelName}`, { - choice: 1, - }), - }); - - return ( - - - } - description={useTrans("uwil-backend::back.form_subtitle_global")} - className="sm:grid-cols-2 gap-4" - > - - -
- - {isAValidUrl(data.url) && ( - } - tooltipContent={GetTranslation("back.access_url")} - link={data.url} - externalLink - type="button" - size="icon" - /> - )} -
-
-
- -
- - ); -} diff --git a/resources/ts/back/Pages/GitlabProjects/Index.tsx b/resources/ts/back/Pages/GitlabProjects/Index.tsx deleted file mode 100644 index 067c1f7..0000000 --- a/resources/ts/back/Pages/GitlabProjects/Index.tsx +++ /dev/null @@ -1,195 +0,0 @@ -// * Packages -import { route } from "ziggy-js"; -import { usePage } from "@inertiajs/react"; -import { Row } from "@tanstack/react-table"; -import { ArchiveIcon, ArrowLeftIcon, PlusIcon } from "lucide-react"; -// * Components shadcn -import { Badge } from "@/components/ui/badge"; -import { - Tooltip, - TooltipContent, - TooltipTrigger, -} from "@/components/ui/tooltip"; -// * Other -import AuthenticatedLayout from "@/back/Layouts/AuthenticatedLayout"; -import DataTable from "@/back/Components/Table/DataTable"; -import DataTableSearch from "@/back/Components/Table/DataTableSearch"; -import DataTableFilterButton from "@/back/Components/Table/DataTableFilterButton"; -import SoftdeleteWarning from "@/back/Components/SoftdeleteWarning"; -import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; -import { GetFormatedDate, GetTranslation } from "@/lib/utils"; -import { Views } from "@/back/lib/actions"; -import { AuthProp, Resource } from "@/back/types/global"; -import str from "@/hooks/use-string"; -import useTrans from "@/hooks/use-translations"; -import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; -import { GitlabProjectModel } from "@/back/types/project"; -import { AppEnv } from "@/types/global"; - -const getColumns = () => { - return [ - { - accessorKey: "name", - header: ({ column }: { column: { id: string } }) => ( - - ), - cell: ({ row }: { row: Row }) => ( - - ), - }, - { - accessorKey: "url", - header: ({ column }: { column: { id: string } }) => ( - - ), - cell: ({ row }: { row: Row }) => ( - - - - {row.getValue("url")} - - - {GetTranslation("back.access_url")} - - ), - }, - { - accessorKey: "updated_at", - header: ({ column }: { column: { id: string } }) => ( - - ), - cell: ({ row }: { row: Row }) => ( - - {GetFormatedDate(row.getValue("updated_at"))} - - ), - }, - ]; -}; - -export default function Index({ - models, - searchFields, - modelName, -}: { - models: Resource; - searchFields: string; - modelName: string; -}) { - const { auth, appEnv } = usePage().props as unknown as { - auth: AuthProp; - appEnv: AppEnv; - }; - const { viewAny, viewTrash, create } = auth.policies.gitlabProjects; - const routeName = appEnv.routes.name; - const isArchiveRoute = route().current(`${routeName}${modelName}.trash`); - const actionModels = isArchiveRoute - ? [Views.RESTORATION, Views.FORCEDELETION] - : [ - Views.VISUALIZATION, - Views.EDITION, - Views.DUPLICATION, - Views.ARCHIVATION, - ]; - const columns = getColumns(); - - // Translations. - const transModel = useTrans(`models.classes.${modelName}`, { choice: 2 }); - const transArchiveTitle = useTrans( - "uwil-backend::crud.helpers.archives_model", - { - params: { model: transModel }, - }, - ); - const transTitle = str(isArchiveRoute ? transArchiveTitle : transModel) - .ucFirst() - .value(); - const transCrudBackList = useTrans("uwil-backend::back.crud_back_to_list"); - - const beforeNode = () => { - return ( - isArchiveRoute && - viewAny && ( -
- } - tooltipContent={

{transCrudBackList}

} - /> -
- ) - ); - }; - const transCrudAddEntry = useTrans("uwil-backend::back.crud_add_entry"); - const transAccessTo = useTrans("uwil-backend::back.crud_access_to", { - params: { - target: useTrans("uwil-backend::back.archived_entries"), - }, - }); - const afterNode = () => { - return ( - !isArchiveRoute && ( -
- {viewTrash && ( - } - tooltipContent={

{transAccessTo}

} - variant="outline" - /> - )} - {create && ( - } - tooltipContent={

{transCrudAddEntry}

} - /> - )} -
- ) - ); - }; - - return ( - - {isArchiveRoute && } - - - - ); -} diff --git a/resources/ts/back/Pages/GitlabProjects/Show.tsx b/resources/ts/back/Pages/GitlabProjects/Show.tsx deleted file mode 100644 index 0b4a4be..0000000 --- a/resources/ts/back/Pages/GitlabProjects/Show.tsx +++ /dev/null @@ -1,153 +0,0 @@ -// * Packages -import { usePage } from "@inertiajs/react"; -import { route } from "ziggy-js"; -import { ArrowLeftIcon } from "lucide-react"; -// * Components shadcn -import { Badge } from "@/components/ui/badge"; -import { - Tooltip, - TooltipContent, - TooltipTrigger, -} from "@/components/ui/tooltip"; -// * Other -import AuthenticatedLayout from "@/back/Layouts/AuthenticatedLayout"; -import DetailsTable from "@/back/Components/Table/DetailsTable"; -import ModelActions from "@/back/Components/ModelActions"; -import BtnOptionnalLinkWithTooltip from "@/back/Components/BtnOptionnalLinkWithTooltip"; -import { GetFormatedDate, GetTranslation } from "@/lib/utils"; -import { Views } from "@/back/lib/actions"; -import { AuthProp, SingleResource } from "@/back/types/global"; -import str from "@/hooks/use-string"; -import useTrans from "@/hooks/use-translations"; -import { TranslationField } from "@/back/types/i18n"; -import RenderTranslationCell from "@/back/Components/Table/RenderTranslationCell"; -import { GitlabProjectModel } from "@/back/types/project"; -import { AppEnv } from "@/types/global"; - -const getColumns = () => { - return [ - { - accessorKey: "name", - header: str(GetTranslation("validation.custom.name")).ucFirst().value(), - cell: ({ value }: { value: TranslationField }) => ( - - ), - }, - { - accessorKey: "url", - header: str(GetTranslation("validation.custom.url")).ucFirst().value(), - cell: ({ value }: { value: string }) => ( - - - - {value} - - - {GetTranslation("back.access_url")} - - ), - }, - { - accessorKey: "gitlab_id", - header: str(GetTranslation("validation.custom.gitlab_id")) - .ucFirst() - .value(), - cell: ({ value }: { value: number }) => value, - }, - { - accessorKey: "created_at", - header: str( - GetTranslation("uwil-backend::validation.attributes.created_at"), - ) - .ucFirst() - .value(), - cell: ({ value }: { value: string }) => ( - {GetFormatedDate(value)} - ), - }, - { - accessorKey: "updated_at", - header: str( - GetTranslation("uwil-backend::validation.attributes.updated_at"), - ) - .ucFirst() - .value(), - cell: ({ value }: { value: string }) => ( - {GetFormatedDate(value)} - ), - }, - { - accessorKey: "deleted_at", - header: str( - GetTranslation("uwil-backend::validation.attributes.deleted_at"), - ) - .ucFirst() - .value(), - cell: ({ value }: { value: string }) => ( - {GetFormatedDate(value)} - ), - }, - ]; -}; - -export default function Show({ - data, - modelName, -}: { - data: SingleResource; - modelName: string; -}) { - const { auth, appEnv } = usePage().props as unknown as { - auth: AuthProp; - appEnv: AppEnv; - }; - const { viewAny } = auth.policies.gitlabProjects; - const model = data.data as GitlabProjectModel; - const actionModels = [Views.EDITION, Views.DUPLICATION, Views.ARCHIVATION]; - const transTitle = useTrans( - "uwil-backend::crud.helpers.visualization_model", - { - params: { - model: useTrans(`models.classes.${modelName}`, { - choice: 1, - }), - }, - }, - ); - const columns = getColumns(); - - // Translations. - const transCrudBackToList = useTrans("uwil-backend::back.crud_back_to_list"); - - const beforeNode = () => { - return ( - viewAny && ( -
- } - tooltipContent={

{transCrudBackToList}

} - /> -
- ) - ); - }; - - return ( - - - {/* @ts-expect-error Weird error type on cell. */} - - - ); -} diff --git a/resources/ts/back/types/project.d.ts b/resources/ts/back/types/project.d.ts index db9dece..ffc8792 100644 --- a/resources/ts/back/types/project.d.ts +++ b/resources/ts/back/types/project.d.ts @@ -32,6 +32,27 @@ type GitlabProjectModel = DefaultModel & { gitlab_id: number; }; +type GitlabLabelModel = DefaultModel & { + name: TranslationField; + gitlab_id: number; +} + +type GitlabIssueModel = DefaultModel & { + title: TranslationField; + url: string; + estimate_time: number; + spent_time: number; + is_closed: boolean; + gitlab_id: number; + gitlab_iid: number; + milestone_iid: number; + gitlab_project_id: number; + g_created_at: Date; + g_updated_at: Date; + g_closed_at: Date|null; + g_due_date: Date|null; +} + type SiteModel = DefaultModel & { name: TranslationField; url_re7: string; diff --git a/routes/back/gitlab-projects.php b/routes/back/gitlab-projects.php deleted file mode 100644 index b4d49b7..0000000 --- a/routes/back/gitlab-projects.php +++ /dev/null @@ -1,14 +0,0 @@ -name('gitlab-projects.trash'); -Route::patch('/gitlab-projects/{gitlab_project}/restore', [GitlabProjectController::class, 'restore']) - ->name('gitlab-projects.restore'); -Route::delete('/gitlab-projects/{gitlab_project}/force', [GitlabProjectController::class, 'forceDestroy']) - ->name('gitlab-projects.forceDestroy'); -Route::resource('gitlab-projects', GitlabProjectController::class); -Route::get('/gitlab-projects/{gitlab_project}/duplicate', [GitlabProjectController::class, 'duplicate']) - ->name('gitlab-projects.duplicate'); diff --git a/routes/breadcrumbs/gitlab-projects.php b/routes/breadcrumbs/gitlab-projects.php deleted file mode 100644 index 090df59..0000000 --- a/routes/breadcrumbs/gitlab-projects.php +++ /dev/null @@ -1,49 +0,0 @@ -parent("{$routeName}dashboard.index"); - $trail->push( - Str::ucfirst(trans_choice('models.classes.gitlab-projects', \INF)), - route("{$routeName}gitlab-projects.index") - ); -}); -Breadcrumbs::for("{$routeName}gitlab-projects.create", function (Generator $trail) use ($routeName) { - $trail->parent("{$routeName}gitlab-projects.index"); - $trail->push( - Str::ucfirst(trans('uwil-backend::crud.actions.create')), - route("{$routeName}gitlab-projects.create"), - ); -}); -Breadcrumbs::for("{$routeName}gitlab-projects.edit", function (Generator $trail) use ($routeName) { - $trail->parent("{$routeName}gitlab-projects.index"); - $trail->push( - Str::ucfirst(trans('uwil-backend::crud.actions.edit')), - route("{$routeName}gitlab-projects.edit", [ - 'gitlab_project' => request()->gitlab_project, - ]) - ); -}); -Breadcrumbs::for("{$routeName}gitlab-projects.duplicate", function (Generator $trail) use ($routeName) { - $trail->parent("{$routeName}gitlab-projects.index"); - $trail->push(Str::ucfirst(trans('uwil-backend::crud.actions.duplicate'))); -}); -Breadcrumbs::for("{$routeName}gitlab-projects.show", function (Generator $trail) use ($routeName) { - $trail->parent("{$routeName}gitlab-projects.index"); - $trail->push( - Str::ucfirst(trans('uwil-backend::crud.actions.visualize')), - route("{$routeName}gitlab-projects.show", [ - 'gitlab_project' => request()->gitlab_project, - ]), - ); -}); -Breadcrumbs::for("{$routeName}gitlab-projects.trash", function (Generator $trail) use ($routeName) { - $trail->parent("{$routeName}gitlab-projects.index"); - $trail->push(Str::ucfirst(trans('uwil-backend::back.archives'))); -});