]> _ Git - fluidbook-toolbox.git/commitdiff
wip #7193 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 19 Nov 2024 17:10:12 +0000 (18:10 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 19 Nov 2024 17:10:12 +0000 (18:10 +0100)
app/Models/FluidbookPublication.php
resources/views/vendor/backpack/crud/buttons/fluidbook_publication/preview.blade.php

index 8857d276e423103eb20c419a5f8ef48fd48e8eaf..f466277a9c323f75b844dfbbb41a88d7b02e4345 100644 (file)
@@ -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) {
index 8b46d41440ee3b7fe8e210bc32835ea21d8beea7..978e67f4ab55b2066f7d7aebee76c95264489313 100644 (file)
@@ -2,20 +2,30 @@
 @php
     $actions=[];
     $suffixv3='';
-//    if($entry->version==2){
-//        $actions['compilev2']=['label'=>'<span class="context-menu-subtitle">'.__('Compilateur V2').'</span>','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'=>'<span class="context-menu-subtitle">'.__('Tester le compilateur V3').'</span>','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')}}"><i class="las la-eye"></i> {{__('Voir')}}
     </a>
 @endif
+