Skip to content

Commit

Permalink
Migrated to Mailcoach v8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Combind committed Apr 11, 2024
1 parent c0ac788 commit 81aedca
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 133 deletions.
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
],
"require": {
"php": "^8.3",
"filament/actions": "^3.2",
"filament/forms": "^3.2",
"illuminate/contracts": "^10.0|^11.0",
"laravel/sanctum": "^3.3|^4.0",
"laravel/ui": "^4.4",
Expand Down
2 changes: 1 addition & 1 deletion resources/views/auth/layout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<span class="flex w-10 h-6 text-white transform group-hover:scale-90 transition-transform duration-150">
@include('mailcoach::app.layouts.partials.logoSvg')
</span>
<span class="text-white uppercase text-xs font-bold tracking-wider">Mailcoach</span>
<span class="text-white uppercase text-xs font-bold tracking-wider">{{ config('app.name') }}</span>
</a>
</header>
<main class="p-6 md:p-10">
Expand Down
93 changes: 40 additions & 53 deletions resources/views/auth/login.blade.php
Original file line number Diff line number Diff line change
@@ -1,54 +1,41 @@
@extends('mailcoach-skeleton::auth.layout', ['title' => __mc('Log in')])

@section('content')
<h1 class="markup-h2">{{ __mc('Log in') }}</h1>

<form class="form-grid" method="POST" action="{{ route('login') }}">
@csrf

<div class="form-field">
@error('email')
<p class="form-error" role="alert">
{{ $message }}
</p>
@enderror

<label for="email" class="label">{{ __mc('Email') }}</label>

<input id="email" type="email" class="input @error('email') is-invalid @enderror" name="email"
value="{{ old('email') }}" required autocomplete="email" autofocus>
</div>

<div class="form-field">
@error('password')
<p class="form-error" role="alert">
{{ $message }}
</p>
@enderror

<label for="password" class="label">{{ __mc('Password') }}</label>

<input id="password" type="password" class="input @error('password') is-invalid @enderror"
name="password" required autocomplete="current-password">
<x-mailcoach::layout :title="__mc('Login')" hide-footer hide-nav>
<div class="flex flex-col gap-6 justify-center mt-12">
<div class="w-20 mx-auto">
@include('mailcoach::app.layouts.partials.logoSvg')
</div>

<div class="form-field">
<label class="checkbox-label" for="remember">
<input class="checkbox" type="checkbox" name="remember" id="remember"
{{ old('remember') ? 'checked' : '' }}>

{{ __mc('Remember me next time') }}
</label>
</div>

<x-mailcoach::form-buttons>
<x-mailcoach::button :label="__mc('Log in')" />

@if (Route::has('forgot-password'))
<a class="link ml-2" href="{{ route('forgot-password') }}">
{{ __mc('Forgot Your Password?') }}
</a>
@endif
</x-mailcoach::form-buttons>
</form>
@endsection
<x-mailcoach::fieldset class="w-full max-w-md mx-auto" card :legend="__mc('Log in')">
<form class="form-grid" method="POST" action="{{ route('login') }}">
@csrf

<x-mailcoach::text-field
:label="__mc('Email')"
name="email"
type="email"
autofocus
autocomplete="email"
required
/>

<x-mailcoach::text-field
:label="__mc('Password')"
name="password"
type="password"
autocomplete="current-password"
required
/>

<x-mailcoach::form-buttons>
<x-mailcoach::button :label="__mc('Log in')" />

@if (Route::has('forgot-password'))
<a class="ml-3" href="{{ route('forgot-password') }}">
<x-mailcoach::button-link
:label="__mc('Forgot Your Password?')"
/>
</a>
@endif
</x-mailcoach::form-buttons>
</form>
</x-mailcoach::fieldset>
</div>
</x-mailcoach::layout>
73 changes: 34 additions & 39 deletions resources/views/auth/welcome.blade.php
Original file line number Diff line number Diff line change
@@ -1,40 +1,35 @@
@extends('mailcoach-skeleton::auth.layout', ['title' => __mc('Welcome')])
@section('content')
<h1 class="markup-h2">{{ __mc('Welcome') }}</h1>

<form class="form-grid" method="POST">
@csrf

<input type="hidden" name="email" value="{{ $user->email }}"/>

<div class="form-field">
@error('password')
<p class="form-error" role="alert">
{{ $message }}
</p>
@enderror

<label for="password" class="label">{{ __mc('Password') }}</label>

<input id="password" type="password" class="input @error('password') is-invalid @enderror"
name="password" required autocomplete="new-password">
<x-mailcoach::layout :title="__mc('Welcome')" hide-footer hide-nav>
<div class="flex flex-col gap-6 justify-center mt-12">
<div class="w-20 mx-auto">
@include('mailcoach::app.layouts.partials.logoSvg')
</div>

<div class="form-field">
@error('password_confirmation')
<p class="form-error" role="alert">
{{ $message }}
</p>
@enderror

<label for="password_confirmation" class="label">{{ __mc('Confirm Password') }}</label>

<input id="password_confirmation" type="password" class="input @error('password_confirmation') is-invalid @enderror"
name="password_confirmation" required autocomplete="new-password">
</div>

<x-mailcoach::form-buttons>
<x-mailcoach::button :label="__mc('Save password and login')" />
</x-mailcoach::form-buttons>
</form>
@endsection
<x-mailcoach::fieldset class="w-full max-w-md mx-auto" card :legend="__mc('Welcome')">
<p>{{ __mc('Welcome to Mailcoach! Choose a password:') }}</p>
<form class="form-grid" method="POST">
@csrf

<input type="hidden" name="email" value="{{ $user->email }}"/>

<x-mailcoach::text-field
:label="__mc('Password')"
name="password"
type="password"
autocomplete="new-password"
required
/>

<x-mailcoach::text-field
:label="__mc('Confirm password')"
name="password_confirmation"
type="password"
autocomplete="new-password"
required
/>

<x-mailcoach::form-buttons>
<x-mailcoach::button :label="__mc('Save password and login')" />
</x-mailcoach::form-buttons>
</form>
</x-mailcoach::fieldset>
</div>
</x-mailcoach::layout>
41 changes: 20 additions & 21 deletions resources/views/livewire/account.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
</form>

<x-mailcoach::fieldset card :legend="__mc('API Tokens')">
<x-mailcoach::help>
<x-mailcoach::alert type="help">
{!! __mc('You can use tokens to authenticate with the Mailcoach API. You\'ll find more info in <a href=":docsUrl" target="_blank">our docs</a>.', [
'docsUrl' => 'https://mailcoach.app/docs'
]) !!}
</x-mailcoach::help>
'docsUrl' => 'https://mailcoach.app/docs'
]) !!}
</x-mailcoach::alert>

<form
wire:submit="saveToken"
Expand Down Expand Up @@ -71,40 +71,39 @@


@if ($newToken)
<x-mailcoach::help>
<x-mailcoach::alert type="help">
<p class="mb-2">
{{ __mc('We will display this token only once. Make sure to copy it to a safe place.') }}
</p>

<x-mailcoach::code-copy :code="$newToken"/>
</x-mailcoach::help>
</x-mailcoach::alert>
@endif
</x-mailcoach::fieldset>

@if (count($tokens))
<x-mailcoach::card class="p-0">
<table class="table-styled">
@if (count($tokens))
<table class="fi-ta fi-ta-table min-w-full border-separate">
<thead>
<tr>
<x-mailcoach::th>{{ __mc('Name') }}</x-mailcoach::th>
<x-mailcoach::th>{{ __mc('Last used at') }}</x-mailcoach::th>
<th class="fi-ta-cell fi-ta-text-item px-3 py-4 text-left">{{ __mc('Name') }}</th>
<th class="fi-ta-cell fi-ta-text-item px-3 py-4 text-left">{{ __mc('Last used at') }}</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach($tokens as $token)
<tr>
<td>{{ $token->name }}</td>
<td>{{ $token->last_used_at ?? 'Not used yet' }}</td>
<td class="td-action">
<x-mailcoach::confirm-button :confirm-text="__mc('Are you sure you want to delete this token?')" on-confirm="() => $wire.deleteToken({{ $token->id }})">
<x-mailcoach::icon-label icon="far fa-trash-alt" :caution="true"/>
</x-mailcoach::confirm-button>
<tr class="fi-ta-row">
<td class="fi-ta-cell fi-ta-text-item px-3 py-4">{{ $token->name }}</td>
<td class="fi-ta-cell fi-ta-text-item px-3 py-4">{{ $token->last_used_at ?? 'Not used yet' }}</td>
<td class="fi-ta-cell fi-ta-text-item px-3 py-4 text-right">
{{ ($this->deleteTokenAction)(['token' => $token->id]) }}
</td>
</tr>
@endforeach
</tbody>
</table>
</x-mailcoach::card>
@endif
@endif
</x-mailcoach::fieldset>


<x-filament-actions::modals />
</div>
6 changes: 3 additions & 3 deletions resources/views/livewire/users/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

<x-mailcoach::text-field type="email" :label="__mc('Email')" wire:model="email" name="email" required />

<x-mailcoach::form-buttons>
<div class="form-buttons">
<x-mailcoach::button :label="__mc('Create new user')" />

<button type="button" class="button-cancel" x-on:click="$store.modals.close('create-user')">
<button type="button" class="button-link ml-4" x-on:click="$dispatch('close-modal', { id: 'create-user' })">
{{ __mc('Cancel') }}
</button>
</x-mailcoach::form-buttons>
</div>
</form>
2 changes: 1 addition & 1 deletion src/Http/Controllers/Auth/WelcomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public function sendPasswordSavedResponse(): Response
{
notify(__mc('Your password has been saved.'));

return redirect()->route('mailcoach.campaigns');
return redirect()->route('mailcoach.dashboard');
}
}
6 changes: 3 additions & 3 deletions src/Listeners/SetupMailcoach.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ public function handle(): void
MenuItem::make()
->label(__mc('Account'))
->url(route('account'))
->icon('fa-user'),
->icon('heroicon-s-user'),
MenuItem::make()
->label(__mc('Users'))
->url(route('users'))
->icon('fa-users'),
->icon('heroicon-s-user-group'),
);

Mailcoach::addUserMenuItemsAfter(
MenuItem::make()
->isForm()
->label(__mc('Log out'))
->url(route('logout'))
->icon('fa-power-off text-red-500'),
->icon('heroicon-s-arrow-right-start-on-rectangle'),
);

Mailcoach::addSettingsMenuItemsBefore(
Expand Down
38 changes: 30 additions & 8 deletions src/Livewire/AccountComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@

namespace Combindma\MailcoachSkeleton\Livewire;

use Filament\Actions\Action;
use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\Rule;
use Laravel\Sanctum\PersonalAccessToken;
use Livewire\Component;

class AccountComponent extends Component
class AccountComponent extends Component implements HasActions, HasForms
{
use InteractsWithActions;
use InteractsWithForms;

public string $email;

public string $name;
Expand Down Expand Up @@ -77,13 +84,28 @@ public function saveToken()
$this->tokenName = '';
}

public function deleteToken(PersonalAccessToken $token)
public function deleteTokenAction(): Action
{
abort_unless($token?->tokenable_id === Auth::id(), 403);

$token->delete();

notify(__mc('The token has been deleted.'));
return Action::make('deleteToken')
->requiresConfirmation()
->icon('heroicon-s-trash')
->color('danger')
->link()
->label('')
->tooltip(__mc('Delete token'))
->modalIcon('heroicon-s-trash')
->modalHeading(__mc('Delete token'))
->modalDescription(__mc('Are you sure you want to delete this token?'))
->modalCloseButton(false)
->action(function (array $arguments) {
$token = Auth::user()->personalAccessTokens->find($arguments['token']);

abort_unless($token, 404);

$token->delete();

notify(__mc('The token has been deleted.'));
});
}

public function render()
Expand Down
11 changes: 7 additions & 4 deletions src/Livewire/CreateUserComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
namespace Combindma\MailcoachSkeleton\Livewire;

use App\Models\User;
use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Illuminate\Validation\Rule;
use Livewire\Component;

class CreateUserComponent extends Component
class CreateUserComponent extends Component implements HasActions, HasForms
{
public string $email = '';

public string $name = '';
use InteractsWithActions;
use InteractsWithForms;

public function saveUser()
{
Expand Down

0 comments on commit 81aedca

Please sign in to comment.