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-299]: Enable/Disable Knowledge Management Portal #501

Merged
merged 4 commits into from
Feb 8, 2024
Merged
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
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,14 @@ public function up(): void

$this->migrator->add('portal.footer_color');
$this->migrator->add('portal.footer_copyright_statement');

/**
* Knowledge Base Portal
*/
$this->migrator->add('portal.knowledge_base_portal_enabled', false);
$this->migrator->add('portal.knowledge_base_portal_service_management', false);
$this->migrator->add('portal.knowledge_base_portal_primary_color');
$this->migrator->add('portal.knowledge_base_portal_rounding');
$this->migrator->add('portal.knowledge_base_portal_authorized_domain');
}
};
54 changes: 53 additions & 1 deletion app-modules/portal/src/Filament/Pages/ManagePortalSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,22 @@

use App\Models\User;
use App\Enums\Feature;
use Filament\Forms\Get;
use Filament\Forms\Form;
use App\Models\SettingsProperty;
use Filament\Pages\SettingsPage;
use AdvisingApp\Form\Enums\Rounding;
use Illuminate\Support\Facades\Gate;
use App\Filament\Fields\TiptapEditor;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\Actions;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\TextInput;
use App\Filament\Clusters\GlobalSettings;
use Filament\Forms\Components\ColorPicker;
use FilamentTiptapEditor\Enums\TiptapOutput;
use Filament\Forms\Components\Actions\Action;
use AdvisingApp\Portal\Settings\PortalSettings;
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;

Expand Down Expand Up @@ -94,7 +100,7 @@ public function form(Form $form): Form
->hexColor(),
])
->columns(2),
Section::make('Features')
Section::make('CRM Portal')
->schema([
Toggle::make('has_applications')
->label('Applications'),
Expand Down Expand Up @@ -139,6 +145,52 @@ public function form(Form $form): Form
->hintIconTooltip('Surveys are not a part of your current subscription.'),
])
->columns(3),
Section::make('Knowledge Portal')
->schema([
Toggle::make('knowledge_base_portal_enabled')
->label('Knowledge Management')
->disabled(! Gate::check(Feature::KnowledgeManagement->getGateName()))
->hintIcon(fn (Toggle $component) => $component->isDisabled() ? 'heroicon-m-lock-closed' : null)
->hintIconTooltip('Knowledge Management is not a part of your current subscription.')
->live()
->columnSpanFull(),
ColorPicker::make('knowledge_base_portal_primary_color')
->label('Primary Color')
->hexColor()
->visible(fn (Get $get) => $get('knowledge_base_portal_enabled'))
->columnSpan(1),
Select::make('knowledge_base_portal_rounding')
->label('Rounding')
->options(Rounding::class)
->visible(fn (Get $get) => $get('knowledge_base_portal_enabled'))
->columnSpan(1),
TextInput::make('knowledge_base_portal_authorized_domain')
->label('Authorized Domain')
->url()
->visible(fn (Get $get) => $get('knowledge_base_portal_enabled'))
->columnSpanFull(),
Toggle::make('knowledge_base_portal_service_management')
->label('Service Management')
->visible(fn (Get $get) => $get('knowledge_base_portal_enabled'))
->disabled(! Gate::check(Feature::ServiceManagement->getGateName()))
->hintIcon(fn (Toggle $component) => $component->isDisabled() ? 'heroicon-m-lock-closed' : null),
Orrison marked this conversation as resolved.
Show resolved Hide resolved
Actions::make([
Action::make('view')
->icon('heroicon-o-eye')
->action(function () {}),
Action::make('embed_snippet')
->label('Embed Snippet')
->action(function () {}),
])
->visible(
fn (Get $get) => $get('knowledge_base_portal_enabled') &&
! is_null($get('knowledge_base_portal_primary_color')) &&
! is_null($get('knowledge_base_portal_rounding')) &&
! is_null($get('knowledge_base_portal_authorized_domain'))
)
->columnSpanFull(),
])->columns(2),

Section::make('Footer')
->schema([
ColorPicker::make('footer_color')
Expand Down
13 changes: 13 additions & 0 deletions app-modules/portal/src/Settings/PortalSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@ class PortalSettings extends Settings

public ?string $footer_copyright_statement;

/**
* Knowledge Base Portal
*/
public bool $knowledge_base_portal_enabled = false;

public bool $knowledge_base_portal_service_management = false;

public ?string $knowledge_base_portal_primary_color = null;

public ?string $knowledge_base_portal_rounding = null;

public ?string $knowledge_base_portal_authorized_domain = null;

public static function group(): string
{
return 'portal';
Expand Down