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
1 change: 1 addition & 0 deletions .discourse-compatibility
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
< 3.5.0.beta5-dev: 8f390815349bd8e930e511907c3031e3d4fb14b8
< 3.5.0.beta1-dev: 59869be98ccaeb37fc23043c11e7d2f8f151732a
< 3.4.0.beta1-dev: a5bc3c041209463b2333035b87daaad1c6c56b2d
< 3.3.0.beta1-dev: df9044b21463d73bb61689945e37160c24def133
Expand Down
44 changes: 23 additions & 21 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,44 @@ GEM
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
ast (2.4.2)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.9)
ast (2.4.3)
base64 (0.3.0)
benchmark (0.4.1)
bigdecimal (3.2.1)
concurrent-ruby (1.3.5)
connection_pool (2.5.0)
drb (2.2.1)
connection_pool (2.5.3)
drb (2.2.3)
i18n (1.14.7)
concurrent-ruby (~> 1.0)
json (2.10.2)
language_server-protocol (3.17.0.4)
json (2.12.2)
language_server-protocol (3.17.0.5)
lint_roller (1.1.0)
logger (1.6.6)
logger (1.7.0)
minitest (5.25.5)
parallel (1.26.3)
parser (3.3.7.1)
parallel (1.27.0)
parser (3.3.8.0)
ast (~> 2.4.1)
racc
prettier_print (1.2.1)
prism (1.4.0)
racc (1.8.1)
rack (3.1.12)
rack (3.1.15)
rainbow (3.1.1)
regexp_parser (2.10.0)
rubocop (1.74.0)
rubocop (1.76.0)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.38.0, < 2.0)
rubocop-ast (>= 1.45.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.39.0)
parser (>= 3.3.1.0)
rubocop-ast (1.45.0)
parser (>= 3.3.7.2)
prism (~> 1.4)
rubocop-capybara (2.22.1)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
Expand All @@ -65,13 +67,13 @@ GEM
rubocop-factory_bot (2.27.1)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-rails (2.30.3)
rubocop-rails (2.32.0)
activesupport (>= 4.2.0)
lint_roller (~> 1.1)
rack (>= 1.1)
rubocop (>= 1.72.1, < 2.0)
rubocop-ast (>= 1.38.0, < 2.0)
rubocop-rspec (3.5.0)
rubocop (>= 1.75.0, < 2.0)
rubocop-ast (>= 1.44.0, < 2.0)
rubocop-rspec (3.6.0)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-rspec_rails (2.31.0)
Expand All @@ -98,4 +100,4 @@ DEPENDENCIES
syntax_tree

BUNDLED WITH
2.6.6
2.6.9
Original file line number Diff line number Diff line change
@@ -1,58 +1,59 @@
import Component from "@ember/component";
import { classNames } from "@ember-decorators/component";
import icon from "discourse/helpers/d-icon";

// Used instead of dasherize for backwards compatibility with stable
const getClassName = (text) => {
return text.toLowerCase().replace(/\s/g, "-");
};

export default {
setupComponent() {
@classNames("above-site-header-outlet", "header-submenus")
export default class HeaderSubmenus extends Component {
init() {
super.init(...arguments);

try {
const splitMenuItems = settings.Menu_items.split("|").filter(Boolean);
const splitSubmenuItems =
settings.Submenu_items.split("|").filter(Boolean);

const menuItemsArray = [];
const SubmenuItemsArray = [];

splitSubmenuItems.forEach((item) => {
const fragments = item.split(",").map((fragment) => fragment.trim());
const parent = fragments[0].toLowerCase();
const text = fragments[1];

if (text.toLowerCase() === "divider") {
const divider = {
parent,
divider: true,
};
return SubmenuItemsArray.push(divider);
}

const className = getClassName(text);
const icon =
const itemIcon =
fragments[2].toLowerCase() === "none"
? ""
: fragments[2].toLowerCase();
const href = fragments[3];
const target = fragments[4] === "blank" ? "_blank" : "";
const title = fragments[5];

const submenuItem = {
parent,
text,
className,
icon,
icon: itemIcon,
href,
target,
title,
};
SubmenuItemsArray.push(submenuItem);
});

splitMenuItems.forEach((item) => {
const fragments = item.split(",").map((fragment) => fragment.trim());
const parentFor = fragments[0].toLowerCase();
const text = fragments[0];
const className = getClassName(text);
const icon =
const itemIcon =
fragments[1].toLowerCase() === "none"
? ""
: fragments[1].toLowerCase();
Expand All @@ -61,20 +62,17 @@ export default {
const childItems = SubmenuItemsArray.filter(
(link) => link.parent === parentFor
);

const menuItem = {
text,
className,
icon,
icon: itemIcon,
title,
view,
childItems,
};
menuItemsArray.push(menuItem);
});

const showCaret = settings.Show_caret;

this.setProperties({
menuItems: menuItemsArray,
showCaret,
Expand All @@ -86,5 +84,59 @@ export default {
"There's an issue in the Header Submenus Component. Check if your settings are entered correctly"
);
}
},
};
}

<template>
<div id="top-menu" class="top-menu">
<div class="menu-content wrap">
<div class="menu-placeholder">
<div class="menu-item-container">
<div class="menu-items">
{{#each this.menuItems as |item|}}
<a
class="menu-item {{item.view}} {{item.className}}"
title={{item.title}}
>
{{#if item.icon}}
{{icon item.icon}}
{{/if}}

{{item.text}}

{{#if this.showCaret}}
{{icon "caret-right"}}
{{/if}}

<div class="d-header-dropdown">
<ul class="d-dropdown-menu">
{{#each item.childItems as |child|}}
{{#if child.divider}}
<li class="divider"></li>
{{else}}
<li class="submenu-item {{child.className}}">
<a
target={{child.target}}
title={{child.title}}
class="submenu-link"
href={{child.href}}
>
{{#if child.icon}}
{{icon child.icon}}
{{/if}}

{{child.text}}
</a>
</li>
{{/if}}
{{/each}}
</ul>
</div>
</a>
{{/each}}
</div>
</div>
</div>
</div>
</div>
</template>
}

This file was deleted.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"private": true,
"devDependencies": {
"@discourse/lint-configs": "2.11.1",
"ember-template-lint": "7.0.1",
"eslint": "9.22.0",
"@discourse/lint-configs": "2.25.0",
"ember-template-lint": "7.8.1",
"eslint": "9.28.0",
"prettier": "3.5.3",
"stylelint": "16.16.0"
"stylelint": "16.20.0"
},
"engines": {
"node": ">= 22",
Expand Down
Loading