feat: disable service, required version

This commit is contained in:
Andras Bacsai 2023-10-05 10:58:08 +02:00
parent 762af66cbf
commit e2e64e36a0
3 changed files with 34 additions and 12 deletions

View File

@ -429,6 +429,13 @@ function getServiceTemplates()
$deprecated = File::get(base_path('templates/deprecated.json')); $deprecated = File::get(base_path('templates/deprecated.json'));
$deprecated = collect(json_decode($deprecated))->sortKeys(); $deprecated = collect(json_decode($deprecated))->sortKeys();
$services = $services->merge($deprecated); $services = $services->merge($deprecated);
$version = config('version');
$services = $services->map(function ($service) use ($version) {
if (version_compare($version, data_get($service,'minVersion', '0.0.0'), '<')) {
$service->disabled = true;
}
return $service;
});
} else { } else {
$services = Http::get(config('constants.services.official')); $services = Http::get(config('constants.services.official'));
if ($services->failed()) { if ($services->failed()) {

View File

@ -55,6 +55,9 @@ .icon:hover {
.box { .box {
@apply flex items-center p-2 transition-colors cursor-pointer min-h-16 bg-coolgray-200 hover:bg-coollabs-100 hover:text-white hover:no-underline min-w-[24rem]; @apply flex items-center p-2 transition-colors cursor-pointer min-h-16 bg-coolgray-200 hover:bg-coollabs-100 hover:text-white hover:no-underline min-w-[24rem];
} }
.box-without-bg {
@apply flex items-center p-2 transition-colors min-h-16 hover:text-white hover:no-underline min-w-[24rem];
}
.lds-heart { .lds-heart {
animation: lds-heart 1.2s infinite cubic-bezier(0.215, 0.61, 0.355, 1); animation: lds-heart 1.2s infinite cubic-bezier(0.215, 0.61, 0.355, 1);

View File

@ -95,19 +95,31 @@
<span class="loading loading-xs loading-spinner"></span> <span class="loading loading-xs loading-spinner"></span>
@else @else
@foreach ($services as $serviceName => $service) @foreach ($services as $serviceName => $service)
<button class="text-left box group" @if (data_get($service, 'disabled'))
wire:loading.attr="disabled" wire:click="setType('one-click-service-{{ $serviceName }}')"> <button class="text-left bg-black cursor-not-allowed bg-coolgray-200/20 box-without-bg"
<div class="flex flex-col mx-6"> disabled>
<div class="font-bold text-white group-hover:text-white"> <div class="flex flex-col mx-6">
{{ Str::headline($serviceName) }} <div class="font-bold text-coolgray-500">
</div> {{ Str::headline($serviceName) }}
@if (data_get($service, 'slogan'))
<div class="text-xs">
{{ data_get($service, 'slogan') }}
</div> </div>
@endif You need to upgrade to {{ data_get($service, 'minVersion') }} to use this service.
</div> </div>
</button> </button>
@else
<button class="text-left box group" wire:loading.attr="disabled"
wire:click="setType('one-click-service-{{ $serviceName }}')">
<div class="flex flex-col mx-6">
<div class="font-bold text-white group-hover:text-white">
{{ Str::headline($serviceName) }}
</div>
@if (data_get($service, 'slogan'))
<div class="text-xs">
{{ data_get($service, 'slogan') }}
</div>
@endif
</div>
</button>
@endif
@endforeach @endforeach
@endif @endif
</div> </div>