diff --git a/CHANGELOG.md b/CHANGELOG.md index 367afbc21..0eb452440 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - Update AdminCuratedRegisterController, show oldest applications first ([c4dde641](https://github.com/pixelfed/pixelfed/commit/c4dde641)) - Update Directory logic, add curated onboarding support ([59c70239](https://github.com/pixelfed/pixelfed/commit/59c70239)) - Update Inbox and StatusObserver, fix silently rejected direct messages due to saveQuietly which failed to generate a snowflake id ([089ba3c4](https://github.com/pixelfed/pixelfed/commit/089ba3c4)) +- Update Curated Onboarding dashboard, improve application filtering and make it easier to distinguish response state ([2b5d7235](https://github.com/pixelfed/pixelfed/commit/2b5d7235)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.12 (2024-02-16)](https://github.com/pixelfed/pixelfed/compare/v0.11.11...v0.11.12) diff --git a/app/Http/Controllers/AdminCuratedRegisterController.php b/app/Http/Controllers/AdminCuratedRegisterController.php index b28fa438f..1bed66b7c 100644 --- a/app/Http/Controllers/AdminCuratedRegisterController.php +++ b/app/Http/Controllers/AdminCuratedRegisterController.php @@ -22,27 +22,43 @@ class AdminCuratedRegisterController extends Controller public function index(Request $request) { $this->validate($request, [ - 'filter' => 'sometimes|in:open,all,awaiting,approved,rejected' + 'filter' => 'sometimes|in:open,all,awaiting,approved,rejected,responses', + 'sort' => 'sometimes|in:asc,desc' ]); $filter = $request->input('filter', 'open'); + $sort = $request->input('sort', 'asc'); $records = CuratedRegister::when($filter, function($q, $filter) { if($filter === 'open') { return $q->where('is_rejected', false) + ->where(function($query) { + return $query->where('user_has_responded', true)->orWhere('is_awaiting_more_info', false); + }) ->whereNotNull('email_verified_at') ->whereIsClosed(false); } else if($filter === 'all') { return $q; + } else if($filter === 'responses') { + return $q->whereIsClosed(false) + ->whereNotNull('email_verified_at') + ->where('user_has_responded', true) + ->where('is_awaiting_more_info', true); } elseif ($filter === 'awaiting') { return $q->whereIsClosed(false) - ->whereNull('is_rejected') - ->whereNull('is_approved'); + ->where('is_rejected', false) + ->where('is_approved', false) + ->where('user_has_responded', false) + ->where('is_awaiting_more_info', true); } elseif ($filter === 'approved') { return $q->whereIsClosed(true)->whereIsApproved(true); } elseif ($filter === 'rejected') { return $q->whereIsClosed(true)->whereIsRejected(true); } }) - ->paginate(10); + ->when($sort, function($query, $sort) { + return $query->orderBy('id', $sort); + }) + ->paginate(10) + ->withQueryString(); return view('admin.curated-register.index', compact('records', 'filter')); } @@ -160,6 +176,7 @@ class AdminCuratedRegisterController extends Controller $activity->message = $request->input('message'); $activity->save(); $record->is_awaiting_more_info = true; + $record->user_has_responded = false; $record->save(); Mail::to($record->email)->send(new CuratedRegisterRequestDetailsFromUser($record, $activity)); return $request->all(); diff --git a/app/Http/Controllers/CuratedRegisterController.php b/app/Http/Controllers/CuratedRegisterController.php index 73bd17bff..58bddb498 100644 --- a/app/Http/Controllers/CuratedRegisterController.php +++ b/app/Http/Controllers/CuratedRegisterController.php @@ -105,6 +105,7 @@ class CuratedRegisterController extends Controller 'action_required' => true, ]); + CuratedRegister::findOrFail($crid)->update(['user_has_responded' => true]); $request->session()->pull('cur-reg-con'); $request->session()->pull('cur-reg-con-attempt'); diff --git a/app/Models/CuratedRegister.php b/app/Models/CuratedRegister.php index edb4e1b22..eeeb82784 100644 --- a/app/Models/CuratedRegister.php +++ b/app/Models/CuratedRegister.php @@ -9,25 +9,43 @@ class CuratedRegister extends Model { use HasFactory; + protected $fillable = [ + 'user_has_responded' + ]; + protected $casts = [ 'autofollow_account_ids' => 'array', 'admin_notes' => 'array', 'email_verified_at' => 'datetime', 'admin_notified_at' => 'datetime', 'action_taken_at' => 'datetime', + 'user_has_responded' => 'boolean', + 'is_awaiting_more_info' => 'boolean', + 'is_accepted' => 'boolean', + 'is_rejected' => 'boolean', + 'is_closed' => 'boolean', ]; public function adminStatusLabel() { + if($this->user_has_responded) { + return 'Awaiting Admin Response'; + } if(!$this->email_verified_at) { return 'Unverified email'; } - if($this->is_accepted) { return 'Approved'; } - if($this->is_rejected) { return 'Rejected'; } - if($this->is_awaiting_more_info ) { - return 'Awaiting Details'; + if($this->is_approved) { + return 'Approved'; + } + if($this->is_rejected) { + return 'Rejected'; + } + if($this->is_awaiting_more_info ) { + return 'Awaiting User Response'; + } + if($this->is_closed ) { + return 'Closed'; } - if($this->is_closed ) { return 'Closed'; } return 'Open'; } diff --git a/database/migrations/2024_02_24_093824_add_has_responded_to_curated_registers_table.php b/database/migrations/2024_02_24_093824_add_has_responded_to_curated_registers_table.php new file mode 100644 index 000000000..9453a73d7 --- /dev/null +++ b/database/migrations/2024_02_24_093824_add_has_responded_to_curated_registers_table.php @@ -0,0 +1,36 @@ +boolean('user_has_responded')->default(false)->index()->after('is_awaiting_more_info'); + }); + + CuratedRegisterActivity::whereFromUser(true)->get()->each(function($cra) { + $cr = CuratedRegister::find($cra->register_id); + $cr->user_has_responded = true; + $cr->save(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('curated_registers', function (Blueprint $table) { + $table->dropColumn('user_has_responded'); + }); + } +}; diff --git a/resources/views/admin/curated-register/index.blade.php b/resources/views/admin/curated-register/index.blade.php index 1094e9113..5ff8c4dd5 100644 --- a/resources/views/admin/curated-register/index.blade.php +++ b/resources/views/admin/curated-register/index.blade.php @@ -26,7 +26,7 @@ ID Username - @if(in_array($filter, ['all', 'open'])) + @if(in_array($filter, ['all', 'open', 'awaiting', 'responses'])) Status @endif Reason for Joining @@ -47,7 +47,7 @@ @{{ $record->username }}

- @if(in_array($filter, ['all', 'open'])) + @if(in_array($filter, ['all', 'open', 'awaiting', 'responses'])) {!! $record->adminStatusLabel() !!} diff --git a/resources/views/admin/curated-register/partials/nav.blade.php b/resources/views/admin/curated-register/partials/nav.blade.php index 16241997e..b23cc8dcc 100644 --- a/resources/views/admin/curated-register/partials/nav.blade.php +++ b/resources/views/admin/curated-register/partials/nav.blade.php @@ -18,16 +18,19 @@ Open Applications +