Filter the script library and show customer context across pages
This commit is contained in:
+8
-3
@@ -313,7 +313,11 @@ export function Devices({
|
||||
[query, setQuery] = useState(''),
|
||||
[status, setStatus] = useState(''),
|
||||
[history, setHistory] = useState(false);
|
||||
const [routes, setRoutes] = useState<string[]>([]);
|
||||
const [trail, setTrail] = useState<{ filter: string; routes: string[] }>({ filter, routes: [] });
|
||||
const routes = trail.filter === filter ? trail.routes : [];
|
||||
function setRoutes(next: string[] | ((old: string[]) => string[])) {
|
||||
setTrail(old => ({ filter, routes: typeof next === 'function' ? next(old.filter === filter ? old.routes : []) : next }));
|
||||
}
|
||||
const [customerId, assetId, agentId] = detailPath.split('/');
|
||||
const target =
|
||||
customerId && assetId && agentId ? { customer: customerId, asset: assetId, agent: agentId } : null;
|
||||
@@ -328,6 +332,7 @@ export function Devices({
|
||||
}, 200);
|
||||
return () => clearTimeout(timer);
|
||||
}, [search]);
|
||||
useEffect(() => setTrail({ filter, routes: [] }), [filter]);
|
||||
const list = useResource(
|
||||
async (signal) => {
|
||||
if (target) return null;
|
||||
@@ -413,9 +418,9 @@ export function Devices({
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>Kunde</span>
|
||||
<span>Kunde im Gerätebestand</span>
|
||||
<select
|
||||
aria-label="Kunde"
|
||||
aria-label="Kunde im Gerätebestand"
|
||||
value={filter}
|
||||
onChange={(e) => {
|
||||
setRoutes([]);
|
||||
|
||||
Reference in New Issue
Block a user