6
6
use App \Models \Application ;
7
7
use Illuminate \Support \Collection ;
8
8
use Livewire \Component ;
9
+ use Spatie \Url \Url ;
9
10
use Visus \Cuid2 \Cuid2 ;
10
11
11
12
class General extends Component
@@ -183,9 +184,7 @@ public function instantSave()
183
184
$ storage ->save ();
184
185
});
185
186
}
186
-
187
187
}
188
-
189
188
}
190
189
191
190
public function loadComposeFile ($ isInit = false )
@@ -242,23 +241,6 @@ public function updatedApplicationBaseDirectory()
242
241
}
243
242
}
244
243
245
- public function updatedApplicationFqdn ()
246
- {
247
- try {
248
- $ this ->application ->fqdn = str ($ this ->application ->fqdn )->replaceEnd (', ' , '' )->trim ();
249
- $ this ->application ->fqdn = str ($ this ->application ->fqdn )->replaceStart (', ' , '' )->trim ();
250
- $ this ->application ->fqdn = str ($ this ->application ->fqdn )->trim ()->explode (', ' )->map (function ($ domain ) {
251
- return str ($ domain )->trim ()->lower ();
252
- });
253
- $ this ->application ->fqdn = $ this ->application ->fqdn ->unique ()->implode (', ' );
254
- $ this ->application ->save ();
255
- } catch (\Throwable $ e ) {
256
- $ originalFqdn = $ this ->application ->getOriginal ('fqdn ' );
257
- $ this ->application ->fqdn = $ originalFqdn ;
258
- return handleError ($ e , $ this );
259
- }
260
- $ this ->resetDefaultLabels ();
261
- }
262
244
263
245
public function updatedApplicationBuildPack ()
264
246
{
@@ -332,7 +314,7 @@ public function checkFqdns($showToaster = true)
332
314
public function set_redirect ()
333
315
{
334
316
try {
335
- $ has_www = collect ($ this ->application ->fqdns )->filter (fn ($ fqdn ) => str ($ fqdn )->contains ('www. ' ))->count ();
317
+ $ has_www = collect ($ this ->application ->fqdns )->filter (fn ($ fqdn ) => str ($ fqdn )->contains ('www. ' ))->count ();
336
318
if ($ has_www === 0 && $ this ->application ->redirect === 'www ' ) {
337
319
$ this ->dispatch ('error ' , 'You want to redirect to www, but you do not have a www domain set.<br><br>Please add www to your domain list and as an A DNS record (if applicable). ' );
338
320
@@ -349,15 +331,18 @@ public function set_redirect()
349
331
public function submit ($ showToaster = true )
350
332
{
351
333
try {
352
- if ($ this ->application ->isDirty ('redirect ' )) {
353
- $ this ->set_redirect ();
354
- }
334
+ Url::fromString ($ this ->application ->fqdn , ['http ' , 'https ' ]);
355
335
$ this ->application ->fqdn = str ($ this ->application ->fqdn )->replaceEnd (', ' , '' )->trim ();
356
336
$ this ->application ->fqdn = str ($ this ->application ->fqdn )->replaceStart (', ' , '' )->trim ();
357
337
$ this ->application ->fqdn = str ($ this ->application ->fqdn )->trim ()->explode (', ' )->map (function ($ domain ) {
358
338
return str ($ domain )->trim ()->lower ();
359
339
});
360
340
$ this ->application ->fqdn = $ this ->application ->fqdn ->unique ()->implode (', ' );
341
+ $ this ->resetDefaultLabels ();
342
+
343
+ if ($ this ->application ->isDirty ('redirect ' )) {
344
+ $ this ->set_redirect ();
345
+ }
361
346
362
347
$ this ->checkFqdns ();
363
348
@@ -420,6 +405,10 @@ public function submit($showToaster = true)
420
405
$ this ->application ->save ();
421
406
$ showToaster && $ this ->dispatch ('success ' , 'Application settings updated! ' );
422
407
} catch (\Throwable $ e ) {
408
+ $ originalFqdn = $ this ->application ->getOriginal ('fqdn ' );
409
+ if ($ originalFqdn !== $ this ->application ->fqdn ) {
410
+ $ this ->application ->fqdn = $ originalFqdn ;
411
+ }
423
412
return handleError ($ e , $ this );
424
413
} finally {
425
414
$ this ->dispatch ('configurationChanged ' );
0 commit comments