Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extensions/akismet/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"flarum-extension": {
"title": "Akismet",
"category": "moderation",
"category": "feature",
"icon": {
"image": "icon.jpg",
"backgroundSize": "cover",
Expand Down
2 changes: 1 addition & 1 deletion extensions/approval/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"flarum-extension": {
"title": "Approval",
"category": "moderation",
"category": "feature",
"icon": {
"name": "fas fa-check",
"backgroundColor": "#ABDC88",
Expand Down
2 changes: 1 addition & 1 deletion extensions/bbcode/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"flarum-extension": {
"title": "BBCode",
"category": "formatting",
"category": "feature",
"icon": {
"name": "fas fa-bold",
"backgroundColor": "#238C59",
Expand Down
2 changes: 1 addition & 1 deletion extensions/embed/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"flarum-extension": {
"title": "Embed",
"category": "formatting",
"category": "feature",
"icon": {
"name": "fas fa-code",
"backgroundColor": "#B9D233",
Expand Down
2 changes: 1 addition & 1 deletion extensions/emoji/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"flarum-extension": {
"title": "Emoji",
"category": "formatting",
"category": "feature",
"icon": {
"image": "icon.svg",
"backgroundColor": "#FECC4D"
Expand Down
2 changes: 1 addition & 1 deletion extensions/flags/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"flarum-extension": {
"title": "Flags",
"category": "moderation",
"category": "feature",
"icon": {
"name": "fas fa-flag",
"backgroundColor": "#D659B5",
Expand Down
2 changes: 1 addition & 1 deletion extensions/gdpr/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"flarum-extension": {
"title": "GDPR Data Management",
"category": "moderation",
"category": "feature",
"icon": {
"image": "resources/logo.svg",
"backgroundColor": "#EBF1FD",
Expand Down
2 changes: 1 addition & 1 deletion extensions/likes/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"flarum-extension": {
"title": "Likes",
"category": "discussion",
"category": "feature",
"icon": {
"name": "far fa-thumbs-up",
"backgroundColor": "#3A649D",
Expand Down
2 changes: 1 addition & 1 deletion extensions/lock/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"flarum-extension": {
"title": "Lock",
"category": "moderation",
"category": "feature",
"icon": {
"name": "fas fa-lock",
"backgroundColor": "#ddd",
Expand Down
2 changes: 1 addition & 1 deletion extensions/markdown/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"flarum-extension": {
"title": "Markdown",
"category": "formatting",
"category": "feature",
"icon": {
"image": "icon.svg",
"backgroundColor": "#000",
Expand Down
2 changes: 1 addition & 1 deletion extensions/mentions/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"flarum-extension": {
"title": "Mentions",
"category": "discussion",
"category": "feature",
"optional-dependencies": [
"flarum/tags"
],
Expand Down
2 changes: 1 addition & 1 deletion extensions/messages/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"extra": {
"flarum-extension": {
"title": "Messages",
"category": "discussion",
"category": "feature",
"optional-dependencies": [
"flarum/tags"
],
Expand Down
2 changes: 1 addition & 1 deletion extensions/nicknames/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"flarum-extension": {
"title": "Nicknames",
"category": "discussion",
"category": "feature",
"icon": {
"name": "fas fa-user-tag",
"backgroundColor": "#8E4529",
Expand Down
2 changes: 1 addition & 1 deletion extensions/pusher/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"flarum-extension": {
"title": "Pusher",
"category": "infrastructure",
"category": "feature",
"icon": {
"image": "icon.png",
"backgroundSize": "46% 63%",
Expand Down
2 changes: 1 addition & 1 deletion extensions/realtime/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"flarum-extension": {
"title": "Realtime",
"category": "infrastructure",
"category": "feature",
"icon": {
"image": "resources/assets/logo.svg",
"backgroundColor": "#E3E7F1",
Expand Down
2 changes: 1 addition & 1 deletion extensions/statistics/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"flarum-extension": {
"title": "Statistics",
"category": "analytics",
"category": "feature",
"icon": {
"name": "fas fa-chart-bar",
"backgroundColor": "#6932d1",
Expand Down
2 changes: 1 addition & 1 deletion extensions/sticky/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"flarum-extension": {
"title": "Sticky",
"category": "discussion",
"category": "feature",
"icon": {
"name": "fas fa-thumbtack",
"backgroundColor": "#D13E32",
Expand Down
2 changes: 1 addition & 1 deletion extensions/subscriptions/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"flarum-extension": {
"title": "Subscriptions",
"category": "discussion",
"category": "feature",
"optional-dependencies": [
"flarum/approval"
],
Expand Down
2 changes: 1 addition & 1 deletion extensions/suspend/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"flarum-extension": {
"title": "Suspend",
"category": "moderation",
"category": "feature",
"icon": {
"name": "fas fa-ban",
"backgroundColor": "#ddd",
Expand Down
2 changes: 1 addition & 1 deletion extensions/tags/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"flarum-extension": {
"title": "Tags",
"category": "discussion",
"category": "feature",
"icon": {
"name": "fas fa-tags",
"backgroundColor": "#F28326",
Expand Down
13 changes: 3 additions & 10 deletions framework/core/js/src/admin/AdminApplication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,9 @@ export default class AdminApplication extends Application {
registry = new AdminRegistry();

extensionCategories: Record<string, number> = {
feature: 100,
moderation: 90,
discussion: 80,
authentication: 70,
formatting: 60,
infrastructure: 55,
analytics: 52,
other: 50,
theme: 40,
language: 30,
feature: 30,
theme: 20,
language: 10,
};

history: IHistory = {
Expand Down
121 changes: 24 additions & 97 deletions framework/core/js/src/admin/components/AdminNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,13 @@ import getCategorizedExtensions from '../utils/getCategorizedExtensions';
import ItemList from '../../common/utils/ItemList';
import Stream from '../../common/utils/Stream';
import Input from '../../common/components/Input';
import Icon from '../../common/components/Icon';
import extractText from '../../common/utils/extractText';

export default class AdminNav extends Component {
oninit(vnode) {
super.oninit(vnode);

this.query = Stream('');
this.collapsed = {};

// Pre-expand the category of the currently active extension.
// m.route.get() may be null on a hard reload before Mithril has processed
// the hash, so fall back to parsing window.location.hash directly.
const currentRoute = m.route.get() || window.location.hash.replace(/^#/, '');
const extensionMatch = currentRoute.match(/\/extensions?\/([^/?]+)/);
if (extensionMatch) {
const activeId = extensionMatch[1];
const categorized = getCategorizedExtensions();
for (const [category, extensions] of Object.entries(categorized)) {
if (extensions.some((ext) => ext.id === activeId)) {
this.collapsed[category] = false;
break;
}
}
}
}

view() {
Expand Down Expand Up @@ -72,16 +54,6 @@ export default class AdminNav extends Component {
}
}

isCollapsed(category) {
if (this.query()) return false;
return this.collapsed[category] !== false;
}

toggleCollapsed(category) {
this.collapsed[category] = !this.isCollapsed(category);
m.redraw();
}

/**
* Build an item list of main links to show in the admin navigation.
*
Expand Down Expand Up @@ -165,88 +137,43 @@ export default class AdminNav extends Component {
return items;
}

categoryIcon(category) {
const icons = {
analytics: 'fas fa-chart-bar',
authentication: 'fas fa-lock',
discussion: 'fas fa-comments',
feature: 'fas fa-star',
formatting: 'fas fa-paragraph',
infrastructure: 'fas fa-server',
language: 'fas fa-language',
moderation: 'fas fa-shield-alt',
other: 'fas fa-cube',
theme: 'fas fa-paint-brush',
};
return icons[category] || 'fas fa-puzzle-piece';
}

extensionItems() {
const items = new ItemList();

const categorizedExtensions = getCategorizedExtensions();
const categories = app.extensionCategories;
const query = this.query().toUpperCase();

Object.keys(categorizedExtensions).map((category) => {
const extensions = categorizedExtensions[category];
const count = extensions.length;

// When searching, only show categories that have matching results
const matchingExtensions = extensions.filter((extension) => {
if (!query) return true;
const title = extension.extra['flarum-extension'].title || '';
const description = extension.description || '';
return title.toUpperCase().includes(query) || description.toUpperCase().includes(query);
});

if (query && matchingExtensions.length === 0) return;

const isOpen = !this.isCollapsed(category);

const abandonedInCategory = extensions.filter((ext) => ext.abandoned);
const hasDanger = abandonedInCategory.some((ext) => typeof ext.abandoned === 'string');
const categoryBadgeType = abandonedInCategory.length > 0 ? (hasDanger ? 'danger' : 'warning') : null;

items.add(
`category-${category}`,
<button
className="ExtensionListTitle"
onclick={(e) => {
e.stopPropagation();
this.toggleCollapsed(category);
}}
>
<Icon name={this.categoryIcon(category)} className="ExtensionListTitle-icon" />
<span className="ExtensionListTitle-label">{app.translator.trans(`core.admin.nav.categories.${category}`)}</span>
{categoryBadgeType && <span className={`Badge Badge--${categoryBadgeType} ExtensionListTitle-badge`}>!</span>}
<span className="ExtensionListTitle-count">{count}</span>
<Icon name={`fas fa-chevron-${isOpen ? 'down' : 'right'}`} className="ExtensionListTitle-chevron" />
</button>,
categories[category]
);

if (!isOpen) return;
if (!this.query()) {
items.add(
`category-${category}`,
<h4 className="ExtensionListTitle">{app.translator.trans(`core.admin.nav.categories.${category}`)}</h4>,
categories[category]
);
}

matchingExtensions.map((extension) => {
categorizedExtensions[category].map((extension) => {
const query = this.query().toUpperCase();
const title = extension.extra['flarum-extension'].title || '';
const description = extension.description || '';
const isAbandoned = extension.abandoned;
const hasReplacement = typeof isAbandoned === 'string';

items.add(
`extension-${extension.id}`,
<ExtensionLinkButton
href={app.route('extension', { id: extension.id })}
extensionId={extension.id}
className="ExtensionNavButton"
title={description}
>
{title}
{isAbandoned && <span className={`Badge Badge--${hasReplacement ? 'danger' : 'warning'}`}>!</span>}
</ExtensionLinkButton>,
categories[category]
);
if (!query || title.toUpperCase().includes(query) || description.toUpperCase().includes(query)) {
items.add(
`extension-${extension.id}`,
<ExtensionLinkButton
href={app.route('extension', { id: extension.id })}
extensionId={extension.id}
className="ExtensionNavButton"
title={description}
>
{title}
{isAbandoned && <span className={`Badge Badge--${hasReplacement ? 'danger' : 'warning'}`}>!</span>}
</ExtensionLinkButton>,
categories[category]
);
}
});
});

Expand Down
Loading
Loading