From f4c0a8b5aa3353ad1a9909ddc55b06802169d6d0 Mon Sep 17 00:00:00 2001
From: Witherking25 <witherking@withertech.com>
Date: Thu, 1 Jun 2023 19:01:21 -0400
Subject: add cef console button to developer settings (#441)

* add cef console button

* Small fix: handle missing localization in backend plus a small typo in the english language (#443)

* Hotfix for i18n where the detector was overriding localStorage

* Please, pnpm, cooperate

* Small fix regarding the backend getting hammered when switching to not supported languages plus a small english typo

* Add a get_tab_id function to utilities

* Go straight to SharedJSContext into console button

* clean up some log statements, and some extra parentheses

---------

Co-authored-by: Marco Rodolfi <marco.rodolfi@tuta.io>
Co-authored-by: Party Wumpus <48649272+PartyWumpus@users.noreply.github.com>
---
 .../components/settings/pages/developer/index.tsx    | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

(limited to 'frontend/src/components/settings/pages/developer/index.tsx')

diff --git a/frontend/src/components/settings/pages/developer/index.tsx b/frontend/src/components/settings/pages/developer/index.tsx
index 774bb449..812ff052 100644
--- a/frontend/src/components/settings/pages/developer/index.tsx
+++ b/frontend/src/components/settings/pages/developer/index.tsx
@@ -4,12 +4,13 @@ import {
   DialogControlsSection,
   DialogControlsSectionHeader,
   Field,
+  Navigation,
   TextField,
   Toggle,
 } from 'decky-frontend-lib';
 import { useRef, useState } from 'react';
 import { useTranslation } from 'react-i18next';
-import { FaFileArchive, FaLink, FaReact, FaSteamSymbol } from 'react-icons/fa';
+import { FaFileArchive, FaLink, FaReact, FaSteamSymbol, FaTerminal } from 'react-icons/fa';
 
 import { setShouldConnectToReactDevTools, setShowValveInternal } from '../../../../developer';
 import { installFromURL } from '../../../../store';
@@ -75,6 +76,23 @@ export default function DeveloperSettings() {
       </DialogControlsSection>
       <DialogControlsSection>
         <DialogControlsSectionHeader>{t('SettingsDeveloperIndex.header')}</DialogControlsSectionHeader>
+        <Field
+          label={t('SettingsDeveloperIndex.cef_console.label')}
+          description={<span style={{ whiteSpace: 'pre-line' }}>{t('SettingsDeveloperIndex.cef_console.desc')}</span>}
+          icon={<FaTerminal style={{ display: 'block' }} />}
+        >
+          <DialogButton onClick={async () => {
+            let res = await window.DeckyPluginLoader.callServerMethod('get_tab_id', { "name": "SharedJSContext" });
+            if (res.success) {
+              Navigation.NavigateToExternalWeb("localhost:8080/devtools/inspector.html?ws=localhost:8080/devtools/page/"+res.result);
+            } else {
+              console.error('Unable to find ID for SharedJSContext tab ', res.result);
+              Navigation.NavigateToExternalWeb("localhost:8080");
+            }
+          }}>
+            {t('SettingsDeveloperIndex.cef_console.button')}
+          </DialogButton>
+        </Field>
         <RemoteDebuggingSettings />
         <Field
           label={t('SettingsDeveloperIndex.valve_internal.label')}
-- 
cgit v1.2.3


From 8049417e036a8d855d0455f32d71caf2ffc39c11 Mon Sep 17 00:00:00 2001
From: Party Wumpus <48649272+PartyWumpus@users.noreply.github.com>
Date: Fri, 2 Jun 2023 00:26:08 +0100
Subject: Attempt to appease the linter

I think the first navigation being on one line looks nicer, but it's over the 120 character limit :(
---
 .../components/settings/pages/developer/index.tsx  | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

(limited to 'frontend/src/components/settings/pages/developer/index.tsx')

diff --git a/frontend/src/components/settings/pages/developer/index.tsx b/frontend/src/components/settings/pages/developer/index.tsx
index 812ff052..200f13ab 100644
--- a/frontend/src/components/settings/pages/developer/index.tsx
+++ b/frontend/src/components/settings/pages/developer/index.tsx
@@ -81,15 +81,19 @@ export default function DeveloperSettings() {
           description={<span style={{ whiteSpace: 'pre-line' }}>{t('SettingsDeveloperIndex.cef_console.desc')}</span>}
           icon={<FaTerminal style={{ display: 'block' }} />}
         >
-          <DialogButton onClick={async () => {
-            let res = await window.DeckyPluginLoader.callServerMethod('get_tab_id', { "name": "SharedJSContext" });
-            if (res.success) {
-              Navigation.NavigateToExternalWeb("localhost:8080/devtools/inspector.html?ws=localhost:8080/devtools/page/"+res.result);
-            } else {
-              console.error('Unable to find ID for SharedJSContext tab ', res.result);
-              Navigation.NavigateToExternalWeb("localhost:8080");
-            }
-          }}>
+          <DialogButton
+            onClick={async () => {
+              let res = await window.DeckyPluginLoader.callServerMethod('get_tab_id', { name: 'SharedJSContext' });
+              if (res.success) {
+                Navigation.NavigateToExternalWeb(
+                  'localhost:8080/devtools/inspector.html?ws=localhost:8080/devtools/page/' + res.result,
+                );
+              } else {
+                console.error('Unable to find ID for SharedJSContext tab ', res.result);
+                Navigation.NavigateToExternalWeb('localhost:8080');
+              }
+            }}
+          >
             {t('SettingsDeveloperIndex.cef_console.button')}
           </DialogButton>
         </Field>
-- 
cgit v1.2.3

