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