Files
coolify/resources/views/components/modal-input.blade.php
T
Andras Bacsai 4f32548e09 feat(tags): connect resources to a tag from the tag page
Add a "Connect to resources" modal to the tag show page for small
screens, where the tags canvas is hidden. A new toggleResource action
attaches or detaches the tag on a team resource after an authorization
check, then refreshes the tag's applications and services.

Also improve responsive layouts:
- Wrap section headings, project/environment toolbars and view toggles
  on narrow screens; keep modal headers from shrinking.
- Move the environment settings link to an icon next to the environment
  name and link the project name back to its environments.
- Group project icon, name and description into one "Project details"
  form with an unsaved-changes bar.
- Show dashboard "view all" links for projects and servers only when
  there are more items than the dashboard limit.
2026-10-15 13:19:18 +02:00

98 lines
5.5 KiB
PHP

@props([
'title' => 'Are you sure?',
'subtitle' => null,
'buttonTitle' => 'Open Modal',
'isErrorButton' => false,
'isHighlightedButton' => false,
'disabled' => false,
'action' => 'delete',
'content' => null,
'closeOutside' => true,
'isFullWidth' => false,
'wireIgnore' => true,
// Optional Livewire bool property to entangle open state (survives Livewire re-renders).
'wireOpen' => null,
'contentClicks' => true,
'isLarge' => false,
'fixedHeight' => false,
])
<div x-data="{ modalOpen: @if ($wireOpen) $wire.entangle(@js($wireOpen)) @else false @endif }"
x-init="$watch('modalOpen', value => { if (!value) { $wire.dispatch('modalClosed') } })"
:class="{ 'z-40': modalOpen }" @keydown.window.escape="modalOpen=false"
{{ $attributes->class(['relative', $isFullWidth ? 'h-full w-full' : 'h-auto w-auto']) }}
@close-modal.window="modalOpen=false" @if ($wireIgnore) wire:ignore @endif>
@if ($content)
<div @if ($contentClicks) @click="modalOpen=true" @endif @class(['h-full w-full' => $isFullWidth])>
{{ $content }}
</div>
@else
@if ($disabled)
<x-forms.button isError disabled @class(['w-full' => $isFullWidth])>{{ $buttonTitle }}</x-forms.button>
@elseif ($isErrorButton)
<x-forms.button isError @click="modalOpen=true" @class(['w-full' => $isFullWidth])>{{ $buttonTitle }}</x-forms.button>
@elseif ($isHighlightedButton)
<x-forms.button isHighlighted @click="modalOpen=true" @class(['w-full' => $isFullWidth])>{{ $buttonTitle }}</x-forms.button>
@else
<x-forms.button @click="modalOpen=true" @class(['w-full' => $isFullWidth])>{{ $buttonTitle }}</x-forms.button>
@endif
@endif
<template x-teleport="body">
<div x-show="modalOpen"
x-init="$watch('modalOpen', value => { if(value) { $nextTick(() => { const firstInput = $el.querySelector('input, textarea, select'); firstInput?.focus(); }) } })"
class="fixed inset-0 z-99 overflow-hidden">
<div x-show="modalOpen" x-transition:enter="transition-opacity ease-out duration-200" x-transition:enter-start="opacity-0"
x-transition:enter-end="opacity-100" x-transition:leave="transition-opacity ease-in duration-150"
x-transition:leave-start="opacity-100" x-transition:leave-end="opacity-0"
class="absolute inset-0 w-full h-full bg-black/50 backdrop-blur-[2px]"></div>
<div @if ($closeOutside) @click.self="modalOpen=false" @endif class="relative flex min-h-full items-start justify-center p-2 sm:items-center sm:p-4">
<div x-show="modalOpen" x-trap.inert.noscroll="modalOpen"
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0 scale-95"
x-transition:enter-end="opacity-100 scale-100"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100 scale-100"
x-transition:leave-end="opacity-0 scale-95"
@class([
'application-settings-form application-settings-section relative flex max-h-[calc(100dvh-2rem)] w-full flex-col overflow-hidden',
'lg:w-[95vw]! lg:max-w-7xl!' => $isLarge,
'lg:w-auto lg:min-w-2xl lg:max-w-4xl' => ! $isLarge,
'sm:h-[40rem]' => $fixedHeight,
])
style="box-shadow: 0 0 0 1px var(--coollabs-hairline), var(--shadow-modal)">
<header class="shrink-0 flex-wrap! sm:flex-nowrap!">
<div class="min-w-0 flex-1 py-0.5">
<h3 class="truncate">{{ $title }}</h3>
@if ($subtitle)
<p class="mt-0.5 text-xs text-neutral-500 dark:text-fg-dim">{{ $subtitle }}</p>
@endif
</div>
@isset($headerActions)
<div class="order-3 w-full sm:order-none sm:w-auto flex shrink-0 items-center gap-2">
{{ $headerActions }}
</div>
@endisset
<button type="button" @click="modalOpen=false"
class="order-2 sm:order-none flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-md text-neutral-500 outline-0 transition-colors hover:bg-neutral-100 hover:text-black focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent dark:text-fg-faint dark:hover:bg-white/[0.06] dark:hover:text-fg">
<x-reicon name="x" class="size-4" />
</button>
</header>
<div @class([
'application-settings-section-body min-h-0 flex-1 overflow-y-auto',
'mt-2 sm:mt-0' => isset($headerActions),
])
style="-webkit-overflow-scrolling: touch;">
{{ $slot }}
</div>
@isset($footer)
<footer
class="flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-neutral-200 px-4 py-3 dark:border-white/[0.08]">
{{ $footer }}
</footer>
@endisset
</div>
</div>
</div>
</template>
</div>