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 = collect(json_decode($deprecated))->sortKeys();
$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 {
$services = Http::get(config('constants.services.official'));
if ($services->failed()) {

View File

@ -55,6 +55,9 @@ .icon:hover {
.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];
}
.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 {
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>
@else
@foreach ($services as $serviceName => $service)
<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') }}
@if (data_get($service, 'disabled'))
<button class="text-left bg-black cursor-not-allowed bg-coolgray-200/20 box-without-bg"
disabled>
<div class="flex flex-col mx-6">
<div class="font-bold text-coolgray-500">
{{ Str::headline($serviceName) }}
</div>
@endif
</div>
</button>
You need to upgrade to {{ data_get($service, 'minVersion') }} to use this service.
</div>
</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
@endif
</div>