Skip to content

Commit 5a24a23

Browse files
authored
[2.x] fix(admin): keep extension danger badge visible on long names (#4660)
The abandoned-extension danger/warning badge was rendered inside the button's truncated label, so when the extension name was long enough to trigger the ellipsis overflow on `.Button-labelText`, the badge itself got clipped and was no longer visible in the admin sidebar. Move the badge into `ExtensionLinkButton::statusItems()` (alongside the enabled/disabled status dot) so it sits as a sibling of the button label rather than inside it. Position it absolutely to the left of the dot, vertically aligned by matching the dot's `margin`-based centering offset for the larger badge size. Closes #4592
1 parent 5f3fb89 commit 5a24a23

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

framework/core/js/src/admin/components/AdminNav.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,6 @@ export default class AdminNav extends Component {
156156
const query = this.query().toUpperCase();
157157
const title = extension.extra['flarum-extension'].title || '';
158158
const description = extension.description || '';
159-
const isAbandoned = extension.abandoned;
160-
const hasReplacement = typeof isAbandoned === 'string';
161159

162160
if (!query || title.toUpperCase().includes(query) || description.toUpperCase().includes(query)) {
163161
items.add(
@@ -169,7 +167,6 @@ export default class AdminNav extends Component {
169167
title={description}
170168
>
171169
{title}
172-
{isAbandoned && <span className={`Badge Badge--${hasReplacement ? 'danger' : 'warning'}`}>!</span>}
173170
</ExtensionLinkButton>,
174171
categories[category]
175172
);

framework/core/js/src/admin/components/ExtensionLinkButton.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ export default class ExtensionLinkButton extends LinkButton {
2323
statusItems(name) {
2424
const items = new ItemList();
2525

26+
const extension = app.data.extensions[name];
27+
const isAbandoned = extension?.abandoned;
28+
29+
if (isAbandoned) {
30+
const hasReplacement = typeof isAbandoned === 'string';
31+
items.add('abandoned', <span className={`Badge Badge--${hasReplacement ? 'danger' : 'warning'}`}>!</span>, 10);
32+
}
33+
2634
items.add('enabled', <span className={'ExtensionListItem-Dot ' + (isExtensionEnabled(name) ? 'enabled' : 'disabled')} />);
2735

2836
return items;

framework/core/less/admin/AdminNav.less

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,12 @@
216216

217217
.ExtensionNavButton {
218218
.Badge {
219-
margin-left: 5px;
220219
.Badge--size(16px);
221220
font-size: 10px;
222221
font-weight: bold;
222+
position: absolute;
223+
right: 33px;
224+
margin: 3px 0;
223225

224226
&.Badge--danger {
225227
--badge-bg: @error-color;

0 commit comments

Comments
 (0)