diff --git a/src/public/app/widgets/type_widgets/content_widget.ts b/src/public/app/widgets/type_widgets/content_widget.ts index d2ea5a971..e7a0533ff 100644 --- a/src/public/app/widgets/type_widgets/content_widget.ts +++ b/src/public/app/widgets/type_widgets/content_widget.ts @@ -35,7 +35,7 @@ import RibbonOptions from "./options/appearance/ribbon.js"; import LocalizationOptions from "./options/appearance/i18n.js"; import CodeBlockOptions from "./options/appearance/code_block.js"; import EditorOptions from "./options/text_notes/editor.js"; -import ShareSettingsOptions from "./options/other/share_settings.js"; // added import statement +import ShareSettingsOptions from "./options/other/share_settings.js"; import type FNote from "../../entities/fnote.js"; import type NoteContextAwareWidget from "../note_context_aware_widget.js"; diff --git a/src/public/app/widgets/type_widgets/options/other/share_settings.ts b/src/public/app/widgets/type_widgets/options/other/share_settings.ts new file mode 100644 index 000000000..d90840948 --- /dev/null +++ b/src/public/app/widgets/type_widgets/options/other/share_settings.ts @@ -0,0 +1,47 @@ +import OptionsWidget from "../options_widget.js"; +import options from "../../../../services/options.js"; +import { t } from "../../../../services/i18n.js"; + +const TPL = ` +
+

${t('Share Settings')}

+ +
+ +

${t('When enabled, accessing the root URL will redirect to the Share page instead of Login')}

+
+ +
+ +

${t('Add a login link to the Share page footer')}

+
+
`; + +export default class ShareSettingsOptions extends OptionsWidget { + doRender() { + this.$widget = $(TPL); + this.contentSized(); + } + + async optionsLoaded(options: Record) { + this.$widget.find('input[name="redirectBareDomain"]').prop('checked', + options.redirectBareDomain === 'true'); + + this.$widget.find('input[name="showLoginInShareTheme"]').prop('checked', + options.showLoginInShareTheme === 'true'); + } + + async save() { + const redirectBareDomain = this.$widget.find('input[name="redirectBareDomain"]').prop('checked'); + await this.updateOption('redirectBareDomain', redirectBareDomain.toString()); + + const showLoginInShareTheme = this.$widget.find('input[name="showLoginInShareTheme"]').prop('checked'); + await this.updateOption('showLoginInShareTheme', showLoginInShareTheme.toString()); + } +} diff --git a/src/services/options_interface.ts b/src/services/options_interface.ts index f3a92383b..ef55af6c5 100644 --- a/src/services/options_interface.ts +++ b/src/services/options_interface.ts @@ -29,6 +29,9 @@ export interface OptionDefinitions extends KeyboardShortcutsOptions