fix: show real volume names
This commit is contained in:
		@@ -11,7 +11,6 @@ class Show extends Component
 | 
				
			|||||||
    public LocalPersistentVolume $storage;
 | 
					    public LocalPersistentVolume $storage;
 | 
				
			||||||
    public bool $isReadOnly = false;
 | 
					    public bool $isReadOnly = false;
 | 
				
			||||||
    public ?string $modalId = null;
 | 
					    public ?string $modalId = null;
 | 
				
			||||||
    public ?string $realName = null;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected $rules = [
 | 
					    protected $rules = [
 | 
				
			||||||
        'storage.name' => 'required|string',
 | 
					        'storage.name' => 'required|string',
 | 
				
			||||||
@@ -26,11 +25,6 @@ class Show extends Component
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function mount()
 | 
					    public function mount()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if ($this->storage->resource_type === 'App\Models\ServiceApplication' || $this->storage->resource_type === 'App\Models\ServiceDatabase') {
 | 
					 | 
				
			||||||
            $this->realName = "{$this->storage->service->service->uuid}_{$this->storage->name}";
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            $this->realName = $this->storage->name;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        $this->modalId = new Cuid2(7);
 | 
					        $this->modalId = new Cuid2(7);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -248,7 +248,7 @@ class Service extends BaseModel
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                // Collect/create/update volumes
 | 
					                // Collect/create/update volumes
 | 
				
			||||||
                if ($serviceVolumes->count() > 0) {
 | 
					                if ($serviceVolumes->count() > 0) {
 | 
				
			||||||
                    foreach ($serviceVolumes as $volume) {
 | 
					                    $serviceVolumes = $serviceVolumes->map(function ($volume) use ($savedService, $topLevelVolumes) {
 | 
				
			||||||
                        $type = null;
 | 
					                        $type = null;
 | 
				
			||||||
                        $source = null;
 | 
					                        $source = null;
 | 
				
			||||||
                        $target = null;
 | 
					                        $target = null;
 | 
				
			||||||
@@ -276,10 +276,10 @@ class Service extends BaseModel
 | 
				
			|||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        if ($type->value() === 'bind') {
 | 
					                        if ($type->value() === 'bind') {
 | 
				
			||||||
                            if ($source->value() === "/var/run/docker.sock") {
 | 
					                            if ($source->value() === "/var/run/docker.sock") {
 | 
				
			||||||
                                continue;
 | 
					                                return $volume;
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                            if ($source->value() === '/tmp' || $source->value() === '/tmp/') {
 | 
					                            if ($source->value() === '/tmp' || $source->value() === '/tmp/') {
 | 
				
			||||||
                                continue;
 | 
					                                return $volume;
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                            LocalFileVolume::updateOrCreate(
 | 
					                            LocalFileVolume::updateOrCreate(
 | 
				
			||||||
                                [
 | 
					                                [
 | 
				
			||||||
@@ -297,7 +297,17 @@ class Service extends BaseModel
 | 
				
			|||||||
                                ]
 | 
					                                ]
 | 
				
			||||||
                            );
 | 
					                            );
 | 
				
			||||||
                        } else if ($type->value() === 'volume') {
 | 
					                        } else if ($type->value() === 'volume') {
 | 
				
			||||||
                            $topLevelVolumes->put($source->value(), null);
 | 
					                            $slug = Str::slug($source, '-');
 | 
				
			||||||
 | 
					                            $name = "{$savedService->service->uuid}_{$slug}";
 | 
				
			||||||
 | 
					                            if (is_string($volume)) {
 | 
				
			||||||
 | 
					                                $source = Str::of($volume)->before(':');
 | 
				
			||||||
 | 
					                                $target = Str::of($volume)->after(':')->beforeLast(':');
 | 
				
			||||||
 | 
					                                $source = $name;
 | 
				
			||||||
 | 
					                                $volume = "$source:$target";
 | 
				
			||||||
 | 
					                            } else if(is_array($volume)) {
 | 
				
			||||||
 | 
					                                data_set($volume, 'source', $name);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            $topLevelVolumes->put($name, null);
 | 
				
			||||||
                            LocalPersistentVolume::updateOrCreate(
 | 
					                            LocalPersistentVolume::updateOrCreate(
 | 
				
			||||||
                                [
 | 
					                                [
 | 
				
			||||||
                                    'mount_path' => $target,
 | 
					                                    'mount_path' => $target,
 | 
				
			||||||
@@ -305,7 +315,7 @@ class Service extends BaseModel
 | 
				
			|||||||
                                    'resource_type' => get_class($savedService)
 | 
					                                    'resource_type' => get_class($savedService)
 | 
				
			||||||
                                ],
 | 
					                                ],
 | 
				
			||||||
                                [
 | 
					                                [
 | 
				
			||||||
                                    'name' => Str::slug($source, '-'),
 | 
					                                    'name' => $name,
 | 
				
			||||||
                                    'mount_path' => $target,
 | 
					                                    'mount_path' => $target,
 | 
				
			||||||
                                    'resource_id' => $savedService->id,
 | 
					                                    'resource_id' => $savedService->id,
 | 
				
			||||||
                                    'resource_type' => get_class($savedService)
 | 
					                                    'resource_type' => get_class($savedService)
 | 
				
			||||||
@@ -313,7 +323,11 @@ class Service extends BaseModel
 | 
				
			|||||||
                            );
 | 
					                            );
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        $savedService->getFilesFromServer();
 | 
					                        $savedService->getFilesFromServer();
 | 
				
			||||||
                    }
 | 
					                        ray($volume);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        return $volume;
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					                    data_set($service, 'volumes', $serviceVolumes->toArray());
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // Add env_file with at least .env to the service
 | 
					                // Add env_file with at least .env to the service
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,7 +12,7 @@
 | 
				
			|||||||
    @endonce
 | 
					    @endonce
 | 
				
			||||||
    <form wire:submit.prevent='submit' class="flex flex-col gap-2 pt-4 xl:items-end xl:flex-row">
 | 
					    <form wire:submit.prevent='submit' class="flex flex-col gap-2 pt-4 xl:items-end xl:flex-row">
 | 
				
			||||||
        @if ($isReadOnly)
 | 
					        @if ($isReadOnly)
 | 
				
			||||||
            <x-forms.input id="realName" label="Volume Name" required readonly />
 | 
					            <x-forms.input id="storage.name" label="Volume Name" required readonly />
 | 
				
			||||||
            <x-forms.input id="storage.host_path" label="Source Path" readonly />
 | 
					            <x-forms.input id="storage.host_path" label="Source Path" readonly />
 | 
				
			||||||
            <x-forms.input id="storage.mount_path" label="Destination Path" required readonly />
 | 
					            <x-forms.input id="storage.mount_path" label="Destination Path" required readonly />
 | 
				
			||||||
        @else
 | 
					        @else
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user