Merge branch 'feature/media-preview-proxy' into 'master'

Ability to configure Media Preview Proxy settings

See merge request pleroma/admin-fe!183
This commit is contained in:
feld 2020-11-18 20:37:59 +00:00
commit c18f167a12
8 changed files with 73 additions and 11 deletions

View file

@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [2.2] - 2020-11-18
### Added
- Ability to configure Media Preview Proxy settings on MediaProxy tab
### Fixed
- Update keys for PurgeExpiredActivity and RemoteIp settings
- Fix wrapping `:icons` setting and parsing tuples in settings with key `:headers`
## [2.1] - 2020-08-26 ## [2.1] - 2020-08-26
### Added ### Added

View file

@ -66,7 +66,11 @@ export const parseTuples = (tuples, key) => {
return [...acc, { [mascot.tuple[0]]: { ...mascot.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}] return [...acc, { [mascot.tuple[0]]: { ...mascot.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}]
}, []) }, [])
} else if (Array.isArray(item.tuple[1]) && } else if (Array.isArray(item.tuple[1]) &&
(item.tuple[0] === ':groups' || item.tuple[0] === ':replace' || item.tuple[0] === ':retries' || item.tuple[0] === ':headers' || item.tuple[0] === ':crontab')) { (item.tuple[0] === ':groups' ||
item.tuple[0] === ':replace' ||
item.tuple[0] === ':retries' ||
(item.tuple[0] === ':headers' && key === 'Pleroma.Web.MediaProxy.Invalidation.Http') ||
item.tuple[0] === ':crontab')) {
if (item.tuple[0] === ':crontab') { if (item.tuple[0] === ':crontab') {
accum[item.tuple[0]] = item.tuple[1].reduce((acc, group) => { accum[item.tuple[0]] = item.tuple[1].reduce((acc, group) => {
return [...acc, { [group.tuple[1]]: { value: group.tuple[0], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}] return [...acc, { [group.tuple[1]]: { value: group.tuple[0], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}]
@ -245,7 +249,7 @@ const wrapValues = (settings, currentState) => {
return acc return acc
}, {}) }, {})
return { 'tuple': [setting, { ...currentState[setting], ...mapValue }] } return { 'tuple': [setting, { ...currentState[setting], ...mapValue }] }
} else if (type.includes('map')) { } else if (type.includes('map') && !type.includes('list')) {
const mapValue = Object.keys(value).reduce((acc, key) => { const mapValue = Object.keys(value).reduce((acc, key) => {
acc[key] = value[key][1] acc[key] = value[key][1]
return acc return acc

View file

@ -42,7 +42,8 @@
@change="update($event, settingGroup.group, settingGroup.key, settingParent, setting.key, setting.type, nested)" @change="update($event, settingGroup.group, settingGroup.key, settingParent, setting.key, setting.type, nested)"
/> />
<el-input <el-input
v-else-if="setting.type === 'string' || (setting.type.includes('string') && setting.type.includes('atom'))" v-else-if="setting.type === 'string' ||
(Array.isArray(setting.type) && setting.type.includes('string') && setting.type.includes('atom'))"
:value="inputValue" :value="inputValue"
:placeholder="setting.suggestions ? setting.suggestions[0] : null" :placeholder="setting.suggestions ? setting.suggestions[0] : null"
:data-search="setting.key || setting.group" :data-search="setting.key || setting.group"
@ -358,7 +359,10 @@ export default {
) )
}, },
renderSingleSelect(type) { renderSingleSelect(type) {
return !this.reducedSelects && (type === 'module' || (type.includes('atom') && type.includes('dropdown'))) return !this.reducedSelects && (
type === 'module' ||
(Array.isArray(type) && type.includes('atom') && type.includes('dropdown'))
)
}, },
senderInput({ key, type }) { senderInput({ key, type }) {
return Array.isArray(type) && type.includes('string') && type.includes('tuple') && key === ':sender' return Array.isArray(type) && type.includes('string') && type.includes('tuple') && key === ':sender'

View file

@ -43,10 +43,10 @@ export default {
'settings' 'settings'
]), ]),
activityExpiration() { activityExpiration() {
return this.settings.description.find(setting => setting.key === 'Pleroma.ActivityExpiration') return this.settings.description.find(setting => setting.key === 'Pleroma.Workers.PurgeExpiredActivity')
}, },
activityExpirationData() { activityExpirationData() {
return _.get(this.settings.settings, [':pleroma', 'Pleroma.ActivityExpiration']) || {} return _.get(this.settings.settings, [':pleroma', 'Pleroma.Workers.PurgeExpiredActivity']) || {}
}, },
connectionsPools() { connectionsPools() {
return this.settings.description.find(setting => setting.key === ':connections_pool') return this.settings.description.find(setting => setting.key === ':connections_pool')

View file

@ -4,6 +4,10 @@
<setting :setting-group="mediaProxy" :data="mediaProxyData"/> <setting :setting-group="mediaProxy" :data="mediaProxyData"/>
</el-form> </el-form>
<el-divider v-if="mediaProxy" class="divider thick-line"/> <el-divider v-if="mediaProxy" class="divider thick-line"/>
<el-form v-if="!loading" :model="mediaPreviewProxyData" :label-position="labelPosition" :label-width="labelWidth">
<setting :setting-group="mediaPreviewProxy" :data="mediaPreviewProxyData"/>
</el-form>
<el-divider v-if="mediaPreviewProxy" class="divider thick-line"/>
<el-form v-if="!loading" :model="httpInvalidationData" :label-position="labelPosition" :label-width="labelWidth"> <el-form v-if="!loading" :model="httpInvalidationData" :label-position="labelPosition" :label-width="labelWidth">
<setting :setting-group="httpInvalidation" :data="httpInvalidationData"/> <setting :setting-group="httpInvalidation" :data="httpInvalidationData"/>
</el-form> </el-form>
@ -60,6 +64,12 @@ export default {
loading() { loading() {
return this.settings.loading return this.settings.loading
}, },
mediaPreviewProxy() {
return this.settings.description.find(setting => setting.key === ':media_preview_proxy')
},
mediaPreviewProxyData() {
return _.get(this.settings.settings, [':pleroma', ':media_preview_proxy']) || {}
},
mediaProxy() { mediaProxy() {
return this.settings.description.find(setting => setting.key === ':media_proxy') return this.settings.description.find(setting => setting.key === ':media_proxy')
}, },

View file

@ -77,10 +77,10 @@ export default {
return _.get(this.settings.settings, [':pleroma', ':modules']) || {} return _.get(this.settings.settings, [':pleroma', ':modules']) || {}
}, },
remoteIp() { remoteIp() {
return this.settings.description.find(setting => setting.key === 'Pleroma.Plugs.RemoteIp') return this.settings.description.find(setting => setting.key === 'Pleroma.Web.Plugs.RemoteIp')
}, },
remoteIpData() { remoteIpData() {
return _.get(this.settings.settings, [':pleroma', 'Pleroma.Plugs.RemoteIp']) || {} return _.get(this.settings.settings, [':pleroma', 'Pleroma.Web.Plugs.RemoteIp']) || {}
} }
}, },
methods: { methods: {

View file

@ -34,7 +34,7 @@ export const tabs = description => {
}, },
'job-queue': { 'job-queue': {
label: 'settings.jobQueue', label: 'settings.jobQueue',
settings: ['Pleroma.ActivityExpiration', ':connections_pool', ':hackney_pools', 'Oban', ':pools', ':workers'] settings: ['Pleroma.Workers.PurgeExpiredActivity', ':connections_pool', ':hackney_pools', 'Oban', ':pools', ':workers']
}, },
'link-formatter': { 'link-formatter': {
label: 'settings.linkFormatter', label: 'settings.linkFormatter',
@ -50,7 +50,7 @@ export const tabs = description => {
}, },
'media-proxy': { 'media-proxy': {
label: 'settings.mediaProxy', label: 'settings.mediaProxy',
settings: [':media_proxy', 'Pleroma.Web.MediaProxy.Invalidation.Http', 'Pleroma.Web.MediaProxy.Invalidation.Script'] settings: [':media_proxy', ':media_preview_proxy', 'Pleroma.Web.MediaProxy.Invalidation.Http', 'Pleroma.Web.MediaProxy.Invalidation.Script']
}, },
'metadata': { 'metadata': {
label: 'settings.metadata', label: 'settings.metadata',
@ -78,7 +78,7 @@ export const tabs = description => {
}, },
'other': { 'other': {
label: 'settings.other', label: 'settings.other',
settings: [':mime', 'Pleroma.Plugs.RemoteIp', ':modules', 'Pleroma.Web.ApiSpec.CastAndValidate'] settings: [':mime', 'Pleroma.Web.Plugs.RemoteIp', ':modules', 'Pleroma.Web.ApiSpec.CastAndValidate']
} }
} }
} }

View file

@ -340,6 +340,39 @@ describe('Wrap settings', () => {
expect(_.isEqual(result1, expectedResult1)).toBeTruthy() expect(_.isEqual(result1, expectedResult1)).toBeTruthy()
expect(_.isEqual(result2, expectedResult2)).toBeTruthy() expect(_.isEqual(result2, expectedResult2)).toBeTruthy()
}) })
it('wraps settings with type [`list`, `map`]', () => {
const settings = { ':manifest': { ':icons': [['map', 'list'], [
{ ':src': '/static/logo.png', ':type': 'image/png' },
{ ':src': '/static/icon.png', ':type': 'image/png' }
]]}}
const state = { ':pleroma': { ':manifest': {
':background_color': '#191b22',
':theme_color': '#282c37',
':icons': [
[
{ 'id': 'f21318c4', 'key': ':src', 'value': '/static/logo.png' },
{ 'id': 'f4b87549', 'key': ':type', 'value': 'image/png' }
], [
{ 'id': 'f31d351e', 'key': ':src', 'value': '/static/icon.png' },
{ 'id': 'f1455852', 'key': ':type', 'value': 'image/png' }
]
]
}}}
const result = wrapUpdatedSettings(':pleroma', settings, state)
const expectedResult = [{
group: ':pleroma',
key: ':manifest',
value: [{ tuple: [':icons', [
{ ':src': '/static/logo.png', ':type': 'image/png' },
{ ':src': '/static/icon.png', ':type': 'image/png' }
]]}]
}]
expect(_.isEqual(result, expectedResult)).toBeTruthy()
})
it('wraps IP setting', () => { it('wraps IP setting', () => {
const settings = { ':gopher': { ':ip': ['tuple', '127.0.0.1']}} const settings = { ':gopher': { ':ip': ['tuple', '127.0.0.1']}}