return to Fleet after editing a PC opened from Fleet
Editing or retiring a PC launched from the Fleet view returned focus to the PCs list instead of Fleet. Fleet now tags its PC navigation with from=fleet, and PC Details and the edit form honor that origin for Back, Edit, Cancel, Save, and Retire. Absent the marker, every path still falls back to the PCs list.
This commit is contained in:
@@ -9,9 +9,9 @@
|
||||
look like a peer of printing a sticker. -->
|
||||
<div class="header-actions">
|
||||
<router-link :to="`/print/asset-label/computer/${$route.params.id}`" class="btn btn-secondary" target="_blank">Print Label</router-link>
|
||||
<router-link :to="`/pcs/${$route.params.id}/edit`" class="btn btn-primary">Edit</router-link>
|
||||
<router-link :to="`/pcs/${$route.params.id}/edit${fromQuery}`" class="btn btn-primary">Edit</router-link>
|
||||
<button @click="confirmRetire" class="btn btn-danger">Retire</button>
|
||||
<router-link to="/pcs" class="btn btn-secondary">Back to List</router-link>
|
||||
<router-link :to="returnTo" class="btn btn-secondary">{{ returnLabel }}</router-link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -376,6 +376,14 @@ const toast = useToast()
|
||||
const authStore = useAuthStore()
|
||||
const { isEnabled } = useIdentifierFlags()
|
||||
|
||||
// Return-navigation origin. Fleet opens this page with ?from=fleet so Back,
|
||||
// Edit, and Retire all lead back to Fleet; every other entry path falls back
|
||||
// to the PCs list.
|
||||
const fromFleet = computed(() => route.query.from === 'fleet')
|
||||
const fromQuery = computed(() => (fromFleet.value ? '?from=fleet' : ''))
|
||||
const returnTo = computed(() => (fromFleet.value ? '/endpoints' : '/pcs'))
|
||||
const returnLabel = computed(() => (fromFleet.value ? 'Back to Fleet' : 'Back to List'))
|
||||
|
||||
const loading = ref(true)
|
||||
const computer = ref(null)
|
||||
// Liveness for the triage band. Null when the endpoints plugin is absent, or
|
||||
@@ -643,7 +651,7 @@ async function confirmRetire() {
|
||||
try {
|
||||
await computersApi.delete(route.params.id)
|
||||
toast.success(`Retired ${label}`)
|
||||
router.push('/pcs')
|
||||
router.push(returnTo.value)
|
||||
} catch (error) {
|
||||
console.error('Error retiring PC:', error)
|
||||
toast.error(apiError(error, 'Failed to retire PC'))
|
||||
|
||||
Reference in New Issue
Block a user