new helpdesk module
This commit is contained in:
@@ -10,10 +10,12 @@ use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Component;
|
||||
use Modules\Helpdesk\Models\Category;
|
||||
use Modules\Helpdesk\Models\GitRepository;
|
||||
use Modules\Helpdesk\Models\Priority;
|
||||
use Modules\Helpdesk\Models\Project;
|
||||
use Modules\Helpdesk\Models\Status;
|
||||
use Modules\Helpdesk\Models\Team;
|
||||
use Modules\Helpdesk\Models\WorkflowTemplate;
|
||||
|
||||
final class SettingsManager extends Component
|
||||
{
|
||||
@@ -34,6 +36,12 @@ final class SettingsManager extends Component
|
||||
/** @var array<string, mixed> */
|
||||
public array $projectForm = ['id' => null, 'company_id' => null, 'team_id' => null, 'title' => '', 'slug' => '', 'color' => 'blue', 'description' => '', 'archived_at' => null];
|
||||
|
||||
/** @var array<string, mixed> */
|
||||
public array $repositoryForm = ['id' => null, 'company_id' => null, 'project_id' => null, 'name' => '', 'provider' => 'git', 'remote_url' => '', 'default_branch' => 'main', 'webhook_secret' => ''];
|
||||
|
||||
/** @var array<string, mixed> */
|
||||
public array $workflowForm = ['id' => null, 'name' => '', 'event' => 'ticket.created', 'subject' => '', 'html_body' => '', 'text_body' => '', 'to_role' => 'requester', 'cc' => '', 'bcc' => '', 'is_active' => true];
|
||||
|
||||
/** @return void */
|
||||
public function saveStatus(): void
|
||||
{
|
||||
@@ -219,6 +227,86 @@ final class SettingsManager extends Component
|
||||
$this->projectForm = ['id' => null, 'company_id' => null, 'team_id' => null, 'title' => '', 'slug' => '', 'color' => 'blue', 'description' => '', 'archived_at' => null];
|
||||
}
|
||||
|
||||
|
||||
/** @return void */
|
||||
public function saveRepository(): void
|
||||
{
|
||||
$data = $this->validate([
|
||||
'repositoryForm.company_id' => ['nullable', 'integer'],
|
||||
'repositoryForm.project_id' => ['nullable', 'integer', 'exists:helpdesk_projects,id'],
|
||||
'repositoryForm.name' => ['required', 'string', 'max:160'],
|
||||
'repositoryForm.provider' => ['required', 'string', 'max:40'],
|
||||
'repositoryForm.remote_url' => ['required', 'string', 'max:500'],
|
||||
'repositoryForm.default_branch' => ['required', 'string', 'max:120'],
|
||||
'repositoryForm.webhook_secret' => ['nullable', 'string', 'max:120'],
|
||||
])['repositoryForm'];
|
||||
|
||||
GitRepository::query()->updateOrCreate(['id' => $this->repositoryForm['id']], $data);
|
||||
$this->resetRepositoryForm();
|
||||
session()->flash('success', 'Git repository saved.');
|
||||
}
|
||||
|
||||
/** @return void */
|
||||
public function editRepository(int $id): void
|
||||
{
|
||||
$this->repositoryForm = GitRepository::query()->findOrFail($id)->only(['id', 'company_id', 'project_id', 'name', 'provider', 'remote_url', 'default_branch', 'webhook_secret']);
|
||||
$this->section = 'git';
|
||||
}
|
||||
|
||||
/** @return void */
|
||||
public function deleteRepository(int $id): void
|
||||
{
|
||||
GitRepository::query()->findOrFail($id)->delete();
|
||||
session()->flash('success', 'Git repository deleted.');
|
||||
}
|
||||
|
||||
/** @return void */
|
||||
public function resetRepositoryForm(): void
|
||||
{
|
||||
$this->repositoryForm = ['id' => null, 'company_id' => null, 'project_id' => null, 'name' => '', 'provider' => 'git', 'remote_url' => '', 'default_branch' => 'main', 'webhook_secret' => ''];
|
||||
}
|
||||
|
||||
|
||||
/** @return void */
|
||||
public function saveWorkflowTemplate(): void
|
||||
{
|
||||
$data = $this->validate([
|
||||
'workflowForm.name' => ['required', 'string', 'max:160'],
|
||||
'workflowForm.event' => ['required', 'string', 'max:80'],
|
||||
'workflowForm.subject' => ['required', 'string', 'max:220'],
|
||||
'workflowForm.html_body' => ['required', 'string'],
|
||||
'workflowForm.text_body' => ['nullable', 'string'],
|
||||
'workflowForm.to_role' => ['required', 'string', 'max:40'],
|
||||
'workflowForm.cc' => ['nullable', 'string', 'max:500'],
|
||||
'workflowForm.bcc' => ['nullable', 'string', 'max:500'],
|
||||
'workflowForm.is_active' => ['boolean'],
|
||||
])['workflowForm'];
|
||||
|
||||
WorkflowTemplate::query()->updateOrCreate(['id' => $this->workflowForm['id']], $data);
|
||||
$this->resetWorkflowTemplateForm();
|
||||
session()->flash('success', 'Workflow message saved.');
|
||||
}
|
||||
|
||||
/** @return void */
|
||||
public function editWorkflowTemplate(int $id): void
|
||||
{
|
||||
$this->workflowForm = WorkflowTemplate::query()->findOrFail($id)->only(['id', 'name', 'event', 'subject', 'html_body', 'text_body', 'to_role', 'cc', 'bcc', 'is_active']);
|
||||
$this->section = 'workflow';
|
||||
}
|
||||
|
||||
/** @return void */
|
||||
public function deleteWorkflowTemplate(int $id): void
|
||||
{
|
||||
WorkflowTemplate::query()->findOrFail($id)->delete();
|
||||
session()->flash('success', 'Workflow message deleted.');
|
||||
}
|
||||
|
||||
/** @return void */
|
||||
public function resetWorkflowTemplateForm(): void
|
||||
{
|
||||
$this->workflowForm = ['id' => null, 'name' => '', 'event' => 'ticket.created', 'subject' => '', 'html_body' => '', 'text_body' => '', 'to_role' => 'requester', 'cc' => '', 'bcc' => '', 'is_active' => true];
|
||||
}
|
||||
|
||||
/** @return View */
|
||||
public function render(): View
|
||||
{
|
||||
@@ -229,6 +317,8 @@ final class SettingsManager extends Component
|
||||
'categories' => Category::query()->withCount('tickets')->orderBy('name')->get(),
|
||||
'teams' => Team::query()->withCount(['projects', 'tickets'])->orderBy('name')->get(),
|
||||
'projects' => Project::query()->with(['team'])->withCount('tickets')->orderBy('title')->get(),
|
||||
'repositories' => GitRepository::query()->with(['project'])->withCount('commits')->orderBy('name')->get(),
|
||||
'workflowTemplates' => WorkflowTemplate::query()->orderBy('event')->orderBy('name')->get(),
|
||||
])->layout('layouts.app');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user