backups: fix the history view's back link
The view linked to /assets/<assetid>, which is not a route. Each asset type has its own detail route keyed by its own id (/machines/<machineid>), and there is no generic asset detail page to return to, so the link 404'd. Uses router.back() instead: this page is only ever reached from an asset panel, so history is the correct destination regardless of the asset type, and it needs no per-type route table. Falls back to the machines list when opened directly from a pasted URL. The /api/assets/<id> call that fetches the heading name is unaffected - that endpoint does exist; it was only the frontend route that did not.
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
<template>
|
||||
<div class="bh">
|
||||
<div class="bh-head">
|
||||
<router-link :to="`/assets/${assetid}`" class="bh-back">← Back to asset</router-link>
|
||||
<!-- back(), not a route: this page is reached from an asset panel, and
|
||||
each asset type has its own detail route keyed by its OWN id
|
||||
(/machines/:machineid, not the assetid we are given). There is no
|
||||
generic /assets/:id to link to. -->
|
||||
<button type="button" class="bh-back" @click="goback">← Back</button>
|
||||
<h1>Configuration Backups</h1>
|
||||
<p v-if="assetname" class="bh-sub">{{ assetname }}</p>
|
||||
</div>
|
||||
@@ -90,12 +94,18 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import api from '@/api'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const assetid = route.params.assetid
|
||||
|
||||
function goback() {
|
||||
if (window.history.length > 1) router.back()
|
||||
else router.push('/machines')
|
||||
}
|
||||
|
||||
const revisions = ref([])
|
||||
const diffs = ref({})
|
||||
const assetname = ref('')
|
||||
@@ -177,7 +187,10 @@ onMounted(load)
|
||||
<style scoped>
|
||||
.bh { padding: 1.5rem; }
|
||||
.bh-head { margin-bottom: 1rem; }
|
||||
.bh-back { font-size: 0.85rem; }
|
||||
.bh-back {
|
||||
font-size: 0.85rem; background: none; border: none; padding: 0;
|
||||
color: #0d6efd; cursor: pointer;
|
||||
}
|
||||
.bh-sub { color: #666; margin: 0.2rem 0 0; }
|
||||
.bh-note, .bh-muted { color: #666; }
|
||||
.bh-error { color: #c00; }
|
||||
|
||||
Reference in New Issue
Block a user