mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-13 04:30:41 -05:00
hide mods for normal users
also, allow enabling mods, and add ribbons to disabled mods
This commit is contained in:
parent
593951b409
commit
0bb71a39cb
@ -17,11 +17,13 @@ class ModerationOptions extends Component
|
||||
public function deleteMod(): void
|
||||
{
|
||||
$this->mod->delete();
|
||||
$this->js('window.location.reload()');
|
||||
}
|
||||
|
||||
public function disableMod(): void
|
||||
public function toggleDisabled(): void
|
||||
{
|
||||
$this->mod->disabled = true;
|
||||
$this->mod->disabled = ! $this->mod->disabled;
|
||||
$this->mod->save();
|
||||
$this->js('window.location.reload()');
|
||||
}
|
||||
}
|
||||
|
@ -158,6 +158,14 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
return Str::lower($this->role?->name) === 'administrator';
|
||||
}
|
||||
|
||||
/**
|
||||
* Conveniently check is a user is a mod or an admin
|
||||
*/
|
||||
public function isModOrAdmin(): bool
|
||||
{
|
||||
return $this->isMod() || $this->isAdmin();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwritten to instead use the queued version of the VerifyEmail notification.
|
||||
*/
|
||||
|
@ -20,7 +20,11 @@ class ModPolicy
|
||||
*/
|
||||
public function view(?User $user, Mod $mod): bool
|
||||
{
|
||||
// Everyone can view mods.
|
||||
// Everyone can view mods, unless they are disabled.
|
||||
if ($mod->disabled && ! $user?->isModOrAdmin()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,6 @@ main a:not(.mod-list-component):not(.tab):not([role="menuitem"]) {
|
||||
.ribbon {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.ribbon {
|
||||
@ -106,7 +105,6 @@ main a:not(.mod-list-component):not(.tab):not([role="menuitem"]) {
|
||||
clip-path: polygon(100% calc(100% - var(--f)), 100% 100%, calc(100% - var(--f)) calc(100% - var(--f)), var(--f) calc(100% - var(--f)), 0 100%, 0 calc(100% - var(--f)), 999px calc(100% - var(--f) - 999px), calc(100% - 999px) calc(100% - var(--f) - 999px));
|
||||
transform: translate(calc((cos(45deg) - 1) * 100%), -100%) rotate(-45deg);
|
||||
transform-origin: 100% 100%;
|
||||
background-color: #0e7490;
|
||||
}
|
||||
|
||||
.rainbow {
|
||||
|
@ -1,14 +1,17 @@
|
||||
@props(['mod', 'version'])
|
||||
|
||||
<a href="{{ $mod->detailUrl() }}" class="mod-list-component relative mx-auto w-full max-w-2xl">
|
||||
@if ($mod->featured && !request()->routeIs('home'))
|
||||
<div class="ribbon z-10">{{ __('Featured!') }}</div>
|
||||
@if ($mod->featured && !$mod->disabled && !request()->routeIs('home'))
|
||||
<div class="ribbon text-white bg-cyan-500 dark:bg-cyan-700 z-10">{{ __('Featured!') }}</div>
|
||||
@endif
|
||||
@if ($mod->disabled)
|
||||
<div class="ribbon text-white bg-red-500 dark:bg-red-700 z-10">{{ __('Disabled') }}</div>
|
||||
@endif
|
||||
<div class="flex flex-col group h-full w-full bg-white dark:bg-gray-950 rounded-xl shadow-md dark:shadow-gray-950 drop-shadow-2xl overflow-hidden hover:shadow-lg hover:bg-gray-50 dark:hover:bg-black hover:shadow-gray-400 dark:hover:shadow-black transition-colors ease-out duration-700">
|
||||
<div class="h-auto md:h-full md:flex">
|
||||
@if (auth()->check() && (auth()->user()->isAdmin() || auth()->user()->isMod()))
|
||||
@if (auth()->check() && auth()->user()->isModOrAdmin())
|
||||
<div class="absolute right-0 z-50 m-2">
|
||||
<livewire:mod.moderation-options :mod="$mod"/>
|
||||
<livewire:mod.moderation-options :mod="$mod" />
|
||||
</div>
|
||||
@endif
|
||||
<div class="relative h-auto md:h-full md:shrink-0 overflow-hidden">
|
||||
|
@ -173,7 +173,9 @@
|
||||
@if ($mods->isNotEmpty())
|
||||
<div class="my-8 grid grid-cols-1 gap-6 lg:grid-cols-2">
|
||||
@foreach ($mods as $mod)
|
||||
<x-mod-card :mod="$mod" :version="$mod->latestVersion" />
|
||||
@if(!$mod->disabled || (auth()->check() && auth()->user()->isModOrAdmin()))
|
||||
<x-mod-card :mod="$mod" :version="$mod->latestVersion" />
|
||||
@endif
|
||||
@endforeach
|
||||
</div>
|
||||
@else
|
||||
|
@ -12,15 +12,22 @@
|
||||
|
||||
<x-slot name="content">
|
||||
<div>
|
||||
<button wire:click.prevent="disableMod" wire:confirm="Disable the mod '{{$this->mod->name}}'?" class="p-2 h-full w-full text-blue-500 dark:text-blue-500 bg-gray-200 dark:bg-gray-800 hover:text-blue-400 dark:hover:text-blue-400">
|
||||
<button wire:click.prevent="toggleDisabled" wire:confirm="{{$this->mod->disabled ? __('Enable') : __('Disable') }} the mod '{{$this->mod->name}}'?" class="p-2 h-full w-full text-blue-500 dark:text-blue-500 bg-gray-200 dark:bg-gray-800 hover:text-blue-400 dark:hover:text-blue-400">
|
||||
<div class="flex">
|
||||
<span class="pr-2">
|
||||
@if ($this->mod->disabled)
|
||||
{{-- Icon (circle with checkmark) --}}
|
||||
<svg width="24" height="24" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M12 2c5.523 0 10 4.477 10 10s-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2Zm3.22 6.97-4.47 4.47-1.97-1.97a.75.75 0 0 0-1.06 1.06l2.5 2.5a.75.75 0 0 0 1.06 0l5-5a.75.75 0 1 0-1.06-1.06Z" />
|
||||
</svg>
|
||||
@else
|
||||
{{-- Icon (circle with dash) --}}
|
||||
<svg width="24" height="24" fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M12 2.001c5.524 0 10 4.477 10 10s-4.476 10-10 10c-5.522 0-10-4.477-10-10s4.478-10 10-10Zm4.25 9.25h-8.5a.75.75 0 0 0 0 1.5h8.5a.75.75 0 0 0 0-1.5Z" />
|
||||
</svg>
|
||||
@endif
|
||||
</span>
|
||||
{{ __('Disable') }}
|
||||
{{$this->mod->disabled ? __('Enable') : __('Disable') }}
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
|
@ -11,8 +11,16 @@
|
||||
|
||||
{{-- Main Mod Details Card --}}
|
||||
<div class="relative p-4 sm:p-6 text-center sm:text-left bg-white dark:bg-gray-950 rounded-xl shadow-md dark:shadow-gray-950 drop-shadow-2xl">
|
||||
@if ($mod->featured)
|
||||
<div class="ribbon z-10">{{ __('Featured!') }}</div>
|
||||
@if (auth()->check() && auth()->user()->isModOrAdmin())
|
||||
<div class="absolute top-0 right-0 z-50 m-2">
|
||||
<livewire:mod.moderation-options :mod="$mod" />
|
||||
</div>
|
||||
@endif
|
||||
@if ($mod->featured && !$mod->disabled)
|
||||
<div class="ribbon text-white bg-cyan-500 dark:bg-cyan-700 z-10">{{ __('Featured!') }}</div>
|
||||
@endif
|
||||
@if ($mod->disabled)
|
||||
<div class="ribbon text-white bg-red-500 dark:bg-red-700 z-10">{{ __('Disabled') }}</div>
|
||||
@endif
|
||||
<div class="flex flex-col sm:flex-row gap-4 sm:gap-6">
|
||||
<div class="grow-0 shrink-0 flex justify-center items-center">
|
||||
|
Loading…
x
Reference in New Issue
Block a user