in src/FeatureTimeline/redux/selectors/workItemHierarchySelector.ts [88:143]
function getWorkItemDetails(
projectId: string,
teamId: string,
id: number,
input: IFeatureTimelineRawState,
isRoot: boolean): IWorkItemDisplayDetails {
const {
workItemsState,
workItemMetadata
} = input;
const workItemInfo = id && workItemsState.workItemInfos[id];
const workItem = workItemInfo && workItemInfo.workItem;
let workItemType = null;
let workItemStateColor: WorkItemStateColor = null;
if (workItem) {
const workItemTypeName = workItem.fields["System.WorkItemType"];
const state = workItem.fields["System.State"].toLowerCase();
const metadata = workItemMetadata[projectId];
workItemType = metadata.workItemTypes.filter((wit) => wit.name.toLowerCase() === workItemTypeName.toLowerCase())[0];
if (metadata.workItemStateColors[workItemTypeName]) {
workItemStateColor = metadata.workItemStateColors[workItemTypeName].filter(sc => sc.name.toLowerCase() === state)[0];
}
}
const children = getWorkItemsDetails(projectId, teamId, getChildrenIds(workItemsState.workItemInfos, id), input, /* isRoot */ false);
// try getting start/end iteration from children
let iterationDuration = getWorkItemIterationDuration(children, projectId, teamId, input, id, workItem);
const orderFieldName = input.backlogConfiguration.backlogConfigurations[projectId][teamId].backlogFields.typeFields["Order"];
const effortFieldName = input.backlogConfiguration.backlogConfigurations[projectId][teamId].backlogFields.typeFields["Effort"];
const color = workItemType && workItemType.color ? "#" + (workItemType.color.length > 6 ? workItemType.color.substr(2) : workItemType.color) : "#c2c8d1";
const workItemDetails: IWorkItemDisplayDetails = {
id,
title: workItem ? workItem.fields["System.Title"] : "Unparented",
color,
order: workItem ? workItem.fields[orderFieldName] || Number.MAX_VALUE : Number.MAX_VALUE,
efforts: workItem ? workItem.fields[effortFieldName] || 0 : 0,
workItem,
iterationDuration,
children,
isRoot,
isComplete: workItemInfo && workItemInfo.stateCategory === StateCategory.Completed,
workItemStateColor,
childrenWithNoEfforts: children.filter(c => c.efforts === 0).length,
predecessors: [],
successors: [],
highlighteSuccessorIcon: false,
highlightPredecessorIcon: false
};
return workItemDetails;
}