Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADVAPP-1142]: Improve Product Administration display settings based on licensing restrictions #1252

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app-modules/alert/src/Policies/AlertStatusPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,22 @@
namespace AdvisingApp\Alert\Policies;

use AdvisingApp\Alert\Models\AlertStatus;
use AdvisingApp\Prospect\Models\Prospect;
use AdvisingApp\StudentDataModel\Models\Student;
use App\Models\Authenticatable;
use Illuminate\Auth\Access\Response;

class AlertStatusPolicy
{
public function before(Authenticatable $authenticatable): ?Response
{
if (! $authenticatable->hasAnyLicense([Student::getLicenseType(), Prospect::getLicenseType()])) {
return Response::deny('You are not licensed for the Retention or Recruitment CRM.');
}

return null;
}

public function viewAny(Authenticatable $authenticatable): Response
{
return $authenticatable->canOrElse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
namespace AdvisingApp\BasicNeeds\Policies;

use AdvisingApp\BasicNeeds\Models\BasicNeedsCategory;
use AdvisingApp\Prospect\Models\Prospect;
use AdvisingApp\StudentDataModel\Models\Student;
use App\Models\Authenticatable;
use Illuminate\Auth\Access\Response;
Expand All @@ -45,8 +46,8 @@ class BasicNeedsCategoryPolicy
{
public function before(Authenticatable $authenticatable): ?Response
{
if (! $authenticatable->hasLicense(Student::getLicenseType())) {
return Response::deny('You are not licensed for the Retention CRM.');
if (! $authenticatable->hasAnyLicense([Student::getLicenseType(), Prospect::getLicenseType()])) {
return Response::deny('You are not licensed for the Retention or Recruitment CRM.');
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
namespace AdvisingApp\BasicNeeds\Policies;

use AdvisingApp\BasicNeeds\Models\BasicNeedsProgram;
use AdvisingApp\Prospect\Models\Prospect;
use AdvisingApp\StudentDataModel\Models\Student;
use App\Models\Authenticatable;
use Illuminate\Auth\Access\Response;
Expand All @@ -45,8 +46,8 @@ class BasicNeedsProgramPolicy
{
public function before(Authenticatable $authenticatable): ?Response
{
if (! $authenticatable->hasLicense(Student::getLicenseType())) {
return Response::deny('You are not licensed for the Retention CRM.');
if (! $authenticatable->hasAnyLicense([Student::getLicenseType(), Prospect::getLicenseType()])) {
return Response::deny('You are not licensed for the Retention or Recruitment CRM.');
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

namespace AdvisingApp\Engagement\Filament\Resources;

use AdvisingApp\Authorization\Enums\LicenseType;
use AdvisingApp\Engagement\Filament\Resources\EmailTemplateResource\Pages\CreateEmailTemplate;
use AdvisingApp\Engagement\Filament\Resources\EmailTemplateResource\Pages\EditEmailTemplate;
use AdvisingApp\Engagement\Filament\Resources\EmailTemplateResource\Pages\ListEmailTemplates;
Expand All @@ -53,6 +54,14 @@ class EmailTemplateResource extends Resource

protected static ?string $cluster = Communication::class;

public static function canAccess(): bool
{
/** @var User $user */
$user = auth()->user();

return $user->hasAnyLicense([LicenseType::RetentionCrm, LicenseType::RecruitmentCrm]);
}

public static function getPages(): array
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

namespace AdvisingApp\Engagement\Filament\Resources;

use AdvisingApp\Authorization\Enums\LicenseType;
use AdvisingApp\Engagement\Filament\Resources\SmsTemplateResource\Pages\CreateSmsTemplate;
use AdvisingApp\Engagement\Filament\Resources\SmsTemplateResource\Pages\EditSmsTemplate;
use AdvisingApp\Engagement\Filament\Resources\SmsTemplateResource\Pages\ListSmsTemplates;
Expand All @@ -57,6 +58,14 @@ class SmsTemplateResource extends Resource

protected static ?string $cluster = Communication::class;

public static function canAccess(): bool
{
/** @var User $user */
$user = auth()->user();

return $user->hasAnyLicense([LicenseType::RetentionCrm, LicenseType::RecruitmentCrm]);
}

public static function getPages(): array
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

namespace AdvisingApp\Prospect\Filament\Pages;

use AdvisingApp\Prospect\Models\Prospect;
use App\Filament\Clusters\ConstituentManagement;
use App\Filament\Forms\Components\Heading;
use App\Filament\Forms\Components\Paragraph;
Expand Down Expand Up @@ -67,6 +68,10 @@ public static function canAccess(): bool
/** @var User $user */
$user = auth()->user();

if (! $user->hasLicense(Prospect::getLicenseType())) {
return false;
}

return $user->can(['product_admin.view-any']);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
namespace AdvisingApp\Prospect\Filament\Pages;

use AdvisingApp\Prospect\Filament\Resources\ProspectResource;
use AdvisingApp\Prospect\Models\Prospect;
use AdvisingApp\Prospect\Settings\ProspectPipelineSettings;
use App\Features\PipelineFlag;
use App\Filament\Clusters\ConstituentManagement;
Expand All @@ -53,7 +54,7 @@ class ManageProspectPipelineSettings extends SettingsPage

protected static ?string $cluster = ConstituentManagement::class;

protected static ?string $navigationGroup = 'Prospect Management';
protected static ?string $navigationGroup = 'Prospects';

protected static string $settings = ProspectPipelineSettings::class;

Expand All @@ -66,6 +67,10 @@ public static function canAccess(): bool
/** @var User $user */
$user = auth()->user();

if (! $user->hasLicense(Prospect::getLicenseType())) {
return false;
}

return PipelineFlag::active() && $user->can(['product_admin.view-any']);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
use AdvisingApp\Prospect\Filament\Resources\ProspectTagResource\Pages\EditProspectTag;
use AdvisingApp\Prospect\Filament\Resources\ProspectTagResource\Pages\ListProspectTags;
use AdvisingApp\Prospect\Filament\Resources\ProspectTagResource\Pages\ViewProspectTag;
use AdvisingApp\Prospect\Models\Prospect;
use App\Enums\TagType;
use App\Filament\Clusters\ConstituentManagement;
use App\Models\Tag;
Expand All @@ -60,6 +61,14 @@ class ProspectTagResource extends Resource

protected static ?string $navigationGroup = 'Prospects';

public static function canAccess(): bool
{
/** @var User $user */
$user = auth()->user();

return $user->hasLicense(Prospect::getLicenseType());
}

public static function getPages(): array
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

namespace AdvisingApp\StudentDataModel\Filament\Pages;

use AdvisingApp\StudentDataModel\Models\Student;
use AdvisingApp\StudentDataModel\Settings\ManageStudentConfigurationSettings;
use App\Filament\Clusters\ConstituentManagement;
use App\Models\User;
Expand All @@ -60,6 +61,10 @@ public static function canAccess(): bool
/** @var User $user */
$user = auth()->user();

if (! $user->hasLicense(Student::getLicenseType())) {
return false;
}

return $user->can(['product_admin.view-any']);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
use AdvisingApp\StudentDataModel\Filament\Resources\StudentTagResource\Pages\EditStudentTag;
use AdvisingApp\StudentDataModel\Filament\Resources\StudentTagResource\Pages\ListStudentTags;
use AdvisingApp\StudentDataModel\Filament\Resources\StudentTagResource\Pages\ViewStudentTag;
use AdvisingApp\StudentDataModel\Models\Student;
use App\Enums\TagType;
use App\Filament\Clusters\ConstituentManagement;
use App\Models\Tag;
Expand All @@ -60,6 +61,14 @@ class StudentTagResource extends Resource

protected static ?string $navigationGroup = 'Students';

public static function canAccess(): bool
{
/** @var User $user */
$user = auth()->user();

return $user->hasLicense(Student::getLicenseType());
}

public static function getPages(): array
{
return [
Expand Down