Skip to content

Commit 16fdbff

Browse files
committed
feat:(LAR-138) adding button and translation
1 parent 74f32e2 commit 16fdbff

File tree

14 files changed

+272
-146
lines changed

14 files changed

+272
-146
lines changed

lang/en/actions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
'unban' => 'Cancel ban',
1515
'confirm' => 'Confirm',
1616
'start' => 'Start',
17+
'view' => 'View',
1718

1819
];

lang/en/notifications.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
'created' => 'Your article has been created.',
99
'submitted' => 'Thank you for submitting your article. We will only contact you once we have accepted your article.',
1010
'updated' => 'Your article has been updated.',
11+
'deleted' => 'Your article has been deleted.',
1112
],
1213

1314
'thread' => [

lang/en/pages/article.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@
2929
'unpublished' => 'This article has not yet been published.',
3030
'draft' => 'Draft',
3131
'your_article' => 'Your Articles',
32+
'not_article_created' => "You haven't created any articles yet",
3233

3334
];

lang/en/pages/forum.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,7 @@
4040
'min_thread_length' => '10 characters minimum',
4141
'answer_reply' => 'Answer to',
4242
'threads_count' => ':count messages',
43+
'your_thread' => 'Your thread',
44+
'not_thread_created' => "You haven't created any topic yet",
4345

4446
];

lang/fr/actions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
'unban' => 'Dé-bannir',
1515
'confirm' => 'Confirmer',
1616
'start' => 'Démarrer',
17-
17+
'view' => 'Voir',
1818
];

lang/fr/notifications.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
'created' => 'Votre article a été crée.',
99
'submitted' => 'Merci d\'avoir soumis votre article. Vous aurez des nouvelles que lorsque nous accepterons votre article.',
1010
'updated' => 'Votre article a été mis à jour.',
11+
'deleted' => 'Votre article a été supprimé.',
1112
],
1213

1314
'thread' => [

lang/fr/pages/article.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@
2929
'unpublished' => 'Cet article n\'a pas encore été publié.',
3030
'draft' => 'Brouillon',
3131
'your_article' => 'Vos articles',
32+
'not_article_created' => "Vous n'avez pas encore créé d'articles",
3233

3334
];

lang/fr/pages/forum.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,7 @@
4040
'min_thread_length' => 'Minimum de 10 caractères.',
4141
'answer_reply' => 'Répondre au sujet',
4242
'threads_count' => ':count messages',
43+
'your_thread' => 'Vos Sujets',
44+
'not_thread_created' => "Vous n'avez pas encore créé de sujet",
4345

4446
];

resources/views/components/discussions/overview.blade.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
@props([
22
'discussion',
33
'hiddenAuthor' => false,
4+
'displayButton' => false,
5+
'displayClass' => true
46
])
57

6-
<div>
8+
<div @if($displayClass) class="py-6" @endif >
79
@if ($discussion->tags->isNotEmpty())
8-
<div class="flex justify-between space-x-2 mb-4">
10+
<div class="flex items-center space-x-2 mb-4">
911
<div class="flex-1">
1012
@foreach ($discussion->tags as $tag)
1113
<x-tag
@@ -14,16 +16,18 @@
1416
/>
1517
@endforeach
1618
</div>
19+
@if($displayButton)
20+
<div>
21+
@can('update', $discussion)
22+
{{ $this->editAction()(['discussion' => $discussion->id]) }}
23+
@endcan
1724

18-
<div>
19-
<button type="button"
20-
class="inline-flex rounded bg-warning-500 px-2.5 py-0.5 text-xs font-medium text-yellow-800"
21-
onclick="Livewire.dispatch('openPanel', { component: 'components.slideovers.discussion-form', arguments: { discussionId: {{ $discussion->id }} }})">
22-
{{ __('actions.edit') }}
23-
</button>
24-
25-
{{-- Mettre le bouton delete ici --}}
26-
</div>
25+
@can('delete', $discussion)
26+
{{ $this->deleteAction()(['discussion' => $discussion->id]) }}
27+
@endcan
28+
<x-filament-actions::modals />
29+
</div>
30+
@endif
2731
</div>
2832
@endif
2933

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
@props([
22
'thread',
3+
'displayButton' => false
34
])
5+
<div {{ $attributes->twMerge(['class' => 'flex items-center mb-2 flex-wrap gap-1.5']) }}>
6+
@if (count($channels = $thread->channels->load('parent')))
7+
@foreach ($channels as $channel)
8+
@php
9+
$color = $channel->parent_id ? $channel->parent->color : $channel->color;
10+
@endphp
11+
<x-link :href="route('forum.channels', $channel)" class="flex gap-2">
12+
<x-forum.channel
13+
:channel="$channel"
14+
class="text-xs is-channel is-{{ $channel->slug }}"
15+
style="--channel-color: {{ $color }}"
16+
/>
17+
</x-link>
18+
@endforeach
19+
@endif
20+
@if($displayButton && isset($this->deleteAction) || isset($this->editAction))
21+
<div class="ml-auto">
22+
@can('update', $thread)
23+
{{ $this->editAction()(['thread' => $thread->id]) }}
24+
@endcan
425

