From 43a939ff1a43afd0f8c56e0c34566245805ce056 Mon Sep 17 00:00:00 2001 From: Emerick Rogul Date: Wed, 26 Jun 2024 16:17:00 -0400 Subject: [PATCH] Merge pull request #24391 from brave/cr127-followup-remove-redundant-sidepanel-settings Remove redundant side panel settings --- .../brave_overrides/appearance_page.ts | 69 +++++++++++-------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/browser/resources/settings/brave_overrides/appearance_page.ts b/browser/resources/settings/brave_overrides/appearance_page.ts index 0761a9a28d54..f0953685e3a8 100644 --- a/browser/resources/settings/brave_overrides/appearance_page.ts +++ b/browser/resources/settings/brave_overrides/appearance_page.ts @@ -3,8 +3,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // you can obtain one at https://mozilla.org/MPL/2.0/. -// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck - import '../brave_appearance_page/super_referral.js' import '../brave_appearance_page/brave_theme.js' @@ -20,18 +18,18 @@ RegisterPolymerTemplateModifications({ 'settings-appearance-page': (templateContent) => { const theme = templateContent.getElementById('themeRow') if (!theme) { - console.error(`[Brave Settings Overrides] Couldn't find #themeRow`) + console.error(`[Settings] Couldn't find #themeRow`) } else { const useDefaultButtonTemplate = templateContent.querySelector( 'template[is=dom-if][if="[[prefs.extensions.theme.id.value]]"]') if (!useDefaultButtonTemplate) { console.error( - '[Brave Settings Overrides] Appearance Page cannot find use default' + + '[Settings] Appearance Page cannot find use default' + ' theme button template') } else { - useDefaultButtonTemplate.setAttribute("restamp", "true") + useDefaultButtonTemplate.setAttribute('restamp', 'true') } - theme.setAttribute("class", "settings-row hr") + theme.setAttribute('class', 'settings-row hr') theme.insertAdjacentHTML( 'beforebegin', getTrustedHTML` @@ -49,13 +47,13 @@ RegisterPolymerTemplateModifications({ ) if (hasSuperReferral) { // Routes - const r = Router.getInstance().routes_ + const r = Router.getInstance().getRoutes() if (!r.APPEARANCE) { console.error( - '[Brave Settings Overrides] Routes: could not find APPEARANCE page') + '[Settings] Routes: could not find APPEARANCE page') return } else { - r.THEMES = r.APPEARANCE.createChild('/themes'); + r.THEMES = r.APPEARANCE.createChild('/themes') // Hide chromium's theme section. It's replaced with our themes page. if (theme) { theme.remove() @@ -65,7 +63,7 @@ RegisterPolymerTemplateModifications({ const pages = templateContent.getElementById('pages') if (!pages) { console.error( - `[Brave Settings Overrides] Couldn't find appearance_page #pages`) + `[Settings] Couldn't find appearance_page #pages`) } else { pages.appendChild( html` @@ -87,7 +85,7 @@ RegisterPolymerTemplateModifications({ '[pref="{{prefs.browser.show_home_button}}"]') if (!homeButtonToggle) { console.error( - `[Brave Settings Overrides] Couldn't find home button toggle`) + `[Settings] Couldn't find home button toggle`) } else { homeButtonToggle.remove() } @@ -95,7 +93,7 @@ RegisterPolymerTemplateModifications({ 'template[is=dom-if][if="[[prefs.browser.show_home_button.value]]"]') if (!homeButtonOptionsTemplate) { console.error( - `[Brave Settings Overrides] Couldn't find home button options template`) + `[Settings] Couldn't find home button options template`) } else { homeButtonOptionsTemplate.remove() } @@ -104,7 +102,7 @@ RegisterPolymerTemplateModifications({ '[pref="{{prefs.bookmark_bar.show_on_all_tabs}}"]') if (!bookmarkBarToggle) { console.error( - `[Brave Settings Overrides] Couldn't find bookmark bar toggle`) + `[Settings] Couldn't find bookmark bar toggle`) } else { // Remove Chromium bookmark toggle becasue it is replaced by // settings-brave-appearance-bookmark-bar @@ -115,38 +113,39 @@ RegisterPolymerTemplateModifications({ const defaultFontSize = templateContent.querySelector( '.cr-row:has(#defaultFontSize)') if (!defaultFontSize) { - console.error(`[Brave Settings Overrides] Couldn't find default font size option`) + console.error(`[Settings] Couldn't find default font size option`) } else { // Just hide instead of removing as upstream js refers this. - defaultFontSize.setAttribute("hidden", "true") + defaultFontSize.setAttribute('hidden', 'true') } const customizeFontsSubpageTrigger = templateContent.getElementById('customize-fonts-subpage-trigger') if (!customizeFontsSubpageTrigger) { - console.error(`[Brave Settings Overrides] Couldn't find customize fonts subpage trigger`) + console.error(`[Settings] Couldn't find customize fonts subpage trigger`) } else { customizeFontsSubpageTrigger.remove() } const customizeFontsTemplate = templateContent.querySelector( 'template[is=dom-if][route-path="/fonts"]') if (!customizeFontsTemplate) { - console.error(`[Brave Settings Overrides] Couldn't find customize fonts subpage template`) + console.error(`[Settings] Couldn't find customize fonts subpage template`) } else { customizeFontsTemplate.remove() } const pageZoom = templateContent.querySelector('.cr-row:has(#pageZoom)') if (!pageZoom) { - console.error(`[Brave Settings Overrides] Couldn't find page zoom`) + console.error(`[Settings] Couldn't find page zoom`) } else { pageZoom.remove() } - const hrsToHide = templateContent.querySelectorAll('div.hr:not(#themeRow):not([hidden="[[!pageVisibility.bookmarksBar]]"])'); + const hrsToHide = templateContent.querySelectorAll( + 'div.hr:not(#themeRow):not([hidden="[[!pageVisibility.bookmarksBar]]"])') // We only want to hide two hrs now from upstream appearance_page.html. if (hrsToHide.length !== 2) { - console.error(`[Brave Settings Overrides] detected more than two hrs to hide`) + console.error(`[Settings] detected more than two hrs to hide`) } else { for (const hr of hrsToHide) { - hr.setAttribute("hidden", "true") + hr.setAttribute('hidden', 'true') } } @@ -154,7 +153,7 @@ RegisterPolymerTemplateModifications({ const confirmToQuit = templateContent.querySelector( '[pref="{{prefs.browser.confirm_to_quit}}"]') if (!confirmToQuit) { - console.error(`[Brave Settings Overrides] Couldn't find confirm to quit`) + console.error(`[Settings] Couldn't find confirm to quit`) } else { confirmToQuit.remove() } @@ -162,7 +161,7 @@ RegisterPolymerTemplateModifications({ const tabsToLinks = templateContent.querySelector( '[pref="{{prefs.webkit.webprefs.tabs_to_links}}"]') if (!tabsToLinks) { - console.error(`[Brave Settings Overrides] Couldn't find tabs to links`) + console.error(`[Settings] Couldn't find tabs to links`) } else { tabsToLinks.remove() } @@ -174,7 +173,7 @@ RegisterPolymerTemplateModifications({ 'template[is=dom-if][if="[[!showHoverCardImagesOption_]]"]') if (!hoverCardImagesTemplateNotShow) { console.error( - '[Brave Settings Overrides] Appearance Page cannot find hover card' + + '[Settings] Appearance Page cannot find hover card' + ' images template with !showHoverCardImagesOption_') } else { hoverCardImagesTemplateNotShow.remove() @@ -183,7 +182,7 @@ RegisterPolymerTemplateModifications({ 'template[is=dom-if][if="[[showHoverCardImagesOption_]]"]') if (!hoverCardImagesTemplateShow) { console.error( - '[Brave Settings Overrides] Appearance Page cannot find hover card' + + '[Settings] Appearance Page cannot find hover card' + ' images template with showHoverCardImagesOption_') } else { hoverCardImagesTemplateShow.remove() @@ -191,10 +190,24 @@ RegisterPolymerTemplateModifications({ const colorSchemeModeRow = templateContent.getElementById( 'colorSchemeModeRow') if (!colorSchemeModeRow) { - console.error( - `[Brave Settings Overrides] Couldn't find colorSchemeModeRow`) + console.error(`[Settings] Couldn't find colorSchemeModeRow`) } else { colorSchemeModeRow.remove() } - }, + + // Remove upstream side panel header and radio buttons from Appearance as we + // have our own separate side panel section + const sidePanelSettingsRadioGroup = + templateContent.getElementById('side-panel') + if (!sidePanelSettingsRadioGroup) { + console.error(`[Settings] Couldn't find side-panel`) + } else { + if (sidePanelSettingsRadioGroup.parentNode && + sidePanelSettingsRadioGroup.parentNode.previousElementSibling) { + sidePanelSettingsRadioGroup.parentNode.previousElementSibling. + setAttribute('hidden', 'true') + } + sidePanelSettingsRadioGroup.setAttribute('hidden', 'true') + } + } })