mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-10-03 04:38:48 +00:00
A history request started before a successful clear can return deleted rows afterwards and repopulate the view. Invalidate those reads and settle loading only after the clear succeeds, preserving history on failure and allowing later refreshes. Change-source: pulse-maintainer
22 lines
1.3 KiB
JavaScript
22 lines
1.3 KiB
JavaScript
export const historyFixture = `
|
|
import { render } from 'solid-js/web';
|
|
import { Router, Route } from '@solidjs/router';
|
|
import { AlertsAPI } from '/src/api/alerts';
|
|
import { useAlertHistoryState } from '/src/features/alerts/useAlertHistoryState';
|
|
import { AlertHistoryAdministrationCard } from '/src/features/alerts/AlertHistoryAdministrationCard';
|
|
import '/src/index.css';
|
|
const row = {id:'old',type:'cpu',level:'warning',startTime:new Date().toISOString(),lastSeen:new Date().toISOString(),resourceId:'host',resourceName:'Fixture host',message:'Old history',acknowledged:false};
|
|
let calls = 0;
|
|
AlertsAPI.getHistory = () => ++calls === 1 ? Promise.resolve([row]) : new Promise(resolve => { window.finishHistory = () => resolve([row]); });
|
|
AlertsAPI.clearHistory = async () => {};
|
|
function Fixture() {
|
|
const state = useAlertHistoryState({activeAlerts:()=>({}),getResource:()=>undefined,allResources:()=>[]});
|
|
window.snapshot = () => ({rows:state.alertHistory().length,loading:state.loading()});
|
|
return <main class="p-4">
|
|
<button onClick={()=>state.setTimeFilter('24h')}>Refresh range</button>
|
|
<p>Rows: {state.alertHistory().length}</p>
|
|
<AlertHistoryAdministrationCard state={state}/>
|
|
</main>;
|
|
}
|
|
render(() => <Router><Route path="*" component={Fixture}/></Router>, document.getElementById('root'));
|
|
`;
|