1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Module\Dashboard\DisplayPage\Service; |
4
|
|
|
|
5
|
|
|
use App\Application\Data\UserNetworkSessionData; |
6
|
|
|
use App\Module\Authorization\Service\AuthorizedByRoleChecker; |
|
|
|
|
7
|
|
|
use App\Module\Client\ClientStatus\Repository\ClientStatusFinderRepository; |
|
|
|
|
8
|
|
|
use App\Module\Dashboard\DisplayPage\Data\DashboardData; |
9
|
|
|
use App\Module\User\Enum\UserRole; |
10
|
|
|
|
11
|
|
|
final class DashboardPanelProvider |
12
|
|
|
{ |
13
|
|
|
private ?int $loggedInUserId = null; |
14
|
|
|
|
15
|
1 |
|
public function __construct( |
16
|
|
|
private readonly ClientStatusFinderRepository $clientStatusFinderRepository, |
17
|
|
|
private readonly AuthorizedByRoleChecker $authorizationChecker, |
18
|
|
|
private readonly UserFilterChipProvider $userFilterChipProvider, |
|
|
|
|
19
|
|
|
UserNetworkSessionData $userNetworkSessionData, |
20
|
|
|
) { |
21
|
1 |
|
$this->loggedInUserId = $userNetworkSessionData->userId; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Returns authorized dashboards. |
26
|
|
|
* |
27
|
|
|
* @return DashboardData[] |
28
|
|
|
*/ |
29
|
1 |
|
public function getAuthorizedDashboards(): array |
30
|
|
|
{ |
31
|
1 |
|
$authorizedDashboards = []; |
32
|
1 |
|
foreach ($this->getDashboards() as $dashboard) { |
33
|
1 |
|
if ($dashboard->authorized) { |
34
|
1 |
|
$authorizedDashboards[] = $dashboard; |
35
|
|
|
} |
36
|
|
|
} |
37
|
|
|
|
38
|
1 |
|
return $authorizedDashboards; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Returns default dashboards. |
43
|
|
|
* |
44
|
|
|
* @return DashboardData[] |
45
|
|
|
*/ |
46
|
1 |
|
private function getDashboards(): array |
47
|
|
|
{ |
48
|
1 |
|
$statusesMappedByNameId = array_flip( |
49
|
1 |
|
$this->clientStatusFinderRepository->findAllClientStatusesMappedByIdName(true) |
50
|
1 |
|
); |
51
|
|
|
|
52
|
|
|
// Basic client filters |
53
|
1 |
|
return [ |
54
|
|
|
// Category |
55
|
1 |
|
new DashboardData([ |
56
|
1 |
|
'title' => __('Unassigned clients'), |
57
|
1 |
|
'panelId' => 'unassigned-panel', |
58
|
1 |
|
'panelClass' => 'client-panel', |
59
|
1 |
|
'panelHtmlContent' => '<data data-param-name="user" data-param-value="" value=""></data> |
60
|
1 |
|
<div id="client-list-wrapper-unassigned" class="client-list-wrapper"></div>', |
61
|
1 |
|
'authorized' => $this->authorizationChecker->isAuthorizedByRole(UserRole::NEWCOMER), |
62
|
1 |
|
]), |
63
|
1 |
|
new DashboardData([ |
64
|
1 |
|
'title' => __('Clients assigned to me — action pending'), |
65
|
1 |
|
'panelId' => 'assigned-to-me-panel', |
66
|
1 |
|
'panelClass' => 'client-panel', |
67
|
1 |
|
'panelHtmlContent' => '<data data-param-name="user" data-param-value="' . $this->loggedInUserId . '" value=""></data> |
68
|
1 |
|
<data data-param-name="status" data-param-value="' . $statusesMappedByNameId['Action pending'] . '" value=""></data> |
69
|
1 |
|
<div id="client-list-wrapper-assigned-to-me" class="client-list-wrapper"></div>', |
70
|
1 |
|
'authorized' => $this->authorizationChecker->isAuthorizedByRole(UserRole::NEWCOMER), |
71
|
1 |
|
]), |
72
|
1 |
|
new DashboardData([ |
73
|
1 |
|
'title' => __('User activity'), |
74
|
1 |
|
'panelId' => 'user-activity-panel', |
75
|
1 |
|
'panelClass' => null, |
76
|
1 |
|
'panelHtmlContent' => $this->userFilterChipProvider->getUserFilterChipsHtml() . |
77
|
1 |
|
'<div id="user-activity-content"></div>', |
78
|
1 |
|
'authorized' => $this->authorizationChecker->isAuthorizedByRole( |
79
|
1 |
|
UserRole::MANAGING_ADVISOR |
80
|
1 |
|
), |
81
|
1 |
|
]), |
82
|
1 |
|
new DashboardData([ |
83
|
1 |
|
'title' => __('New notes'), |
84
|
1 |
|
'panelId' => 'new-notes-panel', |
85
|
1 |
|
'panelClass' => 'note-panel', |
86
|
1 |
|
'panelHtmlContent' => '<data data-param-name="most-recent" data-param-value="10" value=""></data> |
87
|
1 |
|
<div id="note-wrapper-most-recent" class="client-note-wrapper"></div>', |
88
|
1 |
|
'authorized' => $this->authorizationChecker->isAuthorizedByRole(UserRole::MANAGING_ADVISOR), |
89
|
1 |
|
]), |
90
|
1 |
|
new DashboardData([ |
91
|
1 |
|
'title' => __('Recently assigned clients'), |
92
|
1 |
|
'panelId' => 'recently-assigned-panel', |
93
|
1 |
|
'panelClass' => 'client-panel', |
94
|
1 |
|
'panelHtmlContent' => '<data data-param-name="recently-assigned" data-param-value="1" value=""></data> |
95
|
1 |
|
<div id="client-list-wrapper-recently-assigned" class="client-list-wrapper"></div>', |
96
|
1 |
|
'authorized' => $this->authorizationChecker->isAuthorizedByRole( |
97
|
1 |
|
UserRole::MANAGING_ADVISOR |
98
|
1 |
|
), |
99
|
1 |
|
]), |
100
|
1 |
|
]; |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths