From: Vincent Vanwaelscappel Date: Wed, 11 Sep 2024 10:51:28 +0000 (+0200) Subject: wip #7071 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=9fcbf1f721f08956bd1cc6f81cd98478758c912d;p=fluidbook-toolbox.git wip #7071 @1 --- diff --git a/app/Http/Controllers/Admin/Operations/Tools/WebflowOperation.php b/app/Http/Controllers/Admin/Operations/Tools/WebflowOperation.php index 09a9515fa..2d77b3895 100644 --- a/app/Http/Controllers/Admin/Operations/Tools/WebflowOperation.php +++ b/app/Http/Controllers/Admin/Operations/Tools/WebflowOperation.php @@ -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')); + }); } } diff --git a/app/Models/ToolWebflow.php b/app/Models/ToolWebflow.php index 33c0a5ef7..551150397 100644 --- a/app/Models/ToolWebflow.php +++ b/app/Models/ToolWebflow.php @@ -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')]);