diff --git a/.github/release-notes.md b/.github/release-notes.md
index 18677ce..7d22463 100644
--- a/.github/release-notes.md
+++ b/.github/release-notes.md
@@ -1,5 +1,7 @@
Show a countdown to each server's next wipe on its console page, with an optional public page for Discord and websites.
+When Wipe & Season Manager is installed and a server has an enabled wipe plan, the countdown, the public page and its Discord preview follow that plan. Each schedule has its own time zone, so wipes stay at the same local time across daylight saving. See the changelog for everything in this release.
+
## Install
Download `next-wipe-${VERSION}.pteroext` below, then upload it under **Admin → Extensions** and enable it. From a terminal instead:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9993786..2c36d5f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,14 @@
# Changelog
+## 1.1.0
+
+- Works with Wipe & Season Manager. When that extension is installed and the server has an enabled plan, the countdown, the public page and its Discord link preview show that plan's next wipe, name and time zone, so they always match the Wipes tab. Skipping a wipe or changing a plan there updates them too. Without a plan, Next Wipe uses its own schedule as before.
+- While a plan drives the countdown, the Edit button is replaced by a Wipes button that opens the server's Wipes tab, and a Public page button that turns the public page on or off.
+- Each schedule now has a time zone. A 19:00 London wipe stays at 19:00 London time when the clocks change. New schedules start in your browser's time zone; existing schedules keep UTC until you change them.
+- Subusers with Wipe & Season Manager's manage permission can now change the wipe schedule too.
+- The console card matches the other console blocks: one row, standard buttons and spacing.
+- The public page shows the wipe time in the server's time zone as well as the visitor's, and includes a link preview for Discord. Its JSON adds `timezone` and `next_local`.
+
## 1.0.0
- First release.
diff --git a/README.md b/README.md
index 3eedcf2..783254d 100644
--- a/README.md
+++ b/README.md
@@ -4,17 +4,20 @@ Show a countdown to each server's next wipe on its console page, with an optiona
## Features
-- **Countdown on the console page**: "Map wipe · Every week, in 3d 4h 12m" with the date in each viewer's own time zone. Everyone who can see the server sees it.
+- **Countdown on the console page**: "Map wipe · Every week · Europe/London, in 3d 4h 12m" with the date in each viewer's own time zone, and in the schedule's time zone when that is different. Everyone who can see the server sees it.
- **Repeating schedules**: once, every week, every two weeks, every month on the same day, or the first Thursday of each month (Rust's forced wipe). The next wipe is worked out automatically.
-- **Subuser permission**: owners can manage the schedule, and subusers need the **Next Wipe → manage** permission to change it.
-- **Public page (opt-in)**: a link anyone can open, for Discord or your website, showing only the server name and wipe time. It can be embedded in an iframe, and adding `?format=json` returns the time for bots. Turning the page off makes the link stop working; turning it back on restores the same link.
+- **Time zones**: each schedule has its own time zone (new ones start in your browser's), and the wipe stays at the same local time when the clocks change for daylight saving.
+- **Works with Wipe & Season Manager**: when that extension is installed and the server has an enabled wipe plan, the countdown, the public page and its Discord preview follow the plan's next wipe (the earliest one when there are several), with its name and time zone. Skipping or running a wipe there updates them. The Edit button becomes a **Wipes** button that opens the server's Wipes tab, and a **Public page** button turns the public page on or off. With no plan, Next Wipe uses its own schedule.
+- **Subuser permission**: owners can manage the schedule, and subusers need the **Next Wipe → manage** or **Wipe & Season Manager → manage** permission to change it.
+- **Public page (opt-in)**: a link anyone can open, for Discord or your website, showing only the server name and wipe time. Pasted into Discord it shows a preview with the next wipe. It can be embedded in an iframe, and adding `?format=json` returns the time for bots (`next_at`, `next_unix`, `timezone`, `next_local`). Turning the page off makes the link stop working; turning it back on restores the same link.
## API
| Method | Path | Who |
|---|---|---|
| GET | `/api/client/servers/{server}/extensions/next-wipe/wipe` | Anyone who can see the server |
-| PUT, DELETE | `/api/client/servers/{server}/extensions/next-wipe/wipe` | Owner, admins, subusers with `ext.next-wipe.manage` |
+| PUT, DELETE | `/api/client/servers/{server}/extensions/next-wipe/wipe` | Owner, admins, subusers with `ext.next-wipe.manage` or `ext.wipe-season-manager.manage` |
+| PUT | `/api/client/servers/{server}/extensions/next-wipe/wipe/public` | Same as above; turns only the public page on or off |
| GET | `/extensions/next-wipe/s/{token}` | Anyone, when the server's public page is on (`?format=json` for JSON) |
## Requirements
diff --git a/database/migrations/2026_10_13_000302_add_timezone_to_next_wipe_schedules_table.php b/database/migrations/2026_10_13_000302_add_timezone_to_next_wipe_schedules_table.php
new file mode 100644
index 0000000..aa0dd87
--- /dev/null
+++ b/database/migrations/2026_10_13_000302_add_timezone_to_next_wipe_schedules_table.php
@@ -0,0 +1,23 @@
+string('timezone', 64)->default('UTC')->after('repeat');
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::table('ext_next_wipe_schedules', function (Blueprint $table) {
+ $table->dropColumn('timezone');
+ });
+ }
+};
diff --git a/extension.json b/extension.json
index aacf1ba..af43a3f 100644
--- a/extension.json
+++ b/extension.json
@@ -2,7 +2,7 @@
"$schema": "./node_modules/@pterodactyl/sdk/manifest.schema.json",
"id": "next-wipe",
"name": "Next Wipe",
- "version": "1.0.0",
+ "version": "1.1.0",
"description": "Show a countdown to each server's next wipe on its console page, with an optional public page for Discord and websites.",
"author": "RustixDev",
"icon": "calendar-clock",
diff --git a/package-lock.json b/package-lock.json
index 42d6576..4c5baff 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "next-wipe",
- "version": "1.0.0",
+ "version": "1.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "next-wipe",
- "version": "1.0.0",
+ "version": "1.1.0",
"devDependencies": {
"@base-ui/react": "^1.6.0",
"@pterodactyl/sdk": "file:./sdk/pterodactyl-sdk-2.0.0-beta.4.tgz",
diff --git a/package.json b/package.json
index d830672..5e153fe 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "next-wipe",
"private": true,
- "version": "1.0.0",
+ "version": "1.1.0",
"type": "module",
"scripts": {
"build": "vite build",
diff --git a/resources/views/public.blade.php b/resources/views/public.blade.php
index f920f17..cf16c88 100644
--- a/resources/views/public.blade.php
+++ b/resources/views/public.blade.php
@@ -4,6 +4,13 @@
{{ $label }} · {{ $server }}
+@php($summary = $next_local ? 'Next wipe: '.$next_local : 'No wipe scheduled')
+
+{{-- Discord and other sites build their link preview from these. --}}
+
+
+
+
@@ -21,7 +29,8 @@
{{ $label }}
@if ($next_unix)
{{ $next_at }}
-
{{ $next_at }} UTC
+
{{ $next_local }}
+
{{ $next_local }}
@else
No wipe scheduled
@endif
@@ -31,7 +40,9 @@
(function () {
var el = document.getElementById('count');
var at = Number(el.dataset.at) * 1000;
- document.getElementById('when').textContent = new Date(at).toLocaleString(undefined, { dateStyle: 'full', timeStyle: 'short' });
+ // The visitor's own time; the line under it keeps the server's time zone.
+ document.getElementById('when').textContent = new Date(at).toLocaleString(undefined, { dateStyle: 'full', timeStyle: 'short' }) + ' (your time)';
+ document.getElementById('zone').hidden = false;
function tick() {
var s = Math.max(0, Math.floor((at - Date.now()) / 1000));
var d = Math.floor(s / 86400), h = Math.floor(s % 86400 / 3600), m = Math.floor(s % 3600 / 60);
diff --git a/routes/server.php b/routes/server.php
index bf5a283..05c8e6a 100644
--- a/routes/server.php
+++ b/routes/server.php
@@ -3,7 +3,9 @@
use Illuminate\Support\Facades\Route;
use RustixDev\NextWipe\Http\Controllers\ServerWipeController;
-// Anyone who can see the server sees the countdown; changing it needs ext.next-wipe.manage.
+// Anyone who can see the server sees the countdown; changing it needs
+// ext.next-wipe.manage or ext.wipe-season-manager.manage.
Route::get('/wipe', [ServerWipeController::class, 'show']);
Route::put('/wipe', [ServerWipeController::class, 'update']);
+Route::put('/wipe/public', [ServerWipeController::class, 'updatePublic']);
Route::delete('/wipe', [ServerWipeController::class, 'destroy']);
diff --git a/src/Http/Controllers/PublicWipeController.php b/src/Http/Controllers/PublicWipeController.php
index 4ef7666..00679df 100644
--- a/src/Http/Controllers/PublicWipeController.php
+++ b/src/Http/Controllers/PublicWipeController.php
@@ -5,22 +5,29 @@
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use RustixDev\NextWipe\Models\WipeSchedule;
+use RustixDev\NextWipe\Support\UpcomingWipe;
use Symfony\Component\HttpFoundation\Response;
-/** The opt-in public page, for Discord bots and websites. Shows the server name and wipe time only. */
+/**
+ * The opt-in public page, for Discord and websites. Shows the server name and wipe
+ * time only. When Wipe & Season Manager has a plan for the server, its next wipe is shown.
+ */
class PublicWipeController
{
public function show(Request $request, string $token): Response
{
$schedule = WipeSchedule::query()->with('server:id,name')->where('public_token', $token)->where('public', true)->firstOrFail();
- $next = $schedule->next();
+ $upcoming = UpcomingWipe::forServer($schedule->server_id, $schedule);
+ $next = $upcoming?->nextAt;
$payload = [
'server' => $schedule->server->name,
- 'label' => $schedule->label,
+ 'label' => $upcoming->label ?? $schedule->label,
'next_at' => $next?->toIso8601String(),
'next_unix' => $next?->getTimestamp(),
- 'repeat' => $schedule->repeat,
+ 'repeat' => $upcoming->repeat ?? $schedule->repeat,
+ 'timezone' => $upcoming->timezone ?? 'UTC',
+ 'next_local' => $upcoming?->localDescription(),
];
$headers = ['Cache-Control' => 'public, max-age=60', 'Access-Control-Allow-Origin' => '*'];
diff --git a/src/Http/Controllers/ServerWipeController.php b/src/Http/Controllers/ServerWipeController.php
index 36547ff..af07843 100644
--- a/src/Http/Controllers/ServerWipeController.php
+++ b/src/Http/Controllers/ServerWipeController.php
@@ -2,6 +2,8 @@
namespace RustixDev\NextWipe\Http\Controllers;
+use Carbon\CarbonImmutable;
+use DateTimeZone;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
@@ -10,50 +12,113 @@
use Pterodactyl\Models\Server;
use RustixDev\NextWipe\Models\WipeSchedule;
use RustixDev\NextWipe\Support\NextOccurrence;
+use RustixDev\NextWipe\Support\UpcomingWipe;
+use RustixDev\NextWipe\Support\WipeSeasonManager;
class ServerWipeController
{
+ public const string PERMISSION = 'ext.next-wipe.manage';
+
public function show(Request $request, Server $server): JsonResponse
{
$schedule = WipeSchedule::query()->where('server_id', $server->id)->first();
- $canManage = $request->user()->can('ext.next-wipe.manage', $server);
- return new JsonResponse([
- 'data' => $schedule?->toPayload($canManage),
- 'can_manage' => $canManage,
- ]);
+ return new JsonResponse($this->payload($request, $server, $schedule));
}
public function update(Request $request, Server $server): JsonResponse
{
- abort_unless($request->user()->can('ext.next-wipe.manage', $server), 403);
+ $this->authorize($request, $server);
$data = $request->validate([
'label' => ['required', 'string', 'max:60'],
- 'anchor_at' => ['required', 'date'],
+ // The wall-clock time in `timezone`; `anchor_at` (an exact time) is still accepted from older clients.
+ 'anchor_local' => ['required_without:anchor_at', 'date_format:Y-m-d\TH:i'],
+ 'anchor_at' => ['required_without:anchor_local', 'date'],
+ 'timezone' => ['nullable', 'string', 'max:64', 'timezone:all_with_bc'],
'repeat' => ['required', Rule::in(NextOccurrence::REPEATS)],
'public' => ['boolean'],
- ], [], ['anchor_at' => 'next wipe', 'repeat' => 'repeat']);
+ ], [], ['anchor_local' => 'next wipe', 'anchor_at' => 'next wipe', 'repeat' => 'repeat', 'timezone' => 'time zone']);
+
+ $timezone = $data['timezone'] ?? 'UTC';
+ $anchor = isset($data['anchor_local'])
+ ? CarbonImmutable::createFromFormat('Y-m-d\TH:i', $data['anchor_local'], new DateTimeZone($timezone))
+ : CarbonImmutable::parse($data['anchor_at']);
$schedule = WipeSchedule::query()->firstOrNew(['server_id' => $server->id]);
$schedule->fill([
'label' => $data['label'],
- 'anchor_at' => $data['anchor_at'],
+ 'anchor_at' => $anchor->utc(),
'repeat' => $data['repeat'],
+ 'timezone' => $timezone,
'public' => (bool) ($data['public'] ?? false),
]);
$schedule->public_token ??= Str::random(32);
$schedule->save();
- return new JsonResponse(['data' => $schedule->toPayload(true), 'can_manage' => true]);
+ return new JsonResponse($this->payload($request, $server, $schedule));
+ }
+
+ /** Turn the public page on or off on its own, for servers whose wipes come from Wipe & Season Manager. */
+ public function updatePublic(Request $request, Server $server): JsonResponse
+ {
+ $this->authorize($request, $server);
+ $data = $request->validate(['public' => ['required', 'boolean']]);
+
+ $schedule = WipeSchedule::query()->firstOrNew(['server_id' => $server->id]);
+ if (! $schedule->exists) {
+ // Only the public page is used while Wipe & Season Manager has a plan.
+ $schedule->fill(['label' => 'Wipe', 'anchor_at' => CarbonImmutable::now()->startOfMinute(), 'repeat' => 'none', 'timezone' => 'UTC']);
+ }
+ $schedule->public = (bool) $data['public'];
+ $schedule->public_token ??= Str::random(32);
+ $schedule->save();
+
+ return new JsonResponse($this->payload($request, $server, $schedule));
}
public function destroy(Request $request, Server $server): Response
{
- abort_unless($request->user()->can('ext.next-wipe.manage', $server), 403);
+ $this->authorize($request, $server);
WipeSchedule::query()->where('server_id', $server->id)->delete();
return response()->noContent();
}
+
+ /** @return array */
+ private function payload(Request $request, Server $server, ?WipeSchedule $schedule): array
+ {
+ $canManage = $this->canManage($request, $server);
+ $upcoming = UpcomingWipe::forServer($server->id, $schedule);
+
+ return [
+ 'data' => $upcoming ? [
+ 'source' => $upcoming->source,
+ 'label' => $upcoming->label,
+ 'repeat' => $upcoming->repeat,
+ 'timezone' => $upcoming->timezone,
+ 'next_at' => $upcoming->nextAt?->toIso8601String(),
+ ] : null,
+ 'schedule' => $canManage ? $schedule?->toSettings() : null,
+ 'public' => (bool) $schedule?->public,
+ 'public_url' => $canManage ? $schedule?->publicUrl() : null,
+ 'can_manage' => $canManage,
+ // Whether this user can open the server's Wipes tab.
+ 'can_manage_plans' => WipeSeasonManager::available() && $request->user()->can(WipeSeasonManager::PERMISSION, $server),
+ ];
+ }
+
+ /** Next Wipe's own permission, or Wipe & Season Manager's, lets a subuser change the schedule. */
+ private function canManage(Request $request, Server $server): bool
+ {
+ $user = $request->user();
+
+ return $user->can(self::PERMISSION, $server) || $user->can(WipeSeasonManager::PERMISSION, $server);
+ }
+
+ private function authorize(Request $request, Server $server): void
+ {
+ abort_unless($this->canManage($request, $server), 403);
+ }
}
diff --git a/src/Models/WipeSchedule.php b/src/Models/WipeSchedule.php
index 487ed56..f78fd22 100644
--- a/src/Models/WipeSchedule.php
+++ b/src/Models/WipeSchedule.php
@@ -14,6 +14,7 @@
* @property string $label
* @property CarbonImmutable $anchor_at
* @property string $repeat
+ * @property string $timezone
* @property bool $public
* @property string|null $public_token
* @property Server $server
@@ -22,7 +23,9 @@ class WipeSchedule extends Model
{
protected $table = 'ext_next_wipe_schedules';
- protected $fillable = ['server_id', 'label', 'anchor_at', 'repeat', 'public', 'public_token'];
+ protected $fillable = ['server_id', 'label', 'anchor_at', 'repeat', 'timezone', 'public', 'public_token'];
+
+ protected $attributes = ['timezone' => 'UTC'];
protected function casts(): array
{
@@ -39,21 +42,27 @@ public function server(): BelongsTo
public function next(?CarbonImmutable $now = null): ?CarbonImmutable
{
- return NextOccurrence::after($this->anchor_at->utc(), $this->repeat, ($now ?? CarbonImmutable::now())->utc());
+ return NextOccurrence::after($this->anchor_at->utc(), $this->repeat, ($now ?? CarbonImmutable::now())->utc(), $this->timezone ?: 'UTC');
}
- /** @return array */
- public function toPayload(bool $withToken): array
+ /** The schedule's own settings, for the edit form. */
+ public function toSettings(): array
{
+ $zone = $this->timezone ?: 'UTC';
+ // The form shows the next wipe (or the first one) in the schedule's own zone.
+ $at = ($this->next() ?? $this->anchor_at)->setTimezone($zone);
+
return [
'label' => $this->label,
'anchor_at' => $this->anchor_at->utc()->toIso8601String(),
+ 'anchor_local' => $at->format('Y-m-d\TH:i'),
'repeat' => $this->repeat,
- 'next_at' => $this->next()?->toIso8601String(),
- 'public' => $this->public,
- 'public_url' => $withToken && $this->public && $this->public_token
- ? url('/extensions/next-wipe/s/'.$this->public_token)
- : null,
+ 'timezone' => $zone,
];
}
+
+ public function publicUrl(): ?string
+ {
+ return $this->public && $this->public_token ? url('/extensions/next-wipe/s/'.$this->public_token) : null;
+ }
}
diff --git a/src/NextWipeProvider.php b/src/NextWipeProvider.php
index 2e8ac60..b910e4b 100644
--- a/src/NextWipeProvider.php
+++ b/src/NextWipeProvider.php
@@ -15,6 +15,7 @@ public function boot(): void
$this->loadExtensionViews();
$this->registerPermissions('Next Wipe', [
+ // Subusers with Wipe & Season Manager's manage permission can change it too.
'manage' => 'Set the server\'s wipe schedule and turn its public page on or off.',
]);
}
diff --git a/src/Support/NextOccurrence.php b/src/Support/NextOccurrence.php
index 89f8870..ee0f7db 100644
--- a/src/Support/NextOccurrence.php
+++ b/src/Support/NextOccurrence.php
@@ -5,30 +5,41 @@
use Carbon\CarbonImmutable;
/**
- * Works out the next wipe from the first one and how it repeats. All times are UTC.
+ * Works out the next wipe from the first one and how it repeats. The calendar is
+ * read in the schedule's own time zone, so "every Thursday at 19:00" stays at
+ * 19:00 local time across daylight saving changes (the same rules Wipe & Season
+ * Manager uses). Results are returned in UTC.
*/
final class NextOccurrence
{
public const array REPEATS = ['none', 'weekly', 'biweekly', 'monthly', 'first-thursday'];
- public static function after(CarbonImmutable $anchor, string $repeat, CarbonImmutable $now): ?CarbonImmutable
+ /** The first wipe strictly after $now, or null when a one-off wipe has passed. */
+ public static function after(CarbonImmutable $anchor, string $repeat, CarbonImmutable $now, string $timezone = 'UTC'): ?CarbonImmutable
{
+ // The first wipe's wall-clock time in its own zone is what repeats.
+ $local = $anchor->setTimezone($timezone);
+ $anchor = CarbonImmutable::create($local->year, $local->month, $local->day, $local->hour, $local->minute, 0, $timezone);
+ $now = $now->setTimezone($timezone);
+
if ($anchor->greaterThan($now)) {
- return $anchor;
+ return $anchor->utc();
}
- return match ($repeat) {
+ $next = match ($repeat) {
'weekly' => self::stepDays($anchor, 7, $now),
'biweekly' => self::stepDays($anchor, 14, $now),
'monthly' => self::monthly($anchor, $now),
'first-thursday' => self::firstThursday($anchor, $now),
default => null,
};
+
+ return $next?->utc();
}
private static function stepDays(CarbonImmutable $anchor, int $days, CarbonImmutable $now): CarbonImmutable
{
- $steps = intdiv((int) $anchor->diffInDays($now, true), $days);
+ $steps = intdiv((int) $anchor->startOfDay()->diffInDays($now->startOfDay(), true), $days);
$next = $anchor->addDays($steps * $days);
while ($next->lessThanOrEqualTo($now)) {
@@ -38,22 +49,21 @@ private static function stepDays(CarbonImmutable $anchor, int $days, CarbonImmut
return $next;
}
- /** Same day of the month as the first wipe, clamped to the month's last day. */
+ /** Same day of the month as the first wipe, moved to the month's last day when it is shorter. */
private static function monthly(CarbonImmutable $anchor, CarbonImmutable $now): CarbonImmutable
{
$month = $now->startOfMonth();
for ($i = 0; $i < 3; $i++) {
- $candidate = $month->addMonths($i)
- ->setDay(min($anchor->day, $month->addMonths($i)->daysInMonth))
- ->setTime($anchor->hour, $anchor->minute);
+ $start = $month->addMonthsNoOverflow($i);
+ $candidate = $start->setDay(min($anchor->day, $start->daysInMonth))->setTime($anchor->hour, $anchor->minute);
if ($candidate->greaterThan($now)) {
return $candidate;
}
}
- return $anchor->addMonths(1);
+ return $anchor->addMonthsNoOverflow(1);
}
/** The first Thursday of each month at the first wipe's time (Rust's monthly forced wipe). */
@@ -62,8 +72,8 @@ private static function firstThursday(CarbonImmutable $anchor, CarbonImmutable $
$month = $now->startOfMonth();
for ($i = 0; $i < 3; $i++) {
- $first = $month->addMonths($i);
- $candidate = $first->addDays((4 - $first->dayOfWeek + 7) % 7)->setTime($anchor->hour, $anchor->minute);
+ $start = $month->addMonthsNoOverflow($i);
+ $candidate = $start->addDays((4 - $start->dayOfWeek + 7) % 7)->setTime($anchor->hour, $anchor->minute);
if ($candidate->greaterThan($now)) {
return $candidate;
diff --git a/src/Support/UpcomingWipe.php b/src/Support/UpcomingWipe.php
new file mode 100644
index 0000000..d722617
--- /dev/null
+++ b/src/Support/UpcomingWipe.php
@@ -0,0 +1,59 @@
+label,
+ repeat: $schedule->repeat,
+ timezone: $schedule->timezone ?: 'UTC',
+ nextAt: $schedule->next($now),
+ );
+ }
+
+ public function fromWipeSeasonManager(): bool
+ {
+ return $this->source === self::SOURCE_WSM;
+ }
+
+ /** "Thursday 15 October 2026, 19:00 BST (Europe/London)", in the schedule's own zone. */
+ public function localDescription(): ?string
+ {
+ if ($this->nextAt === null) {
+ return null;
+ }
+
+ $local = $this->nextAt->setTimezone($this->timezone);
+ $text = $local->format('l j F Y, H:i T');
+
+ return $local->format('T') === $this->timezone ? $text : $text.' ('.$this->timezone.')';
+ }
+}
diff --git a/src/Support/WipeSeasonManager.php b/src/Support/WipeSeasonManager.php
new file mode 100644
index 0000000..69beb49
--- /dev/null
+++ b/src/Support/WipeSeasonManager.php
@@ -0,0 +1,61 @@
+where('server_id', $serverId)
+ ->where('enabled', true)
+ ->whereNotNull('next_run_at')
+ ->orderBy('next_run_at')
+ ->orderBy('id')
+ ->first(['name', 'repeat', 'timezone', 'next_run_at']);
+
+ if ($plan === null) {
+ return null;
+ }
+
+ return new UpcomingWipe(
+ source: UpcomingWipe::SOURCE_WSM,
+ label: (string) $plan->name,
+ repeat: (string) $plan->repeat,
+ timezone: (string) ($plan->timezone ?: 'UTC'),
+ // Timestamps are stored in the panel's own zone, as Eloquent writes them.
+ nextAt: CarbonImmutable::parse((string) $plan->next_run_at, config('app.timezone'))->utc(),
+ );
+ }
+}
diff --git a/src/client/api.ts b/src/client/api.ts
index 04d3565..64cc06c 100644
--- a/src/client/api.ts
+++ b/src/client/api.ts
@@ -1,25 +1,45 @@
import { queryOptions } from '@tanstack/react-query';
import { http } from '@pterodactyl/sdk';
+/** Next Wipe's own repeats. */
export type Repeat = 'none' | 'weekly' | 'biweekly' | 'monthly' | 'first-thursday';
+/** Where the shown wipe comes from: this extension's schedule, or a Wipe & Season Manager plan. */
+export type WipeSource = 'next-wipe' | 'wipe-season-manager';
+
+/** The wipe the console card shows. */
export interface Wipe {
+ source: WipeSource;
+ label: string;
+ /** A Next Wipe repeat, or a Wipe & Season Manager one (`once`, `daily`, ...). */
+ repeat: string;
+ timezone: string;
+ next_at: string | null;
+}
+
+/** This extension's own schedule, for the edit form. */
+export interface Schedule {
label: string;
anchor_at: string;
+ /** The next (or first) wipe as a datetime-local value in `timezone`. */
+ anchor_local: string;
repeat: Repeat;
- next_at: string | null;
- public: boolean;
- public_url: string | null;
+ timezone: string;
}
export interface WipeResponse {
data: Wipe | null;
+ schedule: Schedule | null;
+ public: boolean;
+ public_url: string | null;
can_manage: boolean;
+ can_manage_plans: boolean;
}
export interface WipeInput {
label: string;
- anchor_at: string;
+ anchor_local: string;
+ timezone: string;
repeat: Repeat;
public: boolean;
}
@@ -37,6 +57,10 @@ export async function saveWipe(uuid: string, input: WipeInput): Promise(path(uuid), input)).data;
}
+export async function savePublic(uuid: string, enabled: boolean): Promise {
+ return (await http.put(`${path(uuid)}/public`, { public: enabled })).data;
+}
+
export async function deleteWipe(uuid: string): Promise {
await http.delete(path(uuid));
}
diff --git a/src/client/components/NextWipeCard.tsx b/src/client/components/NextWipeCard.tsx
index 96e519b..0da912f 100644
--- a/src/client/components/NextWipeCard.tsx
+++ b/src/client/components/NextWipeCard.tsx
@@ -1,9 +1,10 @@
import { useEffect, useState } from 'react';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
-import { CalendarClock } from 'lucide-react';
-import { Button, Dialog, httpErrorToHuman, toast, type SdkServer as Server } from '@pterodactyl/sdk';
-import { deleteWipe, saveWipe, wipeQuery, type WipeInput } from '../api';
-import { countdown, REPEAT_LABELS } from '../countdown';
+import { CalendarClock, CalendarSync } from 'lucide-react';
+import { Button, Dialog, httpErrorToHuman, toast, usePanelNavigate, type SdkServer as Server } from '@pterodactyl/sdk';
+import { deleteWipe, savePublic, saveWipe, wipeQuery, type WipeInput, type WipeResponse } from '../api';
+import { browserTimezone, countdown, formatWhen, repeatLabel } from '../countdown';
+import PublicForm from './PublicForm';
import WipeForm from './WipeForm';
const useNow = (ms: number) => {
@@ -19,53 +20,75 @@ const useNow = (ms: number) => {
export default function NextWipeCard({ data: server }: { data: Server }) {
const uuid = server.attributes.uuid;
const client = useQueryClient();
+ const navigate = usePanelNavigate();
const now = useNow(1000);
const [editing, setEditing] = useState(false);
const { data } = useQuery({ ...wipeQuery(uuid), enabled: Boolean(uuid) });
+ const saved = (message: string) => (response: WipeResponse) => {
+ client.setQueryData(wipeQuery(uuid).queryKey, response);
+ toast.success(message);
+ setEditing(false);
+ };
+ const failed = (error: Error) => toast.error(httpErrorToHuman(error));
+
const save = useMutation({
mutationFn: (input: WipeInput) => saveWipe(uuid, input),
- onSuccess: (response) => {
- client.setQueryData(wipeQuery(uuid).queryKey, response);
- toast.success('Wipe schedule saved.');
- setEditing(false);
- },
- onError: (error) => toast.error(httpErrorToHuman(error)),
+ onSuccess: saved('Wipe schedule saved.'),
+ onError: failed,
+ });
+
+ const share = useMutation({
+ mutationFn: (enabled: boolean) => savePublic(uuid, enabled),
+ onSuccess: saved('Public page saved.'),
+ onError: failed,
});
const remove = useMutation({
mutationFn: () => deleteWipe(uuid),
onSuccess: () => {
- client.setQueryData(wipeQuery(uuid).queryKey, { data: null, can_manage: true });
+ void client.invalidateQueries({ queryKey: wipeQuery(uuid).queryKey });
toast.success('Wipe schedule removed.');
setEditing(false);
},
- onError: (error) => toast.error(httpErrorToHuman(error)),
+ onError: failed,
});
if (!data || (!data.data && !data.can_manage)) return null;
const wipe = data.data;
+ // Wipe & Season Manager plans drive the countdown; they are changed on the server's Wipes tab.
+ const fromPlans = wipe?.source === 'wipe-season-manager';
const left = wipe?.next_at ? countdown(wipe.next_at, now) : null;
+ const otherZone = wipe && wipe.timezone !== browserTimezone();
+
+ const openWipes = () => {
+ const id = server.attributes.identifier;
+ try {
+ void navigate({ extension: 'wipe-season-manager', screen: 'wipes', params: { id } });
+ } catch {
+ window.location.assign(`/server/${id}/wipes`);
+ }
+ };
return (
-