5-
@if (count($channels = $thread->channels->load('parent')))
6-
<div class="flex justify-between">
7-
<div {{ $attributes->twMerge(['class' => 'flex-1 mb-2 flex-wrap gap-1.5']) }}>
8-
@foreach ($channels as $channel)
9-
@php
10-
$color = $channel->parent_id ? $channel->parent->color : $channel->color;
11-
@endphp
12-
<x-link :href="route('forum.channels', $channel)" class="flex gap-2">
13-
<x-forum.channel
14-
:channel="$channel"
15-
class="text-xs is-channel is-{{ $channel->slug }}"
16-
style="--channel-color: {{ $color }}"
17-
/>
18-
</x-link>
19-
@endforeach
26+
@can('delete', $thread)
27+
{{ $this->deleteAction()(['thread' => $thread->id]) }}
28+
@endcan
29+
<x-filament-actions::modals />
2030
</div>
21-
22-
<div>
23-
<button type="button"
24-
class="inline-flex rounded bg-warning-500 px-2.5 py-0.5 text-xs font-medium text-yellow-800"
25-
onclick="Livewire.dispatch('openPanel', { component: 'components.slideovers.thread-form', arguments: { threadId: {{ $thread->id }} }})">
26-
{{ __('actions.edit') }}
27-
</button>
28-
29-
{{-- Mettre le bouton delete ici --}}
30-
</div>
31-
</div>
32-
@endif
31+
@endif
32+
</div>

resources/views/components/forum/thread.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
])
44

55
<article class="rounded-xl mb-8 p-6 cursor-pointer bg-white transition duration-200 ease-in-out dark:bg-gray-800 dark:ring-gray-800 dark:hover:bg-white/10 lg:py-5 lg:px-6" aria-labelledby="{{ $thread->slug }}">
6-
<x-forum.thread-channels :thread="$thread" />
6+
<x-forum.thread-channels :thread="$thread" :displayButton="true" />
77

88
<div class="flex items-center gap-4">
99
<h2 id="question-title-{{ $thread->id }}" class="truncate text-xl font-medium text-gray-900 dark:text-white lg:text-xl">

resources/views/livewire/components/account/articles.blade.php

Lines changed: 57 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
declare(strict_types=1);
44
55
use App\Actions\Article\ArticleDeleteAction;
6-
use App\Actions\Discussion\DeleteDiscussionAction;
76
use App\Models\Article;
87
use Filament\Actions\Action;
9-
use Filament\Actions\DeleteAction;
8+
use Filament\Actions\Concerns\InteractsWithActions;
9+
use Filament\Actions\Contracts\HasActions;
10+
use Filament\Forms\Concerns\InteractsWithForms;
11+
use Filament\Forms\Contracts\HasForms;
1012
use Filament\Notifications\Notification;
1113
use Livewire\Volt\Component;
1214
use Livewire\WithPagination;
@@ -15,9 +17,11 @@
1517
use Illuminate\Support\Facades\Auth;
1618
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
1719
18-
new class extends Component {
20+
new class extends Component implements HasForms, HasActions {
1921
2022
use WithPagination, WithoutUrlPagination;
23+
use InteractsWithActions;
24+
use InteractsWithForms;
2125
2226
#[Computed]
2327
public function articles(): LengthAwarePaginator
@@ -26,43 +30,64 @@ public function articles(): LengthAwarePaginator
2630
->where('user_id', Auth::id())
2731
->with(['user', 'tags', 'reactions'])
2832
->latest()
29-
->paginate(3);
33+
->paginate(10);
3034
}
3135
32-
public function deleteArticle(Article $article): void
36+
public function editAction(): Action
3337
{
34-
app(ArticleDeleteAction::class)->handle($article);
35-
36-
Notification::make()
37-
->title('Article supprimé avec succès')
38-
->success()
39-
->send();
38+
return Action::make('edit')
39+
->label(__('actions.edit'))
40+
->color('warning')
41+
->action(
42+
fn (array $arguments) => $this->dispatch(
43+
'openPanel',
44+
component: 'components.slideovers.article-form',
45+
arguments: ['articleId' => $arguments['article']]
46+
)
47+
);
4048
}
4149
50+
public function deleteAction(): Action
51+
{
52+
return Action::make('delete')
53+
->label(__('actions.delete'))
54+
->color('danger')
55+
->requiresConfirmation()
56+
->action(function (array $arguments): void {
57+
$article = Article::query()->find($arguments['article']);
58+
59+
app(ArticleDeleteAction::class)->execute($article);
60+
61+
Notification::make()
62+
->success()
63+
->title(__('notifications.article.deleted'))
64+
->send();
65+
});
66+
}
4267
};
4368
?>
4469

