From fbe829cd30863708b33c6b5bcdb446cc3a6e2df2 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 19 Nov 2024 18:10:12 +0100 Subject: [PATCH] wip #7193 @0.5 --- app/Models/FluidbookPublication.php | 5 +++ .../fluidbook_publication/preview.blade.php | 31 +++++++++++++------ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/app/Models/FluidbookPublication.php b/app/Models/FluidbookPublication.php index 8857d276e..f466277a9 100644 --- a/app/Models/FluidbookPublication.php +++ b/app/Models/FluidbookPublication.php @@ -1210,6 +1210,11 @@ class FluidbookPublication extends ToolboxStatusModel return parent::allowsPreview() && $this->getPagesNumber() > 0; } + public function allowsTesting() + { + return $this->allowsPreview() && can(static::$_permissionBase . ':admin'); + } + public static function getProtectedPath($id, $path) { return cache()->tags([FluidbookPublication::class])->rememberForever("fluidbook_protected_path_" . $id . '_' . $path, function () use ($id, $path) { diff --git a/resources/views/vendor/backpack/crud/buttons/fluidbook_publication/preview.blade.php b/resources/views/vendor/backpack/crud/buttons/fluidbook_publication/preview.blade.php index 8b46d4144..978e67f4a 100644 --- a/resources/views/vendor/backpack/crud/buttons/fluidbook_publication/preview.blade.php +++ b/resources/views/vendor/backpack/crud/buttons/fluidbook_publication/preview.blade.php @@ -2,20 +2,30 @@ @php $actions=[]; $suffixv3=''; -// if($entry->version==2){ -// $actions['compilev2']=['label'=>''.__('Compilateur V2').'','disabled'=>true,'url'=>'#']; -// $actions['preview_v2'] = ['label'=>__('Version online'),'url'=>'https://workshop.fluidbook.com/viewerh/'.$entry->getKey().'_'.$entry->hash,'target'=>'_blank']; -// if($entry->isSCORMEnabled()){ -// $actions['scorm_v2'] = ['label'=>__('Version SCORM'),'url'=>'https://workshop.fluidbook.com/viewers/'.$entry->getKey().'_'.$entry->hash,'target'=>'_blank']; -// } -// $actions['sep']='---------'; -// $actions['testv3']=['label'=>''.__('Tester le compilateur V3').'','disabled'=>true,'url'=>'#']; -// } - $actions['preview']=['label'=>__('Version online'),'url'=>$crud->route.'/preview/'.$entry->getKey().'_'.$entry->hash,'target'=>'_blank']; + $previewURL=$crud->route.'/preview/'.$entry->getKey().'_'.$entry->hash; + $actions['preview']=['label'=>__('Version online'),'url'=>$previewURL,'target'=>'_blank']; if($entry->isSCORMEnabled()){ $actions['scorm']=['label'=>__('Version SCORM'),'url'=>$crud->route.'/preview/scorm/'.$entry->getKey().'_'.$entry->hash,'target'=>'_blank']; } + if($entry->allowsTesting()){ + $defaults=['start'=>'true','zoom_to_fit'=>'true' ,'full_screen'=>'true','speed'=>'1','url'=>$previewURL]; + $tests=[ + 'iOS Safari'=>['os'=>'iOS','os_version'=>'17.0','device_browser'=>'safari'], + 'Android Chrome'=>['os'=>'android','os_version'=>'15.0','device'=>'Google Pixel 9','device_browser'=>'chrome'], + ]; + + $actions['sep_testing']='---------'; + foreach ($tests as $k=>$device) { + $url='https://live.browserstack.com/start#'.http_build_query(array_merge($defaults,$device)); + $actions['browserstack_'.\Cubist\Util\Str::snake($k)]= + [ + 'label'=>__('Tester sur :device',['device'=>$k]), + 'url'=>$url, + 'target'=>'_blank' + ]; + } + } @endphp @if($entry->allowsPreview()) @@ -30,3 +40,4 @@ title="{{__('Voir le fluidbook')}}"> {{__('Voir')}} @endif + -- 2.39.5