From f249bf3e3c8d432c4c3917923df4a4f82c8ca4d5 Mon Sep 17 00:00:00 2001 From: Derek Goetz Date: Mon, 3 Jun 2024 08:17:13 -0400 Subject: [PATCH 1/6] Add portal layout option. --- app-modules/portal/src/Enums/PortalLayout.php | 54 +++++++++++++++++++ .../Filament/Pages/ManagePortalSettings.php | 12 +++++ .../KnowledgeManagementPortalController.php | 2 + .../portal/src/Settings/PortalSettings.php | 2 + ...8_add_portal_layout_to_portal_settings.php | 20 +++++++ portals/knowledge-management/src/App.vue | 4 ++ 6 files changed, 94 insertions(+) create mode 100644 app-modules/portal/src/Enums/PortalLayout.php create mode 100644 database/settings/2024_06_02_012958_add_portal_layout_to_portal_settings.php diff --git a/app-modules/portal/src/Enums/PortalLayout.php b/app-modules/portal/src/Enums/PortalLayout.php new file mode 100644 index 000000000..055d03347 --- /dev/null +++ b/app-modules/portal/src/Enums/PortalLayout.php @@ -0,0 +1,54 @@ + + + Copyright © 2016-2024, Canyon GBS LLC. All rights reserved. + + Aiding App™ is licensed under the Elastic License 2.0. For more details, + see + + 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 Aiding 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 + or contact us via email at legal@canyongbs.com. + + +*/ + +namespace AidingApp\Portal\Enums; + +use Filament\Support\Contracts\HasLabel; + +enum PortalLayout: string implements HasLabel +{ + case Full = 'full'; + + case Fixed = 'fixed'; + + public function getLabel(): ?string + { + return match ($this) { + PortalLayout::Full => 'Full-Width', + PortalLayout::Fixed => 'Fixed-Width (Boxed Layout)', + }; + } +} diff --git a/app-modules/portal/src/Filament/Pages/ManagePortalSettings.php b/app-modules/portal/src/Filament/Pages/ManagePortalSettings.php index c98b046c9..bdf89828c 100644 --- a/app-modules/portal/src/Filament/Pages/ManagePortalSettings.php +++ b/app-modules/portal/src/Filament/Pages/ManagePortalSettings.php @@ -48,14 +48,17 @@ use AidingApp\Portal\Enums\PortalType; use Filament\Forms\Components\Actions; use Filament\Forms\Components\Section; +use AidingApp\Portal\Enums\PortalLayout; use Filament\Forms\Components\TextInput; use App\Filament\Clusters\GlobalSettings; use Filament\Forms\Components\ColorPicker; +use Filament\Forms\Components\ToggleButtons; use Filament\Infolists\Components\TextEntry; use FilamentTiptapEditor\Enums\TiptapOutput; use AidingApp\Portal\Settings\PortalSettings; use Filament\Forms\Components\Actions\Action; use App\Filament\Forms\Components\ColorSelect; +use Laravel\Pennant\Feature as PennantFeature; use App\Filament\Forms\Components\TiptapEditor; use AidingApp\Portal\Actions\GeneratePortalEmbedCode; @@ -94,6 +97,15 @@ public function form(Form $form): Form ->hintIconTooltip('Knowledge Management is not a part of your current subscription.') ->live() ->columnSpanFull(), + ToggleButtons::make('knowledge_management_portal_layout') + ->options(PortalLayout::class) + ->enum(PortalLayout::class) + ->visible(fn (Get $get) => PennantFeature::active('portal-configuration-options') & $get('knowledge_management_portal_enabled')) + ->disabled(! Gate::check(Feature::KnowledgeManagement->getGateName())) + ->hintIcon(fn (ToggleButtons $component) => $component->isDisabled() ? 'heroicon-m-lock-closed' : null) + ->hintIconTooltip('Knowledge Management is not a part of your current subscription.') + ->inline() + ->columnSpanFull(), ColorSelect::make('knowledge_management_portal_primary_color') ->label('Primary Color') ->visible(fn (Get $get) => $get('knowledge_management_portal_enabled')) diff --git a/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalController.php b/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalController.php index 77cab4b61..3a9498c1a 100644 --- a/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalController.php +++ b/app-modules/portal/src/Http/Controllers/KnowledgeManagementPortal/KnowledgeManagementPortalController.php @@ -40,6 +40,7 @@ use Filament\Support\Colors\Color; use Illuminate\Support\Facades\URL; use App\Http\Controllers\Controller; +use AidingApp\Portal\Enums\PortalLayout; use AidingApp\Portal\Settings\PortalSettings; class KnowledgeManagementPortalController extends Controller @@ -49,6 +50,7 @@ public function show(): JsonResponse $settings = resolve(PortalSettings::class); return response()->json([ + 'layout' => $settings->knowledge_management_portal_layout ?? PortalLayout::Full, 'primary_color' => Color::all()[$settings->knowledge_management_portal_primary_color ?? 'blue'], 'rounding' => $settings->knowledge_management_portal_rounding, 'requires_authentication' => $settings->knowledge_management_portal_requires_authentication, diff --git a/app-modules/portal/src/Settings/PortalSettings.php b/app-modules/portal/src/Settings/PortalSettings.php index cf180461e..ebde177ca 100644 --- a/app-modules/portal/src/Settings/PortalSettings.php +++ b/app-modules/portal/src/Settings/PortalSettings.php @@ -59,6 +59,8 @@ class PortalSettings extends Settings public ?string $knowledge_management_portal_authorized_domain = null; + public ?string $knowledge_management_portal_layout = null; + public static function group(): string { return 'portal'; diff --git a/database/settings/2024_06_02_012958_add_portal_layout_to_portal_settings.php b/database/settings/2024_06_02_012958_add_portal_layout_to_portal_settings.php new file mode 100644 index 000000000..5062bb847 --- /dev/null +++ b/database/settings/2024_06_02_012958_add_portal_layout_to_portal_settings.php @@ -0,0 +1,20 @@ +migrator->add('portal.knowledge_management_portal_layout', null); + + Feature::activate('portal-configuration-options'); + } + + public function down(): void + { + $this->migrator->delete('portal.knowledge_management_portal_layout'); + + Feature::deactivate('portal-configuration-options'); + } +}; diff --git a/portals/knowledge-management/src/App.vue b/portals/knowledge-management/src/App.vue index 90d27fc6a..211522b2c 100644 --- a/portals/knowledge-management/src/App.vue +++ b/portals/knowledge-management/src/App.vue @@ -80,6 +80,7 @@ const hasServiceManagement = ref(false); const showLogin = ref(false); + const portalLayout = ref(''); const portalPrimaryColor = ref(''); const portalRounding = ref(''); const categories = ref({}); @@ -153,6 +154,8 @@ portalPrimaryColor.value = response.data.primary_color; + portalLayout.value = response.data.layout; + setRequiresAuthentication(response.data.requires_authentication).then(() => { requiresAuthentication.value = response.data.requires_authentication; }); @@ -351,6 +354,7 @@