You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the introduction of ticket versioning, we need to modify our UI components to properly handle grouped tickets and only display the latest version of each ticket group in the Phase Planner view.
Current Behavior
Phase Planner loads and displays all tickets
Each ticket is treated independently
No concept of ticket versions in UI
Desired Behavior
Phase Planner shows only latest version of each ticket group
Updates create new versions while maintaining group relationship
UI indicates current version number
Drag-and-drop works with grouped tickets
Design
Modify PhaseTicketStore to handle ticket grouping
Update PhasePlannerView data loading and websocket handlers
Enhance TicketEditor component for versioned tickets
1. Store Layer (store/phase.ts)
Add new helper functions for organizing tickets by group
Modify ticket storage structure to handle versioning
// New functions to add:-organizeTicketsByGroup(tickets: Ticket[]): Ticket[]-getLatestVersionFromGroup(groupId: string): Ticket
// Group tickets by ticketGroup and find latest version
const organizeTicketsByGroup = (tickets: Ticket[]) => {
// Create a map of ticketGroup -> array of tickets in that group
const groupedTickets = tickets.reduce((groups, ticket) => {
const group = ticket.ticketGroup || ticket.uuid; // fallback for backwards compatibility
if (!groups[group]) {
groups[group] = [];
}
groups[group].push(ticket);
return groups;
}, {} as Record<string, Ticket[]>);
// For each group, find the ticket with highest version
return Object.values(groupedTickets).map(groupTickets => {
return groupTickets.reduce((latest, current) => {
return (current.version > latest.version) ? current : latest;
});
});
};
2. Phase Planner View (PhasePlannerView.tsx)
Modify ticket loading logic in useEffect for initial data fetch
Update websocket handler for ticket updates
Adjust drag-and-drop handlers to work with grouped tickets
// Functions to modify:-fetchData()inmainuseEffect-refreshSingleTicket()-onDragEnd()
Fetch data example
useEffect(() => {
const fetchData = async () => {
try {
const feature = await getFeatureData();
const phase = await getPhaseData();
const phaseTickets = await getPhaseTickets();
if (!feature || !phase || !Array.isArray(phaseTickets)) {
history.push('/');
} else {
// Clear existing tickets
phaseTicketStore.clearPhaseTickets(phase_uuid);
// Organize tickets by group and get latest versions
const latestVersionTickets = organizeTicketsByGroup(phaseTickets);
// Add only the latest version tickets
for (const ticket of latestVersionTickets) {
if (ticket.UUID) {
ticket.uuid = ticket.UUID;
}
phaseTicketStore.addTicket(ticket);
}
setFeatureData(feature);
setPhaseData(phase);
}
} catch (error) {
console.error('Error fetching data:', error);
history.push('/');
}
};
fetchData();
}, [getFeatureData, getPhaseData, history, getPhaseTickets, phase_uuid]);
refreshSingleTicket() example update
const refreshSingleTicket = async (ticketUuid: string) => {
try {
const ticket = await main.getTicketDetails(ticketUuid);
const groupId = ticket.ticketGroup || ticket.uuid;
// Get all tickets in this group
const groupTickets = await main.getTicketsByGroup(groupId);
// Find the latest version
const latestTicket = groupTickets.reduce((latest, current) => {
return (current.version > latest.version) ? current : latest;
});
// Update store with latest version
phaseTicketStore.updateTicket(latestTicket.uuid, latestTicket);
} catch (error) {
console.error('Error on refreshing ticket:', error);
}
};
3. Ticket Editor Component (TicketEditor.tsx)
Update component to display version information
Modify update handler to work with versioned tickets
// Functions to modify:-handleUpdate()-ComponentUItoshowversionnumber
Update UI Components to Handle Ticket Versioning
Context
With the introduction of ticket versioning, we need to modify our UI components to properly handle grouped tickets and only display the latest version of each ticket group in the Phase Planner view.
Current Behavior
Desired Behavior
Design
1. Store Layer (
store/phase.ts
)2. Phase Planner View (
PhasePlannerView.tsx
)useEffect
for initial data fetchFetch data example
refreshSingleTicket() example update
3. Ticket Editor Component (
TicketEditor.tsx
)Example Code
Implementation Steps
Store Layer Changes:
Data Loading Changes:
UI Component Changes:
Type System Updates:
Testing Requirements
Acceptance Criteria
The text was updated successfully, but these errors were encountered: