restore tool - mostly working

This commit is contained in:
Andy Miller
2025-10-18 12:14:52 -06:00
parent 796c61e66d
commit 39aa026f3f
3 changed files with 13 additions and 9 deletions

View File

@@ -393,11 +393,19 @@ class AdminPlugin extends Plugin
$manifestFiles = $manager->hasSnapshots() ? [true] : [];
}
$tools = $event['tools'];
Grav::instance()['log']->debug('[Admin] Tools before restore grav: ' . implode(',', array_keys($tools)));
if ($manifestFiles) {
$event['tools']['restore-grav'] = [['admin.super'], 'PLUGIN_ADMIN.RESTORE_GRAV'];
$tools['restore-grav'] = [['admin.super'], 'PLUGIN_ADMIN.RESTORE_GRAV'];
Grav::instance()['log']->debug('[Admin] Restore Grav tool enabled');
}
$event['tools'] = $tools;
Grav::instance()['log']->debug('[Admin] Tools after register: ' . implode(',', array_keys($tools)));
} catch (\Throwable $e) {
// ignore availability errors, snapshots tool will simply stay hidden
Grav::instance()['log']->warning('[Admin] Restore Grav detection failed: ' . $e->getMessage());
}
}

View File

@@ -1,3 +1,6 @@
{% do assets.addInlineCss(' \
.restore-grav-content {\n padding-bottom: 2rem;\n}\n\n.restore-grav-intro {\n margin-left: 1.5rem;\n margin-bottom: 1.5rem;\n}\n\n.restore-grav-table {\n margin-bottom: 1.5rem;\n}\n\n.restore-grav-table code {\n white-space: nowrap;\n}\n\n.restore-grav-content .button-bar {\n margin-bottom: 1rem;\n}\n') %}
<h1>{{ "PLUGIN_ADMIN.RESTORE_GRAV"|t }}</h1>
<div class="restore-grav-content">
@@ -20,7 +23,6 @@
<th>{{ "PLUGIN_ADMIN.RESTORE_GRAV_TABLE_SNAPSHOT"|t }}</th>
<th>{{ "PLUGIN_ADMIN.RESTORE_GRAV_TABLE_VERSION"|t }}</th>
<th>{{ "PLUGIN_ADMIN.RESTORE_GRAV_TABLE_CREATED"|t }}</th>
<th>{{ "PLUGIN_ADMIN.RESTORE_GRAV_TABLE_LOCATION"|t }}</th>
<th class="actions-cell">{{ "PLUGIN_ADMIN.RESTORE_GRAV_TABLE_ACTIONS"|t }}</th>
</tr>
</thead>
@@ -41,13 +43,6 @@
{{ "PLUGIN_ADMIN.UNKNOWN"|t }}
{% endif %}
</td>
<td>
{% if snapshot.backup_path %}
<code class="snapshot-path">{{ snapshot.backup_path }}</code>
{% else %}
{{ "PLUGIN_ADMIN.UNKNOWN"|t }}
{% endif %}
</td>
<td class="actions-cell">
<form action="{{ admin_route('/tools/restore-grav') }}" method="post" class="inline-form">
<input type="hidden" name="task" value="safeUpgradeRestore">

View File

@@ -39,6 +39,7 @@
</div>
</div>
{% endif %}
{{ dump(tools) }}
{% endblock %}
{% block content %}