Преглед на файлове

Add a back link to the Printer Locations page

The page is opened from the Printers page and is not in the sidebar, so
the browser's back button was the only way out. Add a "Back to Printers"
link above the title, translated in all locales.
maziggy преди 2 седмици
родител
ревизия
1feb799aa9

+ 7 - 0
frontend/src/__tests__/pages/PrinterLocationsPage.test.tsx

@@ -177,6 +177,13 @@ describe('PrinterLocationsPage', () => {
     expect(screen.queryByRole('button', { name: /edit/i })).not.toBeInTheDocument();
     expect(screen.queryByRole('button', { name: /select all/i })).not.toBeInTheDocument();
   });
+
+  it('links back to the printers page', async () => {
+    render(<PrinterLocationsPage />);
+
+    const back = await screen.findByRole('link', { name: /back to printers/i });
+    expect(back).toHaveAttribute('href', '/');
+  });
 });
 
 describe('printer locations strings', () => {

+ 1 - 0
frontend/src/i18n/locales/de.ts

@@ -239,6 +239,7 @@ export default {
   printers: {
     locations: {
       title: 'Druckerstandorte',
+      backToPrinters: 'Zurück zu den Druckern',
       subtitle: '{{grouped}} mit Standort, {{ungrouped}} ohne',
       search: 'Standorte durchsuchen...',
       showEmpty: 'Leere anzeigen',

+ 1 - 0
frontend/src/i18n/locales/en.ts

@@ -241,6 +241,7 @@ export default {
     // they read correctly in every language without plural forms.
     locations: {
       title: 'Printer Locations',
+      backToPrinters: 'Back to Printers',
       subtitle: '{{grouped}} in a location, {{ungrouped}} without one',
       search: 'Search locations...',
       showEmpty: 'Show empty',

+ 1 - 0
frontend/src/i18n/locales/es.ts

@@ -239,6 +239,7 @@ export default {
   printers: {
     locations: {
       title: 'Ubicaciones de impresoras',
+      backToPrinters: 'Volver a las impresoras',
       subtitle: '{{grouped}} con ubicación, {{ungrouped}} sin ubicación',
       search: 'Buscar ubicaciones...',
       showEmpty: 'Mostrar vacías',

+ 1 - 0
frontend/src/i18n/locales/fr.ts

@@ -239,6 +239,7 @@ export default {
   printers: {
     locations: {
       title: 'Emplacements des imprimantes',
+      backToPrinters: 'Retour aux imprimantes',
       subtitle: '{{grouped}} avec emplacement, {{ungrouped}} sans',
       search: 'Rechercher des emplacements...',
       showEmpty: 'Afficher les vides',

+ 1 - 0
frontend/src/i18n/locales/it.ts

@@ -239,6 +239,7 @@ export default {
   printers: {
     locations: {
       title: 'Posizioni delle stampanti',
+      backToPrinters: 'Torna alle stampanti',
       subtitle: '{{grouped}} con posizione, {{ungrouped}} senza',
       search: 'Cerca posizioni...',
       showEmpty: 'Mostra vuote',

+ 1 - 0
frontend/src/i18n/locales/ja.ts

@@ -238,6 +238,7 @@ export default {
   printers: {
     locations: {
       title: 'プリンターの場所',
+      backToPrinters: 'プリンターに戻る',
       subtitle: '場所あり {{grouped}} 台、場所なし {{ungrouped}} 台',
       search: '場所を検索...',
       showEmpty: '空の場所を表示',

+ 1 - 0
frontend/src/i18n/locales/ko.ts

@@ -233,6 +233,7 @@ export default {
   printers: {
     locations: {
       title: '프린터 위치',
+      backToPrinters: '프린터로 돌아가기',
       subtitle: '위치 있음 {{grouped}}대, 위치 없음 {{ungrouped}}대',
       search: '위치 검색...',
       showEmpty: '빈 위치 표시',

+ 1 - 0
frontend/src/i18n/locales/nl.ts

@@ -239,6 +239,7 @@ export default {
   printers: {
     locations: {
       title: 'Printerlocaties',
+      backToPrinters: 'Terug naar printers',
       subtitle: '{{grouped}} met locatie, {{ungrouped}} zonder',
       search: 'Locaties zoeken...',
       showEmpty: 'Lege tonen',

+ 1 - 0
frontend/src/i18n/locales/pt-BR.ts

@@ -239,6 +239,7 @@ export default {
   printers: {
     locations: {
       title: 'Locais das impressoras',
+      backToPrinters: 'Voltar para as impressoras',
       subtitle: '{{grouped}} com local, {{ungrouped}} sem local',
       search: 'Buscar locais...',
       showEmpty: 'Mostrar vazios',

+ 1 - 0
frontend/src/i18n/locales/ru.ts

@@ -233,6 +233,7 @@ export default {
   printers: {
     locations: {
       title: "Расположение принтеров",
+      backToPrinters: "Назад к принтерам",
       subtitle: "С расположением: {{grouped}}, без расположения: {{ungrouped}}",
       search: "Поиск расположений...",
       showEmpty: "Показать пустые",

+ 1 - 0
frontend/src/i18n/locales/sv.ts

@@ -239,6 +239,7 @@ export default {
   printers: {
     locations: {
       title: 'Skrivarplatser',
+      backToPrinters: 'Tillbaka till skrivare',
       subtitle: '{{grouped}} med plats, {{ungrouped}} utan',
       search: 'Sök platser...',
       showEmpty: 'Visa tomma',

+ 1 - 0
frontend/src/i18n/locales/tr.ts

@@ -239,6 +239,7 @@ export default {
   printers: {
     locations: {
       title: 'Yazıcı konumları',
+      backToPrinters: 'Yazıcılara dön',
       subtitle: '{{grouped}} konumlu, {{ungrouped}} konumsuz',
       search: 'Konum ara...',
       showEmpty: 'Boşları göster',

+ 1 - 0
frontend/src/i18n/locales/uk.ts

@@ -239,6 +239,7 @@ export default {
   printers: {
     locations: {
       title: "Розташування принтерів",
+      backToPrinters: "Назад до принтерів",
       subtitle: "З розташуванням: {{grouped}}, без розташування: {{ungrouped}}",
       search: "Пошук розташувань...",
       showEmpty: "Показати порожні",

+ 1 - 0
frontend/src/i18n/locales/zh-CN.ts

@@ -239,6 +239,7 @@ export default {
   printers: {
     locations: {
       title: '打印机位置',
+      backToPrinters: '返回打印机',
       subtitle: '有位置 {{grouped}} 台,无位置 {{ungrouped}} 台',
       search: '搜索位置...',
       showEmpty: '显示空位置',

+ 1 - 0
frontend/src/i18n/locales/zh-TW.ts

@@ -239,6 +239,7 @@ export default {
   printers: {
     locations: {
       title: '印表機位置',
+      backToPrinters: '返回印表機',
       subtitle: '有位置 {{grouped}} 台,無位置 {{ungrouped}} 台',
       search: '搜尋位置...',
       showEmpty: '顯示空位置',

+ 8 - 1
frontend/src/pages/PrinterLocationsPage.tsx

@@ -1,7 +1,8 @@
 import { useEffect, useMemo, useState } from 'react';
 import { useMutation, useQueries, useQuery, useQueryClient } from '@tanstack/react-query';
 import { useTranslation } from 'react-i18next';
-import { Box, CheckSquare, ChevronDown, Loader2, Move, Pencil, Plus, Search, Square, Trash2, UserMinus, X } from 'lucide-react';
+import { Link } from 'react-router-dom';
+import { ArrowLeft, Box, CheckSquare, ChevronDown, Loader2, Move, Pencil, Plus, Search, Square, Trash2, UserMinus, X } from 'lucide-react';
 import { api } from '../api/client';
 import type { Printer, PrinterLocation } from '../api/client';
 import { Button } from '../components/Button';
@@ -471,6 +472,12 @@ export function PrinterLocationsPage() {
 
   return (
     <div className="p-4 md:p-8 pb-28">
+      <Link
+        to="/"
+        className="inline-flex items-center gap-1 mb-3 text-sm text-bambu-gray hover:text-white transition-colors"
+      >
+        <ArrowLeft className="w-4 h-4" /> {t('printers.locations.backToPrinters')}
+      </Link>
       <div className="mb-4">
         <div className="flex items-center gap-3 mb-1">
           <Box className="w-[25px] h-[25px] text-bambu-green" />