Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for Ember v3.28 #36

Merged
merged 16 commits into from
Dec 22, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default MountWidget.extend({
sidebarMinimized,
};

if (context === "discovery") {
if (context === "discovery/categories") {
args.filter = this.filter;
}
if (
Expand Down
56 changes: 54 additions & 2 deletions assets/javascripts/discourse/initializers/sidebars.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default {
});

withPluginApi("0.8.32", (api) => {
api.modifyClass("controller:discovery", {
api.modifyClass("controller:discovery/list", {
pluginId: PLUGIN_ID,
router: service(),
currentPath: readOnly("router.currentRouteName"),
Expand All @@ -83,9 +83,61 @@ export default {
return defaultFilter;
},
});
api.modifyClass("controller:discovery/categories", {
pluginId: PLUGIN_ID,
router: service(),
currentPath: readOnly("router.currentRouteName"),
navigationDefault: controller("navigation/default"),
navigationCategory: controller("navigation/category"),

api.modifyClass("controller:topic", {
@discourseComputed(
"navigationDefault.filterType",
"navigationCategory.filterType",
"currentPath"
)
sidebarFilter(defaultFilter, categoryFilter, currentPath) {
if (!currentPath) {
return undefined;
}
let path = currentPath.toLowerCase();
if (path.indexOf("categories") > -1) {
return "categories";
}
if (path.indexOf("category") > -1) {
return categoryFilter;
}
return defaultFilter;
},
});
api.modifyClass("controller:discovery/filter", {
pluginId: PLUGIN_ID,
router: service(),
currentPath: readOnly("router.currentRouteName"),
navigationDefault: controller("navigation/default"),
navigationCategory: controller("navigation/category"),

@discourseComputed(
"navigationDefault.filterType",
"navigationCategory.filterType",
"currentPath"
)
sidebarFilter(defaultFilter, categoryFilter, currentPath) {
if (!currentPath) {
return undefined;
}
let path = currentPath.toLowerCase();
if (path.indexOf("categories") > -1) {
return "categories";
}
if (path.indexOf("category") > -1) {
return categoryFilter;
}
return defaultFilter;
},
});

api.modifyClass("controller:topic", {
pluginId: `${PLUGIN_ID}-v2`,
category: alias("model.category"),
userHideRightSidebar: false,
});
Expand Down
70 changes: 59 additions & 11 deletions assets/javascripts/discourse/lib/layouts.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,57 @@ const layoutsNamespace = "layouts";
const PLUGIN_ID = "discourse-layouts";

const contexts = [
"discovery",
{
name: "discovery-categories",
route: "discovery/categories",
controller: "discovery/categories",
template: "discovery/categories",
},
{
name: "discovery-latest",
route: "discovery/latest",
controller: "discovery/list",
template: "discovery/list",
},
{
name: "discovery-unread",
route: "discovery/unread",
controller: "discovery/list",
template: "discovery/list",
},
{
name: "discovery-top",
route: "discovery/top",
controller: "discovery/list",
template: "discovery/list",
},
{
name: "discovery-category",
route: "discovery/category",
controller: "discovery/list",
template: "discovery/list",
},
{
name: "latest-category",
route: "discovery/latest-category",
controller: "discovery/list",
template: "discovery/list",
},
{
name: "top-category",
route: "discovery/top-category",
controller: "discovery/list",
template: "discovery/list",
},
"topic",
"user",
"users",
"tags-index",
{
name: "tag-show",
template: "tag-show",
route: "tag-show",
controller: "discovery/list",
template: "discovery/list",
},
"groups-index",
"groups-new",
Expand Down Expand Up @@ -112,14 +155,13 @@ function listLayoutsWidgets() {

function normalizeContext(input, opts = {}) {
let map = {
discovery: [
"topics",
"discovery",
"topic list",
"Topics",
"Discovery",
"Topic List",
],
"discovery-latest": ["discovery-latest"],
"discovery-categories": ["discovery-categories"],
"discovery-unread": ["discovery-unread"],
"discovery-top": ["discovery-top"],
"discovery-category": ["discovery-category"],
"latest-category": ["latest-category"],
"top-category": ["top-category"],
topic: ["topic", "Topic"],
user: ["user", "profile", "User", "Profile"],
users: ["users"],
Expand All @@ -136,7 +178,13 @@ function normalizeContext(input, opts = {}) {
if (opts.name) {
context = I18n.t(
{
discovery: "admin.layouts.widgets.context.discovery",
"discovery-latest": "admin.layouts.widgets.context.latest",
"discovery-categories": "admin.layouts.widgets.context.categories",
"discovery-unread": "admin.layouts.widgets.context.unread",
"discovery-top": "admin.layouts.widgets.context.top",
"discovery-category": "admin.layouts.widgets.context.category",
"latest-category": "admin.layouts.widgets.context.latest_category",
"top-category": "admin.layouts.widgets.context.top_category",
topic: "topic.title",
user: "user.profile",
users: "user.users",
Expand Down
2 changes: 2 additions & 0 deletions assets/javascripts/discourse/mixins/sidebars.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ function hasWidgets(widgets, widgetsSet) {

export default Mixin.create({
router: service(),
siteSettings: service(),
appEvents: service(),
path: alias("router._router.currentPath"),
mobileView: false,
tabletView: false,
Expand Down
7 changes: 7 additions & 0 deletions config/locales/client.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ en:
context:
label: "Contexts"
discovery: "Topic List"
latest: "Latest"
top: "Top"
unread: "Unread"
categories: "Categories"
category: "Topic List"
top_category: "Top Category List"
latest_category: "Latest Category List"
group:
label: "Groups"
users: "Users"
Expand Down
Loading