mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Plugin link fixes and enhancements, ship plugin desc to client
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import Service, { service } from "@ember/service";
|
||||
import { adminRouteValid } from "discourse/lib/admin-utilities";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import escapeRegExp from "discourse/lib/escape-regexp";
|
||||
import getURL from "discourse/lib/get-url";
|
||||
@@ -64,15 +65,25 @@ export default class AdminPaletteDataSource extends Service {
|
||||
label.toLowerCase(),
|
||||
type: "page",
|
||||
icon: link.icon,
|
||||
description: link.description ? i18n(link.description) : "",
|
||||
description: link.description
|
||||
? link.description.includes(" ")
|
||||
? link.description
|
||||
: i18n(link.description)
|
||||
: "",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// TODO (martin) Probably hash these with the plugin name as key
|
||||
const visiblePlugins = (PreloadStore.get("visiblePlugins") || []).filter(
|
||||
(plugin) => plugin.admin_route && plugin.enabled
|
||||
);
|
||||
const plugins = {};
|
||||
(PreloadStore.get("visiblePlugins") || {}).forEach((plugin) => {
|
||||
if (
|
||||
plugin.admin_route &&
|
||||
plugin.enabled &&
|
||||
adminRouteValid(this.router, plugin.admin_route)
|
||||
) {
|
||||
plugins[plugin.name] = plugin;
|
||||
}
|
||||
});
|
||||
ajax("/admin/palette/settings.json").then((result) => {
|
||||
result.forEach((setting) => {
|
||||
// TODO: (martin) Might want to use the sidebar link name for this instead of the
|
||||
@@ -100,10 +111,8 @@ export default class AdminPaletteDataSource extends Service {
|
||||
|
||||
let url;
|
||||
if (setting.plugin) {
|
||||
const plugin = visiblePlugins.find(
|
||||
(visiblePlugin) => visiblePlugin.name === setting.plugin
|
||||
);
|
||||
if (plugin && plugin.admin_route) {
|
||||
const plugin = plugins[setting.plugin];
|
||||
if (plugin) {
|
||||
url = plugin.admin_route.use_new_show_route
|
||||
? this.router.urlFor(
|
||||
`adminPlugins.show.settings`,
|
||||
|
||||
@@ -84,9 +84,8 @@ class SidebarAdminSectionLink extends BaseCustomSidebarSectionLink {
|
||||
// for the plugin ID has its own nested routes defined in the plugin.
|
||||
if (this.router.currentRoute.name === "adminPlugins.show.settings") {
|
||||
if (
|
||||
this.adminSidebarNavLink.route?.includes(
|
||||
this.router.currentRoute.parent.params.plugin_id
|
||||
)
|
||||
this.adminSidebarNavLink.route?.split(".").last ===
|
||||
this.router.currentRoute.parent.params.plugin_id
|
||||
) {
|
||||
return this.router.currentRoute.name;
|
||||
}
|
||||
@@ -273,6 +272,7 @@ function pluginAdminRouteLinks(router) {
|
||||
label: plugin.admin_route.label,
|
||||
text: plugin.humanized_name,
|
||||
icon: "gear",
|
||||
description: plugin.description,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -101,6 +101,7 @@ class ApplicationLayoutPreloader
|
||||
humanized_name: plugin.humanized_name,
|
||||
admin_route: plugin.full_admin_route,
|
||||
enabled: plugin.enabled?,
|
||||
description: plugin.metadata.about,
|
||||
}
|
||||
end,
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# name: chat
|
||||
# about: Adds chat functionality to your site so it can natively support both long-form and short-form communication needs of your online community.
|
||||
# about: Adds chat functionality to your site so it can natively support both long-form and short-form communication needs of your online community
|
||||
# meta_topic_id: 230881
|
||||
# version: 0.4
|
||||
# authors: Kane York, Mark VanLandingham, Martin Brennan, Joffrey Jaffeux
|
||||
|
||||
Reference in New Issue
Block a user