4570
<div xmlns:x-filament-action="http://www.w3.org/1999/html">
4671
<main class="lg:col-span-9">
4772
<div class="md:flex md:items-center md:justify-between">
4873
<div class="min-w-0 flex-1">
49-
<h2 class="font-heading text-lg font-bold leading-7 text-gray-900 sm:truncate sm:text-xl">
74+
<h2 class="font-heading text-lg font-bold leading-7 text-gray-900 sm:truncate sm:text-xl dark:text-white">
5075
{{ __('pages/article.your_article') }}
5176
</h2>
5277
</div>
5378
<div class="mt-4 flex md:ml-4 md:mt-0">
5479
<x-buttons.primary class="justify-items-center" type="button"
5580
onclick="Livewire.dispatch('openPanel', { component: 'components.slideovers.article-form' })">
5681
<x-untitledui-message-text-square class="size-5 mr-2" aria-hidden="true" />
57-
{{ __('Rédiger un article') }}
82+
{{ __('pages/article.new_article') }}
5883
</x-buttons.primary>
5984
</div>
6085
</div>
6186

6287
<div class="mt-5 space-y-4">
6388

6489
@forelse ($this->articles as $article)
65-
<div
90+
<div wire:key="{{ $article->id }}"
6691
class="rounded-xl mb-8 p-6 cursor-pointer bg-white transition duration-200 ease-in-out dark:bg-gray-800 dark:ring-gray-800 dark:hover:bg-white/10 lg:py-5 lg:px-6">
6792
<div class="flex justify-between space-x-3">
6893
<div class="flex-1">
@@ -78,16 +103,24 @@ class="inline-flex items-center rounded-full bg-yellow-100 px-2.5 py-0.5 text-xs
78103
@endforeach
79104
</div>
80105
<div>
81-
@if ($article->isNotPublished())
82-
<button type="button"
83-
class="inline-flex rounded bg-warning-500 px-2.5 py-0.5 text-xs font-medium text-yellow-800"
84-
onclick="Livewire.dispatch('openPanel', { component: 'components.slideovers.article-form', arguments: { articleId: {{ $article->id }} }})">
85-
{{ __('actions.edit') }}
86-
</button>
87-
@endif
88-
89-
{{-- Mettre le bouton delete ici --}}
106+
@if ($article->isNotPublished())
107+
@can('update', $article)
108+
{{ $this->editAction()(['article' => $article->id]) }}
109+
@endcan
110+
@endif
90111

112+
@if ($article->isPublished())
113+
<a
114+
href="{{ route('articles.show', $article->slug) }}"
115+
class="inline-flex items-center px-3 py-1.5 text-sm font-medium rounded-md bg-green-100 text-green-800 hover:bg-green-200 transition-colors"
116+
>
117+
{{ __('actions.view') }}
118+
</a>
119+
@endif
120+
@can('delete', $article)
121+
{{ $this->deleteAction()(['article' => $article->id]) }}
122+
@endcan
123+
<x-filament-actions::modals />
91124
</div>
92125
</div>
93126

@@ -96,16 +129,6 @@ class="inline-flex rounded bg-warning-500 px-2.5 py-0.5 text-xs font-medium text
96129
<h3 class="font-heading/7 text-xl font-semibold text-gray-900 dark:text-white">
97130
{{ $article->title }}
98131
</h3>
99-
100-
<div class="flex items-center font-sans text-gray-400 dark:text-gray-500">
101-
@if ($article->isPublished())
102-
<a href="{{ route('articles.show', $article->slug) }}"
103-
class="hover:text-gray-500 dark:text-gray-400 hover:underline">
104-
Voir
105-
</a>
106-
<span class="mx-1">&middot;</span>
107-
@endif
108-
</div>
109132
</div>
110133

111134
<p class="mt-3 text-base font-normal leading-6 text-gray-500 dark:text-white">
@@ -157,7 +180,7 @@ class="hover:text-gray-500 dark:text-gray-400 hover:underline">
157180
</div>
158181
</div>
159182
@empty
160-
<p class="text-base text-gray-500 dark:text-gray-400">Vous n'avez pas encore créé d'articles.</p>
183+
<p class="text-base text-gray-500 dark:text-gray-400">{{ __('pages/article.not_article_created') }}.</p>
161184
@endforelse
162185

163186
</div>

0 commit comments

Comments
 (0)