Skip to content

Commit 40b321a

Browse files
committed
Remove else block
1 parent 5c46547 commit 40b321a

1 file changed

Lines changed: 52 additions & 52 deletions

File tree

  • modules/@apostrophecms/admin-bar

modules/@apostrophecms/admin-bar/index.js

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -373,68 +373,68 @@ module.exports = {
373373
}
374374
});
375375
});
376-
} else {
377-
// No explicit order - respect group registration order
378-
const newItems = [];
379-
const processedItems = new Set();
380-
381-
// First, process all groups in registration order
382-
groups.forEach(function (group) {
383-
if (!group.label) {
384-
return;
385-
}
386-
387-
// Collect valid items for this group (excluding duplicates and missing items)
388-
const validGroupItems = [];
376+
return;
377+
}
378+
// No explicit order - respect group registration order
379+
const newItems = [];
380+
const processedItems = new Set();
389381

390-
group.items.forEach(function (name) {
391-
// Check for duplicates
392-
if (groupedItems.has(name)) {
393-
self.apos.util.warn(
394-
`Admin bar item "${name}" appears in multiple groups: "${groupedItems.get(name)}" and "${group.label}". ` +
395-
`Using first occurrence in "${groupedItems.get(name)}".`
396-
);
397-
return;
398-
}
382+
// First, process all groups in registration order
383+
groups.forEach(function (group) {
384+
if (!group.label) {
385+
return;
386+
}
399387

400-
const item = _.find(self.items, { name });
401-
if (item && !processedItems.has(name)) {
402-
validGroupItems.push({
403-
item,
404-
name
405-
});
406-
}
407-
});
388+
// Collect valid items for this group (excluding duplicates and missing items)
389+
const validGroupItems = [];
408390

409-
// Only create a group if there are multiple valid items
410-
if (validGroupItems.length > 1) {
411-
const leaderName = validGroupItems[0].name;
412-
self.groupLabels[leaderName] = group.label;
391+
group.items.forEach(function (name) {
392+
// Check for duplicates
393+
if (groupedItems.has(name)) {
394+
self.apos.util.warn(
395+
`Admin bar item "${name}" appears in multiple groups: "${groupedItems.get(name)}" and "${group.label}". ` +
396+
`Using first occurrence in "${groupedItems.get(name)}".`
397+
);
398+
return;
399+
}
413400

414-
validGroupItems.forEach(({ item, name }) => {
415-
item.menuLeader = leaderName;
416-
newItems.push(item);
417-
processedItems.add(name);
418-
groupedItems.set(name, group.label);
401+
const item = _.find(self.items, { name });
402+
if (item && !processedItems.has(name)) {
403+
validGroupItems.push({
404+
item,
405+
name
419406
});
420-
} else if (validGroupItems.length === 1) {
421-
// Single item - add without grouping
422-
const { item, name } = validGroupItems[0];
423-
newItems.push(item);
424-
processedItems.add(name);
425407
}
426408
});
427409

428-
// Then add any remaining ungrouped items in their original order
429-
self.items.forEach(function (item) {
430-
if (!processedItems.has(item.name)) {
410+
// Only create a group if there are multiple valid items
411+
if (validGroupItems.length > 1) {
412+
const leaderName = validGroupItems[0].name;
413+
self.groupLabels[leaderName] = group.label;
414+
415+
validGroupItems.forEach(({ item, name }) => {
416+
item.menuLeader = leaderName;
431417
newItems.push(item);
432-
processedItems.add(item.name);
433-
}
434-
});
418+
processedItems.add(name);
419+
groupedItems.set(name, group.label);
420+
});
421+
} else if (validGroupItems.length === 1) {
422+
// Single item - add without grouping
423+
const { item, name } = validGroupItems[0];
424+
newItems.push(item);
425+
processedItems.add(name);
426+
}
427+
});
435428

436-
self.items = newItems;
437-
}
429+
// Then add any remaining ungrouped items in their original order
430+
self.items.forEach(function (item) {
431+
if (!processedItems.has(item.name)) {
432+
newItems.push(item);
433+
processedItems.add(item.name);
434+
}
435+
});
436+
437+
self.items = newItems;
438438
},
439439

440440
// Determine if the specified admin bar item object should

0 commit comments

Comments
 (0)