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-1077]: Relocate Institutional Assistant and Integrated Assistant to new Artificial Intelligence menu item in Global Administration #1206

Merged
merged 9 commits into from
Jan 2, 2025
Orrison marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
use AdvisingApp\Ai\Models\AiAssistant;
use AdvisingApp\Ai\Settings\AiIntegratedAssistantSettings;
use AdvisingApp\Authorization\Enums\LicenseType;
use App\Filament\Clusters\ArtificialIntelligence;
use App\Filament\Clusters\GlobalArtificialIntelligence;
use App\Models\User;
use Filament\Forms\Components\Select;
use Filament\Forms\Form;
Expand All @@ -56,11 +56,11 @@ class ManageAiIntegratedAssistantSettings extends SettingsPage

protected static ?string $title = 'Integrated Assistant';

protected static ?string $cluster = ArtificialIntelligence::class;
protected static ?string $cluster = GlobalArtificialIntelligence::class;

protected static ?string $navigationIcon = 'heroicon-o-cube-transparent';

protected static ?int $navigationSort = 40;
protected static ?int $navigationSort = 20;

public static function canAccess(): bool
{
Expand All @@ -71,7 +71,7 @@ public static function canAccess(): bool
return false;
}

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

public function form(Form $form): Form
Expand All @@ -86,12 +86,12 @@ public function form(Form $form): Form
->helperText('Used for general purposes like generating content when an assistant is not being used.')
->required(),
])
->disabled(! auth()->user()->can('product_admin.*.update'));
->disabled(! auth()->user()->isSuperAdmin());
}

public function save(): void
{
if (! auth()->user()->can('product_admin.*.update')) {
if (! auth()->user()->isSuperAdmin()) {
return;
}

Expand All @@ -103,7 +103,7 @@ public function save(): void
*/
public function getFormActions(): array
{
if (! auth()->user()->can('product_admin.*.update')) {
if (! auth()->user()->isSuperAdmin()) {
return [];
}

Expand Down
14 changes: 7 additions & 7 deletions app-modules/ai/src/Filament/Pages/ManageAiSettings.php
Orrison marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
use AdvisingApp\Ai\Models\AiAssistant;
use AdvisingApp\Ai\Settings\AiSettings;
use AdvisingApp\Authorization\Enums\LicenseType;
use App\Filament\Clusters\ArtificialIntelligence;
use App\Filament\Clusters\GlobalArtificialIntelligence;
use App\Filament\Forms\Components\Slider;
use App\Models\User;
use Filament\Actions\Action;
Expand All @@ -69,11 +69,11 @@ class ManageAiSettings extends SettingsPage

protected static ?string $title = 'Institutional Assistant';

protected static ?string $cluster = ArtificialIntelligence::class;
protected static ?string $cluster = GlobalArtificialIntelligence::class;

protected static ?string $navigationIcon = 'heroicon-o-cog-6-tooth';

protected static ?int $navigationSort = 30;
protected static ?int $navigationSort = 10;

public static function canAccess(): bool
{
Expand All @@ -84,7 +84,7 @@ public static function canAccess(): bool
return false;
}

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

#[Computed]
Expand Down Expand Up @@ -145,7 +145,7 @@ public function form(Form $form): Form
->searchable()
->required(),
])
->disabled(! auth()->user()->can('product_admin.*.update'));
->disabled(! auth()->user()->isSuperAdmin());
}

public function getSaveFormAction(): Action
Expand Down Expand Up @@ -199,7 +199,7 @@ public function getSaveFormAction(): Action

public function save(): void
{
if (! auth()->user()->can('product_admin.*.update')) {
if (! auth()->user()->isSuperAdmin()) {
return;
}

Expand All @@ -211,7 +211,7 @@ public function save(): void
*/
public function getFormActions(): array
{
if (! auth()->user()->can('product_admin.*.update')) {
if (! auth()->user()->isSuperAdmin()) {
return [];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,6 @@
->assertStatus(403);
});

it('loads if you have the correct access to ai settings', function () {
$user = User::factory()->licensed(LicenseType::ConversationalAi)->create();

$user->givePermissionTo(['product_admin.view-any']);

actingAs($user);
Orrison marked this conversation as resolved.
Show resolved Hide resolved

Livewire::test(ManageAiSettings::class)
->assertStatus(200);
});

it('cannot access the page if assistant is default', function () {
$aiSettings = app(LicenseSettings::class);

Expand Down
48 changes: 48 additions & 0 deletions app/Filament/Clusters/GlobalArtificialIntelligence.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/*
<COPYRIGHT>

Copyright © 2016-2025, Canyon GBS LLC. All rights reserved.

Advising App™ is licensed under the Elastic License 2.0. For more details,
see https://github.com/canyongbs/advisingapp/blob/main/LICENSE.

Notice:

- You may not provide the software to third parties as a hosted or managed
service, where the service provides users with access to any substantial set of
the features or functionality of the software.
- You may not move, change, disable, or circumvent the license key functionality
in the software, and you may not remove or obscure any functionality in the
software that is protected by the license key.
- You may not alter, remove, or obscure any licensing, copyright, or other notices
of the licensor in the software. Any use of the licensor’s trademarks is subject
to applicable law.
- Canyon GBS LLC respects the intellectual property rights of others and expects the
same in return. Canyon GBS™ and Advising App™ are registered trademarks of
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
vigorously.
- The software solution, including services, infrastructure, and code, is offered as a
Software as a Service (SaaS) by Canyon GBS LLC.
- Use of this software implies agreement to the license terms and conditions as stated
in the Elastic License 2.0.

For more information or inquiries please visit our website at
https://www.canyongbs.com or contact us via email at [email protected].

</COPYRIGHT>
*/

namespace App\Filament\Clusters;

use Filament\Clusters\Cluster;

class GlobalArtificialIntelligence extends Cluster
{
protected static ?string $navigationGroup = 'Global Administration';

protected static ?int $navigationSort = 90;

protected static ?string $title = 'Artificial Intelligence';
}