Handle minor version like 6.1 having issues
This commit is contained in:
+81
-34
@@ -45,45 +45,56 @@ function transformNode(node) {
|
|||||||
|
|
||||||
const hasIssueArrays = Object.prototype.hasOwnProperty.call(node, 'addressed') ||
|
const hasIssueArrays = Object.prototype.hasOwnProperty.call(node, 'addressed') ||
|
||||||
Object.prototype.hasOwnProperty.call(node, 'known');
|
Object.prototype.hasOwnProperty.call(node, 'known');
|
||||||
|
const childKeys = Object.keys(node).filter(key => key !== 'addressed' && key !== 'known');
|
||||||
|
|
||||||
if (hasIssueArrays) {
|
const transformedChildren = {};
|
||||||
const addressed = Array.isArray(node.addressed) ? node.addressed : [];
|
childKeys.forEach(key => {
|
||||||
const known = Array.isArray(node.known) ? node.known : [];
|
transformedChildren[key] = transformNode(node[key]);
|
||||||
const allFiles = [...addressed, ...known];
|
});
|
||||||
|
|
||||||
if (allFiles.length === 0) {
|
if (!hasIssueArrays) {
|
||||||
return {
|
return transformedChildren;
|
||||||
addressed: [],
|
|
||||||
known: []
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const groupedByPrefix = {};
|
|
||||||
|
|
||||||
addressed.forEach(fileName => {
|
|
||||||
const prefix = getFilePrefix(fileName);
|
|
||||||
if (!groupedByPrefix[prefix]) {
|
|
||||||
groupedByPrefix[prefix] = { addressed: [], known: [] };
|
|
||||||
}
|
|
||||||
groupedByPrefix[prefix].addressed.push(fileName);
|
|
||||||
});
|
|
||||||
|
|
||||||
known.forEach(fileName => {
|
|
||||||
const prefix = getFilePrefix(fileName);
|
|
||||||
if (!groupedByPrefix[prefix]) {
|
|
||||||
groupedByPrefix[prefix] = { addressed: [], known: [] };
|
|
||||||
}
|
|
||||||
groupedByPrefix[prefix].known.push(fileName);
|
|
||||||
});
|
|
||||||
|
|
||||||
return groupHotfixPrefixes(groupedByPrefix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const transformed = {};
|
const addressed = Array.isArray(node.addressed) ? node.addressed : [];
|
||||||
Object.keys(node).forEach(key => {
|
const known = Array.isArray(node.known) ? node.known : [];
|
||||||
transformed[key] = transformNode(node[key]);
|
const allFiles = [...addressed, ...known];
|
||||||
|
|
||||||
|
if (allFiles.length === 0) {
|
||||||
|
if (childKeys.length > 0) {
|
||||||
|
return transformedChildren;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
addressed: [],
|
||||||
|
known: []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const groupedByPrefix = {};
|
||||||
|
|
||||||
|
addressed.forEach(fileName => {
|
||||||
|
const prefix = getFilePrefix(fileName);
|
||||||
|
if (!groupedByPrefix[prefix]) {
|
||||||
|
groupedByPrefix[prefix] = { addressed: [], known: [] };
|
||||||
|
}
|
||||||
|
groupedByPrefix[prefix].addressed.push(fileName);
|
||||||
});
|
});
|
||||||
return transformed;
|
|
||||||
|
known.forEach(fileName => {
|
||||||
|
const prefix = getFilePrefix(fileName);
|
||||||
|
if (!groupedByPrefix[prefix]) {
|
||||||
|
groupedByPrefix[prefix] = { addressed: [], known: [] };
|
||||||
|
}
|
||||||
|
groupedByPrefix[prefix].known.push(fileName);
|
||||||
|
});
|
||||||
|
|
||||||
|
const transformedIssueFiles = groupHotfixPrefixes(groupedByPrefix);
|
||||||
|
if (childKeys.length === 0) {
|
||||||
|
return transformedIssueFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mergeTreeNodes(transformedChildren, transformedIssueFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
function groupHotfixPrefixes(groupedByPrefix) {
|
function groupHotfixPrefixes(groupedByPrefix) {
|
||||||
@@ -130,3 +141,39 @@ function getFilePrefix(fileName) {
|
|||||||
}
|
}
|
||||||
return baseName.slice(0, underscoreIndex);
|
return baseName.slice(0, underscoreIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mergeTreeNodes(left, right) {
|
||||||
|
if (!isObjectNode(left)) {
|
||||||
|
return right;
|
||||||
|
}
|
||||||
|
if (!isObjectNode(right)) {
|
||||||
|
return left;
|
||||||
|
}
|
||||||
|
|
||||||
|
const merged = { ...left };
|
||||||
|
|
||||||
|
Object.keys(right).forEach(key => {
|
||||||
|
const leftValue = merged[key];
|
||||||
|
const rightValue = right[key];
|
||||||
|
|
||||||
|
if (key === 'addressed' || key === 'known') {
|
||||||
|
const leftFiles = Array.isArray(leftValue) ? leftValue : [];
|
||||||
|
const rightFiles = Array.isArray(rightValue) ? rightValue : [];
|
||||||
|
merged[key] = Array.from(new Set([...leftFiles, ...rightFiles]));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isObjectNode(leftValue) && isObjectNode(rightValue)) {
|
||||||
|
merged[key] = mergeTreeNodes(leftValue, rightValue);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
merged[key] = rightValue;
|
||||||
|
});
|
||||||
|
|
||||||
|
return merged;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isObjectNode(value) {
|
||||||
|
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
||||||
|
}
|
||||||
|
|||||||
+31
-8
@@ -84,8 +84,8 @@ export function getCheckedFileRefs() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
addressedFiles,
|
addressedFiles: dedupeFileRefs(addressedFiles),
|
||||||
knownFiles
|
knownFiles: dedupeFileRefs(knownFiles)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,8 +93,12 @@ function createTreeNode(name, value, path) {
|
|||||||
const container = document.createElement('div');
|
const container = document.createElement('div');
|
||||||
container.className = 'tree-item';
|
container.className = 'tree-item';
|
||||||
|
|
||||||
const isLeafWithFiles = value && typeof value === 'object' && ('addressed' in value || 'known' in value);
|
const isObjectValue = value && typeof value === 'object';
|
||||||
const hasChildren = value && typeof value === 'object' && !isLeafWithFiles && Object.keys(value).length > 0;
|
const hasFiles = isObjectValue && ('addressed' in value || 'known' in value);
|
||||||
|
const childKeys = isObjectValue
|
||||||
|
? getSortedKeys(value).filter(key => key !== 'addressed' && key !== 'known')
|
||||||
|
: [];
|
||||||
|
const hasChildren = childKeys.length > 0;
|
||||||
|
|
||||||
if (hasChildren) {
|
if (hasChildren) {
|
||||||
container.classList.add('parent');
|
container.classList.add('parent');
|
||||||
@@ -105,14 +109,14 @@ function createTreeNode(name, value, path) {
|
|||||||
toggle.style.cursor = 'pointer';
|
toggle.style.cursor = 'pointer';
|
||||||
|
|
||||||
const label = document.createElement('label');
|
const label = document.createElement('label');
|
||||||
const checkbox = createCheckbox(path);
|
const checkbox = createCheckbox(path, hasFiles ? value : undefined);
|
||||||
label.appendChild(checkbox);
|
label.appendChild(checkbox);
|
||||||
label.appendChild(document.createTextNode(name));
|
label.appendChild(document.createTextNode(name));
|
||||||
|
|
||||||
const childrenContainer = document.createElement('div');
|
const childrenContainer = document.createElement('div');
|
||||||
childrenContainer.className = 'tree-children';
|
childrenContainer.className = 'tree-children';
|
||||||
|
|
||||||
getSortedKeys(value).forEach(childKey => {
|
childKeys.forEach(childKey => {
|
||||||
const childNode = createTreeNode(childKey, value[childKey], [...path, childKey]);
|
const childNode = createTreeNode(childKey, value[childKey], [...path, childKey]);
|
||||||
childrenContainer.appendChild(childNode);
|
childrenContainer.appendChild(childNode);
|
||||||
});
|
});
|
||||||
@@ -136,7 +140,7 @@ function createTreeNode(name, value, path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const label = document.createElement('label');
|
const label = document.createElement('label');
|
||||||
if (isLeafWithFiles) {
|
if (hasFiles) {
|
||||||
const checkbox = createCheckbox(path, value);
|
const checkbox = createCheckbox(path, value);
|
||||||
label.appendChild(checkbox);
|
label.appendChild(checkbox);
|
||||||
}
|
}
|
||||||
@@ -151,7 +155,7 @@ function shouldStartCollapsed(name, value) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const childKeys = Object.keys(value);
|
const childKeys = Object.keys(value).filter(key => key !== 'addressed' && key !== 'known');
|
||||||
if (childKeys.length === 0) {
|
if (childKeys.length === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -164,6 +168,25 @@ function shouldStartCollapsed(name, value) {
|
|||||||
return hotfixChildren.length > 0;
|
return hotfixChildren.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function dedupeFileRefs(fileRefs) {
|
||||||
|
const seen = new Set();
|
||||||
|
return fileRefs.filter(ref => {
|
||||||
|
const productKey = String(ref && ref.productKey ? ref.productKey : '');
|
||||||
|
const fileName = String(ref && ref.fileName ? ref.fileName : '');
|
||||||
|
if (!productKey || !fileName) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const key = `${productKey}::${fileName}`;
|
||||||
|
if (seen.has(key)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
seen.add(key);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function createCheckbox(path, value) {
|
function createCheckbox(path, value) {
|
||||||
const checkbox = document.createElement('input');
|
const checkbox = document.createElement('input');
|
||||||
checkbox.type = 'checkbox';
|
checkbox.type = 'checkbox';
|
||||||
|
|||||||
Reference in New Issue
Block a user