Compatibility with discourse admin

Fixes towards admin settings.
This commit is contained in:
2026-03-08 00:56:01 -04:00
parent 3e5951dd81
commit 8c1ad49518
6 changed files with 311 additions and 19 deletions

View File

@@ -16,7 +16,9 @@ const TABS = [
id: "navbar",
label: "Navbar",
settings: new Set([
"navbar_signin_label", "navbar_join_label", "navbar_bg_color", "navbar_border_style"
"navbar_signin_label", "navbar_signin_enabled", "navbar_signin_color",
"navbar_join_label", "navbar_join_enabled", "navbar_join_color",
"navbar_bg_color", "navbar_border_style"
])
},
{
@@ -25,13 +27,14 @@ const TABS = [
settings: new Set([
"hero_title", "hero_subtitle", "hero_card_enabled", "hero_background_image_url",
"hero_image_urls", "hero_image_max_height",
"hero_primary_button_label", "hero_primary_button_url",
"hero_secondary_button_label", "hero_secondary_button_url",
"hero_primary_button_enabled", "hero_primary_button_label", "hero_primary_button_url",
"hero_secondary_button_enabled", "hero_secondary_button_label", "hero_secondary_button_url",
"hero_video_url", "hero_video_button_color", "hero_video_blur_on_hover",
"hero_bg_dark", "hero_bg_light", "hero_min_height", "hero_border_style",
"hero_card_bg_dark", "hero_card_bg_light", "hero_card_opacity",
"contributors_enabled", "contributors_title", "contributors_title_enabled",
"contributors_count_label", "contributors_count_label_enabled",
"contributors_alignment", "contributors_pill_max_width", "contributors_pill_bg_color",
"contributors_days", "contributors_count"
])
},
@@ -62,7 +65,8 @@ const TABS = [
id: "topics",
label: "Trending",
settings: new Set([
"topics_enabled", "topics_title", "topics_count", "topics_card_bg_color",
"topics_enabled", "topics_title_enabled", "topics_title", "topics_count",
"topics_card_bg_color",
"topics_bg_dark", "topics_bg_light", "topics_min_height", "topics_border_style"
])
},
@@ -70,7 +74,8 @@ const TABS = [
id: "groups",
label: "Spaces",
settings: new Set([
"groups_enabled", "groups_title", "groups_count", "groups_selected", "groups_card_bg_color",
"groups_enabled", "groups_title_enabled", "groups_title", "groups_count",
"groups_selected", "groups_card_bg_color",
"groups_bg_dark", "groups_bg_light", "groups_min_height", "groups_border_style"
])
},
@@ -218,6 +223,55 @@ function wrapBgPairs() {
});
}
/**
* Remove all injected tabs and restore clean state.
* Called when navigating away from the community-landing settings page.
*/
function cleanupTabs() {
// Remove injected <li> tabs from native nav
document.querySelectorAll("li.cl-admin-tab").forEach((li) => li.remove());
// Restore native Settings <li> — remove our hook class
const nativeItem = document.querySelector(".cl-native-settings-item");
if (nativeItem) {
nativeItem.classList.remove("cl-native-settings-item", "active");
}
// Remove filter-active class from native nav
const nativeNav = document.querySelector(".d-nav-submenu__tabs");
if (nativeNav) {
nativeNav.classList.remove("cl-filter-active");
}
// Remove standalone tab bar if present
const standaloneBar = document.querySelector(".cl-admin-tabs");
if (standaloneBar) {
standaloneBar.remove();
}
// Unwrap bg-pair wrappers
document.querySelectorAll(".cl-bg-pair").forEach((wrapper) => {
const parent = wrapper.parentNode;
while (wrapper.firstChild) {
parent.insertBefore(wrapper.firstChild, wrapper);
}
wrapper.remove();
});
// Remove cl-tabs-active from container and un-hide all settings
const container = getContainer();
if (container) {
container.classList.remove("cl-tabs-active");
container.querySelectorAll(".cl-tab-hidden").forEach((el) => {
el.classList.remove("cl-tab-hidden");
});
}
// Reset state
currentTab = "settings";
filterActive = false;
}
function buildTabsUI() {
const container = getContainer();
if (!container) return false;
@@ -366,6 +420,7 @@ export default {
// Initial injection with retries
let attempts = 0;
const tryInject = () => {
if (!isActive) return; // Guard: user navigated away during retries
if (buildTabsUI() || attempts > 15) return;
attempts++;
setTimeout(tryInject, 200);
@@ -387,7 +442,10 @@ export default {
}, 500);
}
} else {
// Left plugin settings page — clean up
// Left plugin settings page — clean up injected tabs
if (isActive) {
cleanupTabs();
}
isActive = false;
if (recheckTimer) {
clearInterval(recheckTimer);

View File

@@ -102,6 +102,20 @@ html.dark-scheme .cl-admin-tabs .cl-admin-tab:hover {
flex: 1;
min-width: 0;
margin-bottom: 0 !important;
padding-bottom: 10px !important;
}
/* Inside bg-pairs, let the label and value stack vertically to fit the narrower space */
.cl-bg-pair > .row.setting .setting-label {
float: none;
width: 100%;
margin-right: 0;
}
.cl-bg-pair > .row.setting .setting-value {
float: none;
width: 100%;
padding-right: 0;
}
.cl-bg-pair.cl-tab-hidden {
@@ -173,8 +187,149 @@ html.dark-scheme .admin-detail:not(.cl-tabs-active) .row.setting[data-setting="c
border-top-color: rgba(255, 255, 255, 0.12);
}
/* ── Tab content spacing ── */
/* ── Settings row distribution (match Discourse native layout) ── */
.cl-tabs-active .row.setting[data-setting] {
margin-bottom: 16px;
.cl-tabs-active .row.setting {
padding-bottom: 20px;
}
/* Clearfix without overflow:hidden (avoids clipping dropdowns/color pickers) */
.cl-tabs-active .row.setting::after {
content: "";
display: table;
clear: both;
}
.cl-tabs-active .row.setting .setting-label {
float: left;
width: 17.6576%;
margin-right: 12px;
}
.cl-tabs-active .row.setting .setting-label h3 {
font-size: var(--font-0);
font-weight: normal;
}
.cl-tabs-active .row.setting .setting-label .history-icon {
opacity: 0;
transition: opacity 0.3s;
color: var(--primary-medium);
}
.cl-tabs-active .row.setting .setting-label:hover .history-icon {
opacity: 1;
}
.cl-tabs-active .row.setting .setting-value {
float: left;
width: 53%;
padding-right: 20px;
}
.cl-tabs-active .row.setting .setting-value input[type="checkbox"],
.cl-tabs-active .row.setting .setting-value input[type="radio"] {
flex: 0 0 auto;
}
.cl-tabs-active .row.setting .setting-value .select-kit {
width: 100% !important;
}
.cl-tabs-active .row.setting .setting-value .category-selector {
width: 95%;
}
.cl-tabs-active .row.setting .setting-value .input-setting-string,
.cl-tabs-active .row.setting .setting-value .input-setting-integer,
.cl-tabs-active .row.setting .setting-value .input-setting-textarea {
width: 100%;
}
.cl-tabs-active .row.setting .setting-value .input-setting-textarea {
height: 150px;
}
.cl-tabs-active .row.setting .setting-value .input-setting-list {
padding: 1px;
background-color: var(--secondary);
border: 1px solid var(--input-border-color);
border-radius: 3px;
transition: border linear 0.2s, box-shadow linear 0.2s;
}
.cl-tabs-active .row.setting .setting-controls {
float: left;
}
.cl-tabs-active .row.setting .desc,
.cl-tabs-active .row.setting .validation-error {
padding-top: 3px;
font-size: var(--font-down-1);
line-height: var(--line-height-large);
}
.cl-tabs-active .row.setting .desc {
color: var(--primary-medium);
}
.cl-tabs-active .row.setting .validation-error {
color: var(--danger);
}
.cl-tabs-active .row.setting .setting-theme-warning {
font-size: var(--font-down-1);
color: var(--primary-medium);
}
/* Overridden settings indicator (yellow dot) */
.cl-tabs-active .row.setting.overridden .values input {
background-color: var(--highlight-bg);
}
.cl-tabs-active .row.setting.overridden h3 {
position: relative;
}
.cl-tabs-active .row.setting.overridden h3::before {
content: "";
position: absolute;
top: 0.5rem;
left: -1rem;
width: 0.5rem;
height: 0.5rem;
border-radius: 100%;
background-color: var(--highlight-high);
}
.cl-tabs-active .row.setting.overridden.string input[type="text"],
.cl-tabs-active .row.setting.overridden.string input[type="password"],
.cl-tabs-active .row.setting.overridden.string textarea {
background-color: var(--highlight-bg);
}
@media (max-width: 767px) {
.cl-tabs-active .row.setting .setting-label {
float: none;
width: 100%;
margin-right: 0;
margin-left: 0;
}
.cl-tabs-active .row.setting .setting-label h3 {
margin-bottom: 6px;
}
.cl-tabs-active .row.setting .setting-value {
width: 100%;
padding-right: 0;
}
.cl-tabs-active .row.setting .setting-value .input-setting-list {
width: 100%;
}
.cl-tabs-active .row.setting .setting-value .select-kit {
width: 100% !important;
}
}

View File

@@ -884,6 +884,10 @@
margin-top: 2rem;
}
.cl-hero__creators--left {
align-items: flex-start;
}
.cl-hero__creators-title {
font-size: 0.85rem;
font-weight: 700;