From e7788c1b17f258d238fbd0c97260072c8d292550 Mon Sep 17 00:00:00 2001 From: hensm Date: Tue, 9 Aug 2022 18:31:08 +0100 Subject: [PATCH] Hide advanced options by default and add toggle checkbox --- ext/src/_locales/en/messages.json | 4 + ext/src/defaultOptions.ts | 4 +- ext/src/ui/options/Options.svelte | 299 ++++++++++++++++------------ ext/src/ui/options/Whitelist.svelte | 2 +- ext/src/ui/options/styles/index.css | 20 +- 5 files changed, 186 insertions(+), 143 deletions(-) diff --git a/ext/src/_locales/en/messages.json b/ext/src/_locales/en/messages.json index 2418ef4..ed4a99d 100755 --- a/ext/src/_locales/en/messages.json +++ b/ext/src/_locales/en/messages.json @@ -415,5 +415,9 @@ "optionsSaved": { "message": "Saved!", "description": "Status text displayed by save button once options have been successfully saved." + }, + "optionsShowAdvancedOptions": { + "message": "Show advanced options", + "description": "Show advanced options checkbox label." } } diff --git a/ext/src/defaultOptions.ts b/ext/src/defaultOptions.ts index 8eb2fbe..2759693 100644 --- a/ext/src/defaultOptions.ts +++ b/ext/src/defaultOptions.ts @@ -19,6 +19,7 @@ export interface Options { siteWhitelistEnabled: boolean; siteWhitelist: WhitelistItemData[]; siteWhitelistCustomUserAgent: string; + showAdvancedOptions: boolean; [key: string]: Options[keyof Options]; } @@ -39,5 +40,6 @@ export default { receiverSelectorWaitForConnection: true, siteWhitelistEnabled: true, siteWhitelist: [{ pattern: "https://www.netflix.com/*" }], - siteWhitelistCustomUserAgent: "" + siteWhitelistCustomUserAgent: "", + showAdvancedOptions: false } as Options; diff --git a/ext/src/ui/options/Options.svelte b/ext/src/ui/options/Options.svelte index 4ece5f4..874f82c 100644 --- a/ext/src/ui/options/Options.svelte +++ b/ext/src/ui/options/Options.svelte @@ -68,13 +68,19 @@ } function resetForm() { - opts = JSON.parse(JSON.stringify(defaultOptions)); + if (!opts) return; + + opts = { + ...JSON.parse(JSON.stringify(defaultOptions)), + // Retain advanced options shown state + showAdvancedOptions: opts.showAdvancedOptions + }; } {#if opts}
-
-
- + {#if opts.showAdvancedOptions} +
+
+ +
+ +
+ {_("optionsMediaSyncElementDescription")} +
- -
- {_("optionsMediaSyncElementDescription")} -
-
+ {/if}
@@ -166,88 +174,93 @@
-
- -

{_("optionsMirroringCategoryName")}

-
-

- {_("optionsMirroringCategoryDescription")} -

+ {#if opts.showAdvancedOptions} +
+ +

{_("optionsMirroringCategoryName")}

+
+

+ {_("optionsMirroringCategoryDescription")} +

-
-
- +
+
+ +
+
- -
- -
- -
- -
- {_("optionsMirroringAppIdDescription")} +
+ +
+ +
+ {_("optionsMirroringAppIdDescription")} +
-
-
+
+ {/if} -
- -

{_("optionsReceiverSelectorCategoryName")}

-
-

- {_("optionsReceiverSelectorCategoryDescription")} -

+ {#if opts.showAdvancedOptions} +
+ +

{_("optionsReceiverSelectorCategoryName")}

+
+

+ {_("optionsReceiverSelectorCategoryDescription")} +

-
-
- +
+
+ +
+ +
+ {_( + "optionsReceiverSelectorWaitForConnectionDescription" + )} +
- -
- {_("optionsReceiverSelectorWaitForConnectionDescription")} -
-
-
-
- +
+
+ +
+
- -
-
+
+ {/if}
@@ -257,41 +270,48 @@ {_("optionsSiteWhitelistCategoryDescription")}

-
-
- -
- -
- {_("optionsSiteWhitelistEnabledDescription")} -
-
- -
- -
- + {#if opts.showAdvancedOptions} +
+
+ +
+
- {_("optionsSiteWhitelistCustomUserAgentDescription")} + {_("optionsSiteWhitelistEnabledDescription")}
-
+ +
+ +
+ +
+ {_( + "optionsSiteWhitelistCustomUserAgentDescription" + )} +
+
+
+ {/if}
@@ -307,19 +327,34 @@
-
- {#if isSavedIndicatorVisible} -
- {_("optionsSaved")} + {/if} diff --git a/ext/src/ui/options/Whitelist.svelte b/ext/src/ui/options/Whitelist.svelte index 88a8506..ba8e7cb 100644 --- a/ext/src/ui/options/Whitelist.svelte +++ b/ext/src/ui/options/Whitelist.svelte @@ -183,7 +183,7 @@ icon, remove - {#if !isEditingItem} + {#if !isEditingItem && opts.showAdvancedOptions}