From 493120b5456282756d05d9afaf66b11a2f87d8fc Mon Sep 17 00:00:00 2001 From: Alexander Tumin Date: Sat, 18 Mar 2023 20:48:36 +0300 Subject: Generalize IntegerSetting into NumberSetting, add Integer/Float wrappers --- .../settings_modal/helpers/number_setting.vue | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/components/settings_modal/helpers/number_setting.vue (limited to 'src/components/settings_modal/helpers/number_setting.vue') diff --git a/src/components/settings_modal/helpers/number_setting.vue b/src/components/settings_modal/helpers/number_setting.vue new file mode 100644 index 00000000..3eab5178 --- /dev/null +++ b/src/components/settings_modal/helpers/number_setting.vue @@ -0,0 +1,27 @@ + + + -- cgit v1.2.3-70-g09d2 From 0b5e536b4c96a81ec78f323be9bece6deae61773 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 20 Mar 2023 23:36:47 +0200 Subject: ChoiceSetting support added, added captcha settings --- .../settings_modal/admin_tabs/instance_tab.vue | 51 ++++++++++++++++++++++ .../settings_modal/helpers/choice_setting.js | 27 +++++++++++- .../settings_modal/helpers/choice_setting.vue | 18 ++++++-- .../settings_modal/helpers/number_setting.vue | 15 ++++++- src/components/settings_modal/helpers/setting.js | 7 ++- .../helpers/shared_computed_object.js | 3 ++ src/modules/adminSettings.js | 13 +++--- 7 files changed, 121 insertions(+), 13 deletions(-) (limited to 'src/components/settings_modal/helpers/number_setting.vue') diff --git a/src/components/settings_modal/admin_tabs/instance_tab.vue b/src/components/settings_modal/admin_tabs/instance_tab.vue index ad271293..ff784287 100644 --- a/src/components/settings_modal/admin_tabs/instance_tab.vue +++ b/src/components/settings_modal/admin_tabs/instance_tab.vue @@ -111,6 +111,57 @@ APPROVAL REQUIRED +
  • +

    {{ $t('admin_dash.captcha.header') }}

    +
  • +
  • + + CAPTCHA + +
      +
    • + + CAPTCHA TYPE + + + VALID + +
    • +
    +
      +

      {{ $t('admin_dash.kocaptcha') }}

      +
    • + + cockAPTCHA ENDPOINT + +
    • +
    +
  • diff --git a/src/components/settings_modal/helpers/choice_setting.js b/src/components/settings_modal/helpers/choice_setting.js index a3c3bf44..3ff81bc9 100644 --- a/src/components/settings_modal/helpers/choice_setting.js +++ b/src/components/settings_modal/helpers/choice_setting.js @@ -11,7 +11,32 @@ export default { ...Setting.props, options: { type: Array, - required: true + required: false + }, + optionLabelMap: { + type: Object, + required: false, + default: {} + } + }, + computed: { + ...Setting.computed, + realOptions () { + if (this.source === 'admin') { + console.log(this.backendDescriptionSuggestions) + return this.backendDescriptionSuggestions.map(x => ({ + key: x, + value: x, + label: this.optionLabelMap[x] || x + })) + } + return this.options + } + }, + methods: { + ...Setting.methods, + getValue (e) { + return e } } } diff --git a/src/components/settings_modal/helpers/choice_setting.vue b/src/components/settings_modal/helpers/choice_setting.vue index 4c4cdefe..55f9a62c 100644 --- a/src/components/settings_modal/helpers/choice_setting.vue +++ b/src/components/settings_modal/helpers/choice_setting.vue @@ -3,15 +3,20 @@ v-if="matchesExpertLevel" class="ChoiceSetting" > - + + {{ ' ' }} + + +

    + {{ backendDescriptionDescription + ' ' }} +

    diff --git a/src/components/settings_modal/helpers/setting.js b/src/components/settings_modal/helpers/setting.js index 8c7074a5..a6d35fb9 100644 --- a/src/components/settings_modal/helpers/setting.js +++ b/src/components/settings_modal/helpers/setting.js @@ -13,7 +13,7 @@ export default { }, props: { path: { - type: String, + type: [String, Array], required: true }, disabled: { @@ -21,7 +21,7 @@ export default { default: false }, parentPath: { - type: String + type: [String, Array] }, parentInvert: { type: Boolean, @@ -68,6 +68,9 @@ export default { backendDescriptionDescription () { return this.backendDescription?.description }, + backendDescriptionSuggestions () { + return this.backendDescription?.suggestions + }, shouldBeDisabled () { const parentValue = this.parentPath !== undefined ? get(this.configSource, this.parentPath) : null return this.disabled || (parentValue !== null ? (this.parentInvert ? parentValue : !parentValue) : false) diff --git a/src/components/settings_modal/helpers/shared_computed_object.js b/src/components/settings_modal/helpers/shared_computed_object.js index 912999ce..d02db542 100644 --- a/src/components/settings_modal/helpers/shared_computed_object.js +++ b/src/components/settings_modal/helpers/shared_computed_object.js @@ -7,6 +7,9 @@ const SharedComputedObject = () => ({ }, mergedConfig () { return this.$store.getters.mergedConfig + }, + adminConfig () { + return this.$store.state.adminSettings.config } }) diff --git a/src/modules/adminSettings.js b/src/modules/adminSettings.js index 44a4d409..a84fadbf 100644 --- a/src/modules/adminSettings.js +++ b/src/modules/adminSettings.js @@ -29,7 +29,7 @@ const adminSettingsStorage = { const config = state.config || {} const modifiedPaths = state.modifiedPaths || new Set() backendDbConfig.configs.forEach(c => { - const path = c.group + '.' + c.key + const path = [c.group, c.key] if (c.db) { c.db.forEach(x => modifiedPaths.add(path + '.' + x)) } @@ -44,16 +44,16 @@ const adminSettingsStorage = { } set(config, path, convert(c.value)) }) - console.log(config[':pleroma'][':welcome']) + console.log(config[':pleroma']) commit('updateAdminSettings', { config, modifiedPaths }) }, setInstanceAdminDescriptions ({ state, commit, dispatch }, { backendDescriptions }) { const convert = ({ children, description, label, key = '', group, suggestions }, path, acc) => { - const newPath = group ? group + '.' + key : key + const newPath = group ? [group, key] : [key] const obj = { description, label, suggestions } if (Array.isArray(children)) { children.forEach(c => { - convert(c, '.' + newPath, obj) + convert(c, newPath, obj) }) } set(acc, newPath, obj) @@ -61,12 +61,13 @@ const adminSettingsStorage = { const descriptions = {} backendDescriptions.forEach(d => convert(d, '', descriptions)) + console.log(descriptions[':pleroma']['Pleroma.Captcha']) commit('updateAdminDescriptions', { descriptions }) }, pushAdminSetting ({ rootState, state, commit, dispatch }, { path, value }) { - const [group, key, ...rest] = path.split(/\./g) + const [group, key, ...rest] = Array.isArray(path) ? path : path.split(/\./g) const clone = {} // not actually cloning the entire thing to avoid excessive writes - set(clone, rest.join('.'), value) + set(clone, rest, value) // TODO cleanup paths in modifiedPaths const convert = (value) => { -- cgit v1.2.3-70-g09d2 From 2bf224e214d9b42333a2139a89c089ca9a544149 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 21 Mar 2023 22:46:40 +0200 Subject: made draft-mode and source inject-able --- .../settings_modal/admin_tabs/instance_tab.js | 6 ++ .../settings_modal/admin_tabs/instance_tab.vue | 78 ++++------------------ .../settings_modal/helpers/choice_setting.js | 3 +- .../settings_modal/helpers/choice_setting.vue | 2 +- .../settings_modal/helpers/number_setting.vue | 2 +- src/components/settings_modal/helpers/setting.js | 41 ++++++++---- .../settings_modal/helpers/string_setting.vue | 2 +- 7 files changed, 50 insertions(+), 84 deletions(-) (limited to 'src/components/settings_modal/helpers/number_setting.vue') diff --git a/src/components/settings_modal/admin_tabs/instance_tab.js b/src/components/settings_modal/admin_tabs/instance_tab.js index 77a05d38..7aaedbce 100644 --- a/src/components/settings_modal/admin_tabs/instance_tab.js +++ b/src/components/settings_modal/admin_tabs/instance_tab.js @@ -14,6 +14,12 @@ library.add( ) const InstanceTab = { + provide () { + return { + defaultDraftMode: true, + defaultSource: 'admin' + } + }, components: { BooleanSetting, ChoiceSetting, diff --git a/src/components/settings_modal/admin_tabs/instance_tab.vue b/src/components/settings_modal/admin_tabs/instance_tab.vue index 411982cc..43ad4c8c 100644 --- a/src/components/settings_modal/admin_tabs/instance_tab.vue +++ b/src/components/settings_modal/admin_tabs/instance_tab.vue @@ -4,65 +4,37 @@

    {{ $t('admin_dash.instance.instance') }}

    • - + NAME
    • - + ADMIN EMAIL
    • - + DESCRIPTION
    • - + SHORT DESCRIPTION
    • - + INSTANCE THUMBNAIL
    • - + BACKGROUND IMAGE
    • - + PUBLIC
    • @@ -72,21 +44,15 @@

      {{ $t('admin_dash.instance.registrations') }}

      • - + REGISTRATIONS OPEN
        • INVITES ENABLED @@ -94,20 +60,12 @@
      • - + ACTIVATION REQUIRED
      • - + APPROVAL REQUIRED
      • @@ -115,32 +73,24 @@

        {{ $t('admin_dash.instance.captcha_header') }}

      • - + CAPTCHA
        • CAPTCHA TYPE VALID @@ -152,11 +102,7 @@ >

          {{ $t('admin_dash.instance.kocaptcha') }}

        • - + cockAPTCHA ENDPOINT
        • diff --git a/src/components/settings_modal/helpers/choice_setting.js b/src/components/settings_modal/helpers/choice_setting.js index 3ff81bc9..bdeece76 100644 --- a/src/components/settings_modal/helpers/choice_setting.js +++ b/src/components/settings_modal/helpers/choice_setting.js @@ -22,8 +22,7 @@ export default { computed: { ...Setting.computed, realOptions () { - if (this.source === 'admin') { - console.log(this.backendDescriptionSuggestions) + if (this.realSource === 'admin') { return this.backendDescriptionSuggestions.map(x => ({ key: x, value: x, diff --git a/src/components/settings_modal/helpers/choice_setting.vue b/src/components/settings_modal/helpers/choice_setting.vue index 55f9a62c..8713acf5 100644 --- a/src/components/settings_modal/helpers/choice_setting.vue +++ b/src/components/settings_modal/helpers/choice_setting.vue @@ -11,7 +11,7 @@ {{ ' ' }}