settings updates
This commit is contained in:
@@ -73,7 +73,7 @@ final class KanbanBoard extends Component
|
||||
'last_activity_at' => now(),
|
||||
])->save();
|
||||
|
||||
$freshTicket = $ticket->fresh(['status', 'priority', 'category', 'project', 'team', 'product', 'tags', 'checklistItems', 'board']) ?? $ticket;
|
||||
$freshTicket = $ticket->fresh(['user:id,name,email', 'owner:id,name,email', 'agent:id,name,email', 'status', 'priority', 'category', 'project', 'team', 'product', 'tags', 'checklistItems', 'board']) ?? $ticket;
|
||||
|
||||
$workflow->dispatch(
|
||||
$freshTicket,
|
||||
@@ -81,12 +81,12 @@ final class KanbanBoard extends Component
|
||||
Auth::user(),
|
||||
);
|
||||
|
||||
$message = 'Ticket ' . $freshTicket->reference . ' moved from ' . $oldStatusName . ' to ' . $status->name . '.';
|
||||
$message = 'Ticket '.$freshTicket->reference.' moved from '.$oldStatusName.' to '.$status->name.'.';
|
||||
session()->flash('success', $message);
|
||||
|
||||
$this->refreshBoard();
|
||||
$this->dispatch('helpdesk-kanban-moved', ticketId: (int) $freshTicket->id, statusId: (int) $freshTicket->status_id);
|
||||
$this->dispatch('helpdesk:toast', type: 'success', title: 'Ticket moved', message: $message);
|
||||
$this->dispatch('thredary:toast', type: 'success', title: 'Ticket moved', message: $message);
|
||||
} finally {
|
||||
$this->isMovingTicket = false;
|
||||
}
|
||||
@@ -121,15 +121,15 @@ final class KanbanBoard extends Component
|
||||
|
||||
$this->board_id = $board->id;
|
||||
|
||||
$fresh = $ticket->fresh(['status', 'priority', 'category', 'project', 'team', 'board']) ?? $ticket;
|
||||
$fresh = $ticket->fresh(['user:id,name,email', 'owner:id,name,email', 'agent:id,name,email', 'status', 'priority', 'category', 'project', 'team', 'board']) ?? $ticket;
|
||||
$workflow->dispatch($fresh, 'ticket.updated', Auth::user());
|
||||
|
||||
$message = 'Ticket ' . $fresh->reference . ' moved from ' . $oldBoardName . ' to ' . $board->name . '.';
|
||||
$message = 'Ticket '.$fresh->reference.' moved from '.$oldBoardName.' to '.$board->name.'.';
|
||||
session()->flash('success', $message);
|
||||
|
||||
$this->refreshBoard();
|
||||
$this->dispatch('helpdesk-kanban-moved', ticketId: (int) $fresh->id, statusId: (int) $fresh->status_id);
|
||||
$this->dispatch('helpdesk:toast', type: 'success', title: 'Board changed', message: $message);
|
||||
$this->dispatch('thredary:toast', type: 'success', title: 'Board changed', message: $message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,7 +191,7 @@ final class KanbanBoard extends Component
|
||||
'statuses' => $board?->statuses ?? collect(),
|
||||
'ticketsByStatus' => $this->ticketsByStatus($board),
|
||||
'refreshNonce' => $this->refreshNonce,
|
||||
])->layout('layouts.app', ['title' => __('Helpdesk Kanban')]);
|
||||
])->layout('layouts.app');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,7 +234,7 @@ final class KanbanBoard extends Component
|
||||
/**
|
||||
* Resolve the selected board from an already-loaded board collection.
|
||||
*
|
||||
* @param Collection<int, KanbanBoardModel> $boards
|
||||
* @param Collection<int, KanbanBoardModel> $boards
|
||||
*/
|
||||
private function resolveSelectedBoard(Collection $boards): ?KanbanBoardModel
|
||||
{
|
||||
|
||||
@@ -718,7 +718,7 @@ final class SettingsManager extends Component
|
||||
'tags' => Tag::query()->orderBy('name')->get(),
|
||||
'checklistTemplates' => ChecklistTemplate::query()->orderBy('name')->get(),
|
||||
'colourOptions' => Color::options(),
|
||||
])->layout('layouts.app', ['title' => __('Helpdesk Settings')]);
|
||||
])->layout('layouts.app');
|
||||
}
|
||||
|
||||
private function orderedStatuses(): mixed
|
||||
|
||||
@@ -146,7 +146,7 @@ final class TicketCreate extends Component
|
||||
'projects' => $this->projectOptions(),
|
||||
'products' => Product::query()->where('is_active', true)->orderBy('name')->get(),
|
||||
'tags' => Tag::query()->orderBy('name')->get(),
|
||||
])->layout('layouts.app', ['title' => __('Create Helpdesk Ticket')]);
|
||||
])->layout('layouts.app');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -198,7 +198,7 @@ final class TicketEdit extends Component
|
||||
'products' => Product::query()->where('is_active', true)->orderBy('name')->get(),
|
||||
'tags' => Tag::query()->orderBy('name')->get(),
|
||||
'agents' => $this->agentOptions(),
|
||||
])->layout('layouts.app', ['title' => __('Edit Helpdesk Ticket')]);
|
||||
])->layout('layouts.app');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -105,7 +105,7 @@ final class TicketIndex extends Component
|
||||
'tickets' => $this->tickets(),
|
||||
'statuses' => Status::query()->orderBy('sort_order')->get(),
|
||||
'priorities' => Priority::query()->orderBy('sort_order')->get(),
|
||||
])->layout('layouts.app', ['title' => __('Helpdesk Tickets')]);
|
||||
])->layout('layouts.app');
|
||||
}
|
||||
|
||||
private function resetTicketDeletionState(): void
|
||||
|
||||
@@ -325,7 +325,7 @@ final class TicketShow extends Component
|
||||
'priorities' => Priority::query()->orderBy('sort_order')->get(),
|
||||
'agents' => $this->agentOptions(),
|
||||
'cannedResponses' => CannedResponse::query()->where('is_active', true)->orderBy('sort_order')->orderBy('name')->get(),
|
||||
])->layout('layouts.app', ['title' => __('Helpdesk Ticket')]);
|
||||
])->layout('layouts.app');
|
||||
}
|
||||
|
||||
private function normaliseNullableInt(mixed $value): ?int
|
||||
|
||||
@@ -27,7 +27,7 @@ final class Ticket extends Model
|
||||
|
||||
protected $table = 'helpdesk_tickets';
|
||||
|
||||
protected $with = ['user'];
|
||||
protected $with = ['user', 'owner', 'agent'];
|
||||
|
||||
/** @var list<string> */
|
||||
protected $fillable = [
|
||||
@@ -194,11 +194,11 @@ final class Ticket extends Model
|
||||
/** @param Builder<Ticket> $query @return Builder<Ticket> */
|
||||
public function scopeVisibleTo(Builder $query, User $user): Builder
|
||||
{
|
||||
if ($user->isHelpdeskAdmin()) {
|
||||
if ($user->isAdmin() || (bool) ($user->helpdesk_admin ?? false)) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
if ($user->isHelpdeskAgent()) {
|
||||
if ((method_exists($user, 'isHelpdeskAgent') && $user->isHelpdeskAgent()) || (bool) ($user->helpdesk_agent ?? false)) {
|
||||
return $query->where(static function (Builder $subQuery) use ($user): void {
|
||||
$subQuery->where('agent_id', $user->id)->orWhere('user_id', $user->id);
|
||||
});
|
||||
|
||||
@@ -16,15 +16,10 @@ final class TicketPolicy
|
||||
|
||||
public function view(User $user, Ticket $ticket): bool
|
||||
{
|
||||
if ($this->isHelpdeskAdmin($user)) {
|
||||
if ($this->isAdmin($user) || $this->isAgent($user)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->isHelpdeskAgent($user)) {
|
||||
return (int) $ticket->agent_id === (int) $user->id
|
||||
|| (int) $ticket->user_id === (int) $user->id;
|
||||
}
|
||||
|
||||
return (int) $ticket->user_id === (int) $user->id;
|
||||
}
|
||||
|
||||
@@ -33,29 +28,13 @@ final class TicketPolicy
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helpdesk workflow updates.
|
||||
*
|
||||
* Admins can update every Helpdesk ticket.
|
||||
*
|
||||
* Agents can update any ticket that is visible to them under the Helpdesk
|
||||
* visibility rules. This is important for Kanban drag/drop: a card must
|
||||
* never be displayed as movable and then fail authorization on drop.
|
||||
*
|
||||
* Normal requesters cannot change workflow/status/assignment data.
|
||||
*/
|
||||
public function update(User $user, Ticket $ticket): bool
|
||||
{
|
||||
if ($this->isHelpdeskAdmin($user)) {
|
||||
if ($this->isAdmin($user) || $this->isAgent($user)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (! $this->isHelpdeskAgent($user)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (int) $ticket->agent_id === (int) $user->id
|
||||
|| (int) $ticket->user_id === (int) $user->id;
|
||||
return (int) $ticket->user_id === (int) $user->id;
|
||||
}
|
||||
|
||||
public function comment(User $user, Ticket $ticket): bool
|
||||
@@ -65,36 +44,20 @@ final class TicketPolicy
|
||||
|
||||
public function delete(User $user, Ticket $ticket): bool
|
||||
{
|
||||
return $this->isHelpdeskAdmin($user);
|
||||
return $this->isAdmin($user);
|
||||
}
|
||||
|
||||
private function isHelpdeskAdmin(User $user): bool
|
||||
private function isAdmin(User $user): bool
|
||||
{
|
||||
if (method_exists($user, 'isHelpdeskAdmin')) {
|
||||
return $user->isHelpdeskAdmin();
|
||||
}
|
||||
|
||||
if ((bool) ($user->helpdesk_admin ?? false)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (method_exists($user, 'isAdmin')) {
|
||||
return $user->isAdmin();
|
||||
}
|
||||
|
||||
if (method_exists($user, 'isMpbaPlatformAdmin')) {
|
||||
return $user->isMpbaPlatformAdmin();
|
||||
}
|
||||
|
||||
return false;
|
||||
return (method_exists($user, 'isHelpdeskAdmin') && $user->isHelpdeskAdmin())
|
||||
|| (bool) ($user->helpdesk_admin ?? false)
|
||||
|| (method_exists($user, 'isAdmin') && $user->isAdmin());
|
||||
}
|
||||
|
||||
private function isHelpdeskAgent(User $user): bool
|
||||
private function isAgent(User $user): bool
|
||||
{
|
||||
if (method_exists($user, 'isHelpdeskAgent')) {
|
||||
return $user->isHelpdeskAgent();
|
||||
}
|
||||
|
||||
return (bool) ($user->helpdesk_agent ?? false);
|
||||
return (method_exists($user, 'isHelpdeskAgent') && $user->isHelpdeskAgent())
|
||||
|| (bool) ($user->helpdesk_agent ?? false)
|
||||
|| (method_exists($user, 'isAgent') && $user->isAgent());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user