Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React rewrite #42

Merged
merged 79 commits into from Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
5e6670a
updated Composer dependencies
Kaishiyoku Mar 8, 2024
c405664
updated npm dependencies
Kaishiyoku Mar 8, 2024
cf7f584
added basic layout and router skeleton
Kaishiyoku Mar 8, 2024
7781144
refactored code
Kaishiyoku Mar 8, 2024
c3e1625
set page title properly
Kaishiyoku Mar 8, 2024
0561fd2
optimized category creation page
Kaishiyoku Mar 9, 2024
2b3db08
added the ability to edit categories
Kaishiyoku Mar 9, 2024
ec07387
adjusted label layout
Kaishiyoku Mar 9, 2024
edc14e7
added close button to modals
Kaishiyoku Mar 9, 2024
1bde314
added navigation dropdown
Kaishiyoku Mar 9, 2024
3570ad9
get user data for layout
Kaishiyoku Mar 9, 2024
c90932c
adjusted progress bar color
Kaishiyoku Mar 9, 2024
bb3cb00
open category forms in a pane instead of a modal
Kaishiyoku Mar 9, 2024
b16f013
refactored code
Kaishiyoku Mar 9, 2024
c8f011d
refactored code
Kaishiyoku Mar 10, 2024
c6af55b
added logout and authentication checks to application
Kaishiyoku Mar 10, 2024
4c197d6
added checks if you can create a new category
Kaishiyoku Mar 10, 2024
c58bbe0
added the ability to delete categories
Kaishiyoku Mar 10, 2024
a091b93
refactored code
Kaishiyoku Mar 10, 2024
8ca2ad0
renamed some files
Kaishiyoku Mar 10, 2024
fed1415
adjusted link stack styles
Kaishiyoku Mar 10, 2024
7316700
adjusted navigation styles
Kaishiyoku Mar 10, 2024
56084e2
added the ability to add feeds
Kaishiyoku Mar 10, 2024
e1cad3c
added spacer between feeds and logout link
Kaishiyoku Mar 11, 2024
a31f286
added the ability to edit and delete feeds
Kaishiyoku Mar 11, 2024
e69b437
refactored code
Kaishiyoku Mar 11, 2024
ebca2ee
refactored code
Kaishiyoku Mar 11, 2024
929c77d
refactored code
Kaishiyoku Mar 11, 2024
6c821dd
added missing translation
Kaishiyoku Mar 11, 2024
1610173
minor layout adjustments
Kaishiyoku Mar 11, 2024
9666149
added mobile navigation
Kaishiyoku Mar 11, 2024
0a70867
adjusted routes
Kaishiyoku Mar 12, 2024
b2bb21e
added the ability to load feed items
Kaishiyoku Mar 12, 2024
5978200
added the ability to mark unread feed items as read
Kaishiyoku Mar 13, 2024
f7955a8
added feed item cards
Kaishiyoku Mar 13, 2024
e8bbd08
added total feed items count context
Kaishiyoku Mar 13, 2024
6caa6b6
fixed total feed items count context updates
Kaishiyoku Mar 13, 2024
5888112
fixed feed item handling
Kaishiyoku Mar 14, 2024
1eb2ce6
minor layout adjustments
Kaishiyoku Mar 14, 2024
8baf109
prevent scrolling when mobile navigation menu is open
Kaishiyoku Mar 15, 2024
26a8475
added link to Laravel Telescope
Kaishiyoku Mar 15, 2024
c2396fd
added user management page
Kaishiyoku Mar 15, 2024
8a1517a
fixed usersLoader exception handling
Kaishiyoku Mar 15, 2024
0a6f2f7
added the ability to update profile information
Kaishiyoku Mar 15, 2024
1fd6f90
added the ability to change your password
Kaishiyoku Mar 15, 2024
d67c7e6
added the ability to delete your profile
Kaishiyoku Mar 15, 2024
0f33e12
added toast messages and 404 error page
Kaishiyoku Mar 15, 2024
018b591
adjusted error page layout
Kaishiyoku Mar 15, 2024
e29ec0b
adjusted table styles
Kaishiyoku Mar 15, 2024
cb543ee
adjusted link stack styles
Kaishiyoku Mar 15, 2024
9ee727d
reorganized files
Kaishiyoku Mar 15, 2024
60da69b
renamed request function
Kaishiyoku Mar 15, 2024
03bb8aa
fixed ESLint warnings
Kaishiyoku Mar 15, 2024
1c4b841
fixed category controller tests
Kaishiyoku Mar 16, 2024
5a4e64e
fixed dashboard controller tests
Kaishiyoku Mar 16, 2024
5466cfa
fixed feed controller tests
Kaishiyoku Mar 16, 2024
1dbbb37
fixed ToggleFeedItemController tests
Kaishiyoku Mar 16, 2024
8d83031
fixed MarkAllUnreadFeedItemsAsReadController tests
Kaishiyoku Mar 16, 2024
0e8823c
fixed FeedUrlDiscovererController tests
Kaishiyoku Mar 16, 2024
146ae60
fixed FeedDiscovererController tests
Kaishiyoku Mar 16, 2024
b42bba3
fixed UserWithFeedsCountAndUnreadFeedItemsCount tests
Kaishiyoku Mar 16, 2024
4f9ab03
adjusted feed model casts
Kaishiyoku Mar 16, 2024
8e85c08
fixed ProfileController tests
Kaishiyoku Mar 16, 2024
12979d0
fixed UserController tests
Kaishiyoku Mar 16, 2024
6d58a5f
fixed administrate middleware tests
Kaishiyoku Mar 16, 2024
99eb598
adjusted administrate middleware
Kaishiyoku Mar 16, 2024
c65b172
fixed code style
Kaishiyoku Mar 19, 2024
4a17b5f
fixed code inspection warnings
Kaishiyoku Mar 19, 2024
3c96ae3
fixed npm build
Kaishiyoku Mar 19, 2024
9179763
adjusted vite.config.mjs
Kaishiyoku Mar 19, 2024
b727151
adjusted vite.config.mjs
Kaishiyoku Mar 19, 2024
3d1f117
adjusted app.tsx
Kaishiyoku Mar 19, 2024
0deb7fb
fixed feed item toggle request
Kaishiyoku Mar 19, 2024
f5f569f
fixed "mark all as read" request
Kaishiyoku Mar 20, 2024
bacaa8b
fixed "home" link
Kaishiyoku Mar 20, 2024
10130c3
added "home" link to navigation dropdown
Kaishiyoku Mar 20, 2024
353ed6e
minor layout adjustments
Kaishiyoku Mar 20, 2024
d51789b
adjsuted mobile navigation menu style
Kaishiyoku Mar 20, 2024
54d24b4
adjusted tests
Kaishiyoku Mar 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,13 +1,11 @@
<?php

namespace App\Http\Controllers\Admin;
namespace App\Http\Controllers\Api\Admin;

use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\RedirectResponse;
use Inertia\Inertia;
use Inertia\Response;
use Illuminate\Http\JsonResponse;

class UserController extends Controller
{
Expand All @@ -19,9 +17,9 @@ public function __construct()
/**
* Display a listing of the resource.
*/
public function index(): Response
public function index(): JsonResponse
{
return Inertia::render('Admin/Users/Index', [
return response()->json([
'users' => User::orderBy('name')
->withCount([
'feeds',
Expand All @@ -36,13 +34,13 @@ public function index(): Response
/**
* Remove the specified resource from storage.
*/
public function destroy(User $user): RedirectResponse
public function destroy(User $user): JsonResponse
{
$user->feedItems()->delete();
$user->feeds()->delete();
$user->categories()->delete();
$user->delete();

return redirect()->route('admin.users.index');
return response()->json();
}
}
29 changes: 29 additions & 0 deletions app/Http/Controllers/Api/Auth/PasswordController.php
@@ -0,0 +1,29 @@
<?php

namespace App\Http\Controllers\Api\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\Rules\Password;

class PasswordController extends Controller
{
/**
* Update the user's password.
*/
public function update(Request $request): JsonResponse
{
$validated = $request->validate([
'current_password' => ['required', 'current_password'],
'password' => ['required', Password::defaults(), 'confirmed'],
]);

$request->user()->update([
'password' => Hash::make($validated['password']),
]);

return response()->json();
}
}
@@ -1,14 +1,13 @@
<?php

namespace App\Http\Controllers;
namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Requests\StoreCategoryRequest;
use App\Http\Requests\UpdateCategoryRequest;
use App\Models\Category;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Auth;
use Inertia\Inertia;
use Inertia\Response;

class CategoryController extends Controller
{
Expand All @@ -20,42 +19,32 @@ public function __construct()
/**
* Display a listing of the resource.
*/
public function index(): Response
public function index(): JsonResponse
{
return Inertia::render('Categories/Index', [
return response()->json([
'categories' => Auth::user()->categories()->withCount('feeds')->get(),
'canCreate' => Auth::user()->can('create', Category::class),
]);
}

/**
* Show the form for creating a new resource.
*/
public function create(): Response
{
return Inertia::render('Categories/Create', [
'category' => new Category(),
]);
}

/**
* Store a newly created resource in storage.
*/
public function store(StoreCategoryRequest $request): RedirectResponse
public function store(StoreCategoryRequest $request): JsonResponse
{
$validated = $request->validated();

Auth::user()->categories()->save(new Category($validated));

return redirect()->route('categories.index');
return response()->json();
}

/**
* Show the form for editing the specified resource.
*/
public function edit(Category $category): Response
public function edit(Category $category): JsonResponse
{
return Inertia::render('Categories/Edit', [
return response()->json([
'category' => $category,
'canDelete' => Auth::user()->can('delete', $category),
]);
Expand All @@ -64,22 +53,22 @@ public function edit(Category $category): Response
/**
* Update the specified resource in storage.
*/
public function update(UpdateCategoryRequest $request, Category $category): RedirectResponse
public function update(UpdateCategoryRequest $request, Category $category): JsonResponse
{
$validated = $request->validated();

$category->update($validated);

return redirect()->route('categories.index');
return response()->json();
}

/**
* Remove the specified resource from storage.
*/
public function destroy(Category $category): RedirectResponse
public function destroy(Category $category): JsonResponse
{
$category->delete();

return redirect()->route('categories.index');
return response()->json();
}
}
@@ -1,20 +1,20 @@
<?php

namespace App\Http\Controllers;
namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Requests\DashboardRequest;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\JsonResponse;
use Illuminate\Routing\ResponseFactory;
use Illuminate\Support\Facades\Auth;
use Inertia\Inertia;
use Inertia\Response;

class DashboardController extends Controller
{
/**
* Handle the incoming request.
*/
public function __invoke(DashboardRequest $request): RedirectResponse|Response
public function __invoke(DashboardRequest $request): ResponseFactory|JsonResponse
{
$feedId = $request->exists('feed_id') ? $request->integer('feed_id') : null;

Expand All @@ -32,12 +32,7 @@ public function __invoke(DashboardRequest $request): RedirectResponse|Response
->cursorPaginate()
->withQueryString();

// if feed filtering is active and there are no unread feed items go back to dashboard without query strings
if ($feedId && $feedItems->isEmpty()) {
return redirect()->route('dashboard');
}

return Inertia::render('Dashboard', [
return response()->json([
'selectedFeed' => $feedId ? $unreadFeeds->firstWhere('id', $feedId) : null,
'totalNumberOfFeedItems' => $totalNumberOfFeedItems,
'unreadFeeds' => $unreadFeeds,
Expand Down
@@ -1,15 +1,15 @@
<?php

namespace App\Http\Controllers;
namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Requests\StoreFeedRequest;
use App\Http\Requests\UpdateFeedRequest;
use App\Models\Feed;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use Inertia\Inertia;
use Inertia\Response;

class FeedController extends Controller
{
Expand All @@ -21,9 +21,9 @@ public function __construct()
/**
* Display a listing of the resource.
*/
public function index(): Response
public function index(): JsonResponse
{
return Inertia::render('Feeds/Index', [
return response()->json([
'feeds' => Auth::user()->feeds()->with('category')->withCount('feedItems')->get(),
'canCreate' => Auth::user()->can('create', Feed::class),
]);
Expand All @@ -32,18 +32,17 @@ public function index(): Response
/**
* Show the form for creating a new resource.
*/
public function create(): Response
public function create(): JsonResponse
{
return Inertia::render('Feeds/Create', [
'categories' => Auth::user()->categories()->pluck('name', 'id')->map(fn (string $name, int $id) => ['value' => $id, 'name' => $name])->values(),
'feed' => new Feed(),
return response()->json([
'categories' => $this->categories(),
]);
}

/**
* Store a newly created resource in storage.
*/
public function store(StoreFeedRequest $request): RedirectResponse
public function store(StoreFeedRequest $request): JsonResponse
{
$validated = $request->validated();

Expand All @@ -52,16 +51,16 @@ public function store(StoreFeedRequest $request): RedirectResponse

Auth::user()->feeds()->save($feed);

return redirect()->route('feeds.index');
return response()->json();
}

/**
* Show the form for editing the specified resource.
*/
public function edit(Feed $feed): Response
public function edit(Feed $feed): JsonResponse
{
return Inertia::render('Feeds/Edit', [
'categories' => Auth::user()->categories()->pluck('name', 'id')->map(fn (string $name, int $id) => ['value' => $id, 'name' => $name])->values(),
return response()->json([
'categories' => $this->categories(),
'feed' => $feed,
'canDelete' => Auth::user()->can('delete', $feed),
]);
Expand All @@ -70,7 +69,7 @@ public function edit(Feed $feed): Response
/**
* Update the specified resource in storage.
*/
public function update(UpdateFeedRequest $request, Feed $feed): RedirectResponse
public function update(UpdateFeedRequest $request, Feed $feed): JsonResponse
{
$validated = $request->validated();

Expand All @@ -79,17 +78,25 @@ public function update(UpdateFeedRequest $request, Feed $feed): RedirectResponse

$feed->save();

return redirect()->route('feeds.index');
return response()->json();
}

/**
* Remove the specified resource from storage.
*/
public function destroy(Feed $feed): RedirectResponse
public function destroy(Feed $feed): JsonResponse
{
$feed->feedItems()->delete();
$feed->delete();

return redirect()->route('feeds.index');
return response()->json();
}

/**
* @return Collection<int, array{value: int, name: string}>
*/
private function categories(): Collection
{
return Auth::user()->categories()->pluck('name', 'id')->map(fn (string $name, int $id) => ['value' => $id, 'name' => $name])->values();
}
}
@@ -1,10 +1,12 @@
<?php

namespace App\Http\Controllers;
namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Requests\FeedDiscovererRequest;
use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Exception\ConnectException;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Arr;
use Kaishiyoku\HeraRssCrawler\HeraRssCrawler;

Expand All @@ -13,11 +15,10 @@ class FeedDiscovererController extends Controller
/**
* Handle the incoming request.
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Exception
*/
public function __invoke(FeedDiscovererRequest $request, HeraRssCrawler $heraRssCrawler)
public function __invoke(FeedDiscovererRequest $request, HeraRssCrawler $heraRssCrawler): JsonResponse
{
$validated = $request->validated();

Expand Down
@@ -1,7 +1,8 @@
<?php

namespace App\Http\Controllers;
namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Requests\FeedUrlDiscovererRequest;
use Illuminate\Support\Arr;
use Kaishiyoku\HeraRssCrawler\HeraRssCrawler;
Expand Down
@@ -1,23 +1,25 @@
<?php

namespace App\Http\Controllers;
namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class MarkAllUnreadFeedItemsAsReadController extends Controller
{
/**
* Handle the incoming request.
*
* @return void
*/
public function __invoke(Request $request)
public function __invoke(Request $request): JsonResponse
{
$now = now();

Auth::user()->feedItems()->unread()->update([
'read_at' => $now,
]);

return response()->json();
}
}