diff --git a/src/components/settings_modal/admin_tabs/http_tab.js b/src/components/settings_modal/admin_tabs/http_tab.js new file mode 100644 index 000000000..82e2bb010 --- /dev/null +++ b/src/components/settings_modal/admin_tabs/http_tab.js @@ -0,0 +1,46 @@ +import BooleanSetting from '../helpers/boolean_setting.vue' +import ChoiceSetting from '../helpers/choice_setting.vue' +import IntegerSetting from '../helpers/integer_setting.vue' +import StringSetting from '../helpers/string_setting.vue' +import GroupSetting from '../helpers/group_setting.vue' +import AttachmentSetting from '../helpers/attachment_setting.vue' +import ListSetting from '../helpers/list_setting.vue' +import TupleSetting from '../helpers/tuple_setting.vue' +import MapSetting from '../helpers/map_setting.vue' +import ProxySetting from '../helpers/proxy_setting.vue' + +import SharedComputedObject from '../helpers/shared_computed_object.js' +import { get } from 'lodash' + +const HTTPTab = { + provide () { + return { + defaultDraftMode: true, + defaultSource: 'admin' + } + }, + components: { + BooleanSetting, + ChoiceSetting, + IntegerSetting, + StringSetting, + AttachmentSetting, + MapSetting, + GroupSetting, + ListSetting, + TupleSetting, + ProxySetting + }, + computed: { + ...SharedComputedObject(), + sslOptions () { + const desc = get(this.$store.state.adminSettings.descriptions, ':pleroma.:http.:adapter.:ssl_options.:versions') + return new Set(desc.suggestions.map(option => ({ + label: option.replace(':tlsv', 'TLS v'), + value: option + }))) + }, + } +} + +export default HTTPTab diff --git a/src/components/settings_modal/admin_tabs/http_tab.vue b/src/components/settings_modal/admin_tabs/http_tab.vue new file mode 100644 index 000000000..7a2e7b60a --- /dev/null +++ b/src/components/settings_modal/admin_tabs/http_tab.vue @@ -0,0 +1,126 @@ + + + + {{ $t('admin_dash.http.outbound') }} + + + + + + + + + + + + + + + + + + + + {{ $t('admin_dash.http.incoming') }} + + {{ $t('admin_dash.http.cors') }} + + + + + + + + + + + + + + + + {{ $t('admin_dash.http.security') }} + + + + + + + + + + + + + + + + + + + + + + {{ $t('admin_dash.http.web_cache_ttl') }} + {{ $t('admin_dash.http.web_cache_ttl_description') }} + + + + + + + + {{ $t('admin_dash.http.web_push') }} + {{ $t('admin_dash.http.web_push_description') }} + + + + + + + + + + + + + + + + + + + + + diff --git a/src/components/settings_modal/helpers/proxy_setting.js b/src/components/settings_modal/helpers/proxy_setting.js new file mode 100644 index 000000000..ca717b60b --- /dev/null +++ b/src/components/settings_modal/helpers/proxy_setting.js @@ -0,0 +1,53 @@ +import Checkbox from 'src/components/checkbox/checkbox.vue' +import Setting from './setting.js' + +const getUrl = state => state?.tuple ? state.tuple[1] + ':' + state.tuple[2] : state +const getSocks = state => state?.tuple + +export default { + ...Setting, + data () { + return { + urlField: '', + socksField: false + } + }, + created () { + Setting.created() + this.urlField = getUrl(this.realDraftMode ? this.draft : this.state) + this.socksField = getSocks(this.realDraftMode ? this.draft : this.state) + }, + computed: { + ...Setting.computed, + // state that we'll show in the UI, i.e. transforming map into list + displayState () { + if (this.visibleState?.tuple) { + return this.visibleState.tuple[1] + ':' + this.visibleState.tuple[2] + } + return this.visibleState + }, + socksState () { + return getSocks(this.visibleState) + } + }, + components: { + ...Setting.components, + Checkbox + }, + methods: { + ...Setting.methods, + getValue ({ event, isProxy}) { + if (isProxy) { + this.socksField = event + } else { + this.urlField = event.target.value + } + + if (this.socksField) { + return { tuple: [ ':socks5', ...this.urlField.split(':') ] } + } else { + return this.urlField + } + } + } +} diff --git a/src/components/settings_modal/helpers/proxy_setting.vue b/src/components/settings_modal/helpers/proxy_setting.vue new file mode 100644 index 000000000..ac4884696 --- /dev/null +++ b/src/components/settings_modal/helpers/proxy_setting.vue @@ -0,0 +1,57 @@ + + + + + {{ backendDescriptionLabel + ' ' }} + + + MISSING LABEL FOR {{ path }} + + + + {{ ' ' }} + update({ event })" + > + {{ ' ' }} + update({ event, isProxy: true})" + > + {{ $t('admin_dash.http.socks5') }} + {{ ' ' }} + + {{ ' ' }} + + + + + {{ backendDescriptionDescription + ' ' }} + + + + + diff --git a/src/components/settings_modal/helpers/setting.js b/src/components/settings_modal/helpers/setting.js index 031e66dc0..d5ea3f21c 100644 --- a/src/components/settings_modal/helpers/setting.js +++ b/src/components/settings_modal/helpers/setting.js @@ -18,6 +18,10 @@ export default { type: [String, Array], required: false }, + descriptionPathOverride: { + type: [String, Array], + required: false + }, suggestions: { type: [String, Array], required: false @@ -236,7 +240,9 @@ export default { }, descriptionPath () { if (this.path == null) return null + if (this.descriptionPathOverride) return this.descriptionPathOverride const path = Array.isArray(this.path) ? this.path : this.path.split('.') + console.log(this.path, this.subgroup) if (this.subgroup) { return [ ...path.slice(0, path.length - 1), diff --git a/src/i18n/en.json b/src/i18n/en.json index 18894a475..968b2b609 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -1213,6 +1213,16 @@ "native": "Native", "kocaptcha": "KoCaptcha" }, + "http": { + "outbound": "Outgoing connections", + "incoming": "Incoming connections", + "security": "HTTP Security", + "cors": "Cross-origin Resource Sharing (CORS)", + "web_cache_ttl": "Web Cache TTL", + "web_cache_ttl_description": "Amount of milliseconds until web response cache is cleared. Use `nil` to disable expiration entirely.", + "web_push": "Web Push", + "web_push_description": "Web Push VAPID settings. You can use the mix task web_push.gen.keypair to generate it." + }, "instance": { "instance": "Instance information", "registrations": "User sign-ups", @@ -1249,6 +1259,7 @@ "uploads": { "attachments": "Attachments settings", "upload": "Upload", + "local_uploader": "Local files", "filenames": "Filenames, Titles and Descriptions", "uploader_settings": "Uploader settings" }, @@ -1427,6 +1438,16 @@ "label": "Background image", "description": "Background image (primarily used by PleromaFE)" } + }, + ":http_security": { + ":allow_unsafe_eval": { + "label": "Allow unsafe-eval", + "description": "Allow unsafe evaluation of scripts (required for Flash support)" + }, + ":report_url": { + "label": "Report URL", + "description": "URL to report security violations to" + } } } } diff --git a/src/modules/adminSettings.js b/src/modules/adminSettings.js index 1ea01eeb6..bbe4beba6 100644 --- a/src/modules/adminSettings.js +++ b/src/modules/adminSettings.js @@ -131,6 +131,7 @@ const adminSettingsStorage = { } const descriptions = {} + backendDescriptions.forEach(d => convert(d, '', descriptions)) console.log('DESCRIPTIONS', descriptions) commit('updateAdminDescriptions', { descriptions })
{{ $t('admin_dash.http.web_cache_ttl_description') }}
{{ $t('admin_dash.http.web_push_description') }}
+ {{ backendDescriptionDescription + ' ' }} +