feat(platform-web): show searched vehicle identity context
This commit is contained in:
@@ -21,6 +21,7 @@ export default function App() {
|
||||
const [activeProtocol, setActiveProtocol] = useState(initialRoute.protocol ?? '');
|
||||
const [linkIssueCount, setLinkIssueCount] = useState<number | null>(null);
|
||||
const [currentVehicleStatus, setCurrentVehicleStatus] = useState<VehicleServiceStatus | undefined>();
|
||||
const [currentVehicleLabel, setCurrentVehicleLabel] = useState('');
|
||||
|
||||
const refreshOpsHealth = useCallback((showError = true) => {
|
||||
return api.opsHealth()
|
||||
@@ -94,6 +95,7 @@ export default function App() {
|
||||
const resolved = await api.vehicleResolve(new URLSearchParams({ keyword: lookupKey }));
|
||||
const nextKey = resolved.resolved && resolved.vin ? resolved.vin : lookupKey;
|
||||
setCurrentVehicleStatus(resolved.serviceStatus);
|
||||
setCurrentVehicleLabel(resolved.resolved ? [resolved.plate, resolved.vin || nextKey].filter(Boolean).join(' / ') : lookupKey);
|
||||
setActiveVin(nextKey);
|
||||
setActiveProtocol(nextProtocol);
|
||||
setActivePage('detail');
|
||||
@@ -152,7 +154,7 @@ export default function App() {
|
||||
};
|
||||
|
||||
return (
|
||||
<AppShell activePage={activePage} linkIssueCount={linkIssueCount} currentVehicleStatus={currentVehicleStatus} onChange={navigatePage} onVehicleSearch={openVehicle}>
|
||||
<AppShell activePage={activePage} linkIssueCount={linkIssueCount} currentVehicleStatus={currentVehicleStatus} currentVehicleLabel={currentVehicleLabel} onChange={navigatePage} onVehicleSearch={openVehicle}>
|
||||
{pages[activePage]}
|
||||
</AppShell>
|
||||
);
|
||||
|
||||
@@ -36,6 +36,7 @@ export function AppShell({
|
||||
activePage,
|
||||
linkIssueCount,
|
||||
currentVehicleStatus,
|
||||
currentVehicleLabel,
|
||||
onChange,
|
||||
onVehicleSearch,
|
||||
children
|
||||
@@ -43,6 +44,7 @@ export function AppShell({
|
||||
activePage: PageKey;
|
||||
linkIssueCount: number | null;
|
||||
currentVehicleStatus?: VehicleServiceStatus;
|
||||
currentVehicleLabel?: string;
|
||||
onChange: (page: PageKey) => void;
|
||||
onVehicleSearch: (keyword: string) => void | Promise<void>;
|
||||
children: ReactNode;
|
||||
@@ -89,6 +91,7 @@ export function AppShell({
|
||||
<Button theme="solid" type="primary" loading={searching} onClick={search}>查询车辆</Button>
|
||||
</Space>
|
||||
<Space spacing={12}>
|
||||
{currentVehicleLabel ? <Tag color="grey">{currentVehicleLabel}</Tag> : null}
|
||||
{currentVehicleStatus ? (
|
||||
<Tag color={currentVehicleStatus.severity === 'ok' ? 'green' : currentVehicleStatus.severity === 'error' ? 'red' : 'orange'}>
|
||||
当前车辆:{currentVehicleStatus.title}
|
||||
|
||||
@@ -146,6 +146,7 @@ test('shows resolved vehicle service status after topbar search', async () => {
|
||||
fireEvent.click(screen.getByRole('button', { name: '查询车辆' }));
|
||||
|
||||
expect(await screen.findByText('当前车辆:部分来源离线')).toBeInTheDocument();
|
||||
expect(screen.getByText('粤AG18312 / LB9A32A24R0LS1426')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('shows row service status in dashboard vehicle previews', async () => {
|
||||
|
||||
Reference in New Issue
Block a user