mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-21 05:20:26 +08:00
Revert "Merge pull request #3454 from filamentphp/notifications-action-group"
This reverts commitd02cbfae1d, reversing changes made to83409d9578.
This commit is contained in:
@@ -39,7 +39,6 @@ You're now ready to start [sending notifications](sending-notifications)!
|
||||
The package uses the following dependencies:
|
||||
|
||||
- [Alpine.js](https://alpinejs.dev)
|
||||
- [Alpine Floating UI](https://github.com/awcodes/alpine-floating-ui)
|
||||
- [Tailwind CSS](https://tailwindcss.com)
|
||||
|
||||
You may install these through NPM:
|
||||
@@ -147,14 +146,12 @@ In `/resources/css/app.css`, import [Tailwind CSS](https://tailwindcss.com):
|
||||
|
||||
### Configuring scripts
|
||||
|
||||
In `/resources/js/app.js`, import [Alpine.js](https://alpinejs.dev), Alpine Floating UI and the `filament/notifications` plugin, and register them:
|
||||
In `/resources/js/app.js`, import [Alpine.js](https://alpinejs.dev) and the `filament/notifications` plugin, and register it:
|
||||
|
||||
```js
|
||||
import Alpine from 'alpinejs'
|
||||
import AlpineFloatingUI from '@awcodes/alpine-floating-ui'
|
||||
import NotificationsAlpinePlugin from '../../vendor/filament/notifications/dist/module.esm'
|
||||
|
||||
Alpine.plugin(AlpineFloatingUI)
|
||||
Alpine.plugin(NotificationsAlpinePlugin)
|
||||
|
||||
window.Alpine = Alpine
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<x-filament-support::actions.group
|
||||
:actions="$getActions()"
|
||||
:dark-mode="config('notifications.dark_mode')"
|
||||
:color="$getColor()"
|
||||
:icon="$getIcon()"
|
||||
:label="$getLabel()"
|
||||
:tooltip="$getTooltip()"
|
||||
/>
|
||||
@@ -1,8 +0,0 @@
|
||||
<x-notifications::actions.action
|
||||
:action="$action"
|
||||
component="notifications::dropdown.item"
|
||||
:icon-position="$getIconPosition()"
|
||||
class="filament-notifications-grouped-action"
|
||||
>
|
||||
{{ $getLabel() }}
|
||||
</x-notifications::actions.action>
|
||||
@@ -1,10 +0,0 @@
|
||||
@captureSlots([
|
||||
'detail',
|
||||
])
|
||||
|
||||
<x-filament-support::dropdown.item
|
||||
:attributes="\Filament\Support\prepare_inherited_attributes($attributes)->merge($slots)"
|
||||
:dark-mode="config('notifications.dark_mode')"
|
||||
>
|
||||
{{ $slot }}
|
||||
</x-filament-support::dropdown.item>
|
||||
@@ -77,13 +77,6 @@ class Action extends BaseAction implements Arrayable
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function grouped(): static
|
||||
{
|
||||
$this->view('notifications::actions.grouped-action');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function link(): static
|
||||
{
|
||||
$this->view('notifications::actions.link-action');
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Notifications\Actions;
|
||||
|
||||
use Filament\Support\Actions\ActionGroup as BaseActionGroup;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
|
||||
class ActionGroup extends BaseActionGroup implements Arrayable
|
||||
{
|
||||
protected string $view = 'notifications::actions.group';
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'actions' => collect($this->getActions())->toArray(),
|
||||
'color' => $this->getColor(),
|
||||
'icon' => $this->getIcon(),
|
||||
'iconPosition' => $this->getIconPosition(),
|
||||
'label' => $this->getLabel(),
|
||||
'tooltip' => $this->getTooltip(),
|
||||
];
|
||||
}
|
||||
|
||||
public static function fromArray(array $data): static
|
||||
{
|
||||
$static = static::make(
|
||||
array_map(
|
||||
fn (array $action): Action => Action::fromArray($action),
|
||||
$data['actions'],
|
||||
),
|
||||
);
|
||||
|
||||
$static->color($data['color']);
|
||||
$static->icon($data['icon']);
|
||||
$static->iconPosition($data['iconPosition']);
|
||||
$static->label($data['label']);
|
||||
$static->tooltip($data['tooltip']);
|
||||
|
||||
return $static;
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,12 @@
|
||||
namespace Filament\Notifications\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Filament\Notifications\Actions\ActionGroup;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
trait HasActions
|
||||
{
|
||||
protected array | ActionGroup | Closure $actions = [];
|
||||
protected array | Closure $actions = [];
|
||||
|
||||
public function actions(array | ActionGroup | Closure $actions): static
|
||||
public function actions(array | Closure $actions): static
|
||||
{
|
||||
$this->actions = $actions;
|
||||
|
||||
@@ -19,6 +17,6 @@ trait HasActions
|
||||
|
||||
public function getActions(): array
|
||||
{
|
||||
return Arr::wrap($this->evaluate($this->actions));
|
||||
return $this->evaluate($this->actions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Filament\Notifications;
|
||||
|
||||
use Filament\Notifications\Actions\Action;
|
||||
use Filament\Notifications\Actions\ActionGroup;
|
||||
use Filament\Notifications\Concerns\HasActions;
|
||||
use Filament\Notifications\Concerns\HasBody;
|
||||
use Filament\Notifications\Concerns\HasDuration;
|
||||
@@ -44,7 +43,7 @@ class Notification extends ViewComponent implements Arrayable
|
||||
{
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
'actions' => array_map(fn (Action | ActionGroup $action): array => $action->toArray(), $this->getActions()),
|
||||
'actions' => collect($this->getActions())->toArray(),
|
||||
'body' => $this->getBody(),
|
||||
'duration' => $this->getDuration(),
|
||||
'icon' => $this->getIcon(),
|
||||
@@ -56,15 +55,7 @@ class Notification extends ViewComponent implements Arrayable
|
||||
public static function fromArray(array $data): static
|
||||
{
|
||||
$static = static::make($data['id']);
|
||||
$static->actions(
|
||||
array_map(
|
||||
fn (array $action): Action | ActionGroup => match (array_key_exists('actions', $action)) {
|
||||
true => ActionGroup::fromArray($action),
|
||||
false => Action::fromArray($action),
|
||||
},
|
||||
$data['actions'],
|
||||
),
|
||||
);
|
||||
$static->actions(array_map(fn (array $action): Action => Action::fromArray($action), $data['actions']));
|
||||
$static->body($data['body']);
|
||||
$static->duration($data['duration']);
|
||||
$static->icon($data['icon']);
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import Alpine from 'alpinejs'
|
||||
import AlpineFloatingUI from '@awcodes/alpine-floating-ui'
|
||||
import NotificationsAlpinePlugin from '../../vendor/filament/notifications/dist/module.esm'
|
||||
|
||||
Alpine.plugin(AlpineFloatingUI)
|
||||
Alpine.plugin(NotificationsAlpinePlugin)
|
||||
|
||||
window.Alpine = Alpine
|
||||
|
||||
Reference in New Issue
Block a user