]> _ Git - fluidbook-toolbox.git/commitdiff
wip #7071 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 11 Sep 2024 10:51:28 +0000 (12:51 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 11 Sep 2024 10:51:28 +0000 (12:51 +0200)
app/Http/Controllers/Admin/Operations/Tools/WebflowOperation.php
app/Models/ToolWebflow.php

index 09a9515fa13ead73f3d6ce0e598bf5c35dc22505..2d77b38952383ae2e3c3573173714fa9abaa150b 100644 (file)
@@ -4,9 +4,11 @@ namespace App\Http\Controllers\Admin\Operations\Tools;
 
 use App\Http\Middleware\CheckIfAdmin;
 use App\Http\Middleware\VerifyCsrfToken;
+use App\Jobs\WebflowPublish;
 use App\Models\ToolWebflow;
 use App\Services\Webflow;
 use Illuminate\Support\Facades\Route;
+use Prologue\Alerts\Facades\Alert;
 
 trait WebflowOperation
 {
@@ -32,6 +34,15 @@ trait WebflowOperation
             Webflow::setToken($wf->webflow_api_token);
             return response()->json($wf->getEditableData());
         });
+
+        Route::match(['get'], 'webflow/{id}/deploytoprod', function ($id) {
+            if (!can('webflow:write')) {
+                abort(401);
+            }
+            WebflowPublish::dispatch($id, 'production');
+            Alert::add('success', __('Le déploiement en production a été lancé. Vous recevrez une notification lorsqu\'il sera terminé.'))->flash();
+            return redirect(backpack_url('tool-webflow/' . $id . '/edit'));
+        });
     }
 
 }
index 33c0a5ef7188c55d6a750ef455801a5d9879c2a0..551150397f7c1cbafb20437dd7430c1fe6594b6d 100644 (file)
@@ -13,6 +13,7 @@ use App\SubForms\Webflow\Redirection;
 use App\SubForms\Webflow\SEOPage;
 use Cubist\Azure\Translate\Api;
 use Cubist\Backpack\Magic\Fields\BunchOfFieldsMultiple;
+use Cubist\Backpack\Magic\Fields\Button;
 use Cubist\Backpack\Magic\Fields\Checkbox;
 use Cubist\Backpack\Magic\Fields\Code;
 use Cubist\Backpack\Magic\Fields\Hidden;
@@ -65,6 +66,7 @@ class ToolWebflow extends ToolboxTranslatableModel
             $sites[$k] = $item['label'];
         }
         $this->addField('upload', SelectFromArray::class, __('Uploader sur'), ['translatable' => false, 'options' => $sites, 'tab' => __('Paramètres')]);
+        $this->addField('action_deploy_prod', LinkButton::class, __('Déployer en production'), ['value' => backpack_url('webflow/$id/deploytoprod'), 'translatable' => false, 'tab' => __('Paramètres')]);
         $this->addField('js', Code::class, __('Javascript complémentaire'), ['translatable' => false, 'language' => 'js', 'tab' => __('Code'), 'hint' => __('Code ajouté à toutes les pages')]);
         $this->addField('css', Code::class, __('CSS complémentaire'), ['translatable' => false, 'language' => 'css', 'tab' => __('Code'), 'hint' => __('Code ajouté à toutes les pages')]);
         $this->addField('texts', WebflowTexts::class, '', ['tab' => __('Textes'), 'translatable' => true, 'hint' => __('Modifier un texte ici ne produira aucun changement sur webflow')]);