From 2881730f3354a9a7d8a525f2c53aa02c7e8085a5 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 3 Jul 2020 02:30:15 +0300 Subject: [PATCH 01/28] Create route for MediaProxy Cache --- src/lang/en.js | 3 +++ src/router/index.js | 25 ++++++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/lang/en.js b/src/lang/en.js index 35d91252..834c3cee 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -65,8 +65,11 @@ export default { externalLink: 'External Link', users: 'Users', reports: 'Reports', + invites: 'Invites', + statuses: 'Statuses', settings: 'Settings', moderationLog: 'Moderation Log', + mediaProxyCache: 'MediaProxy Cache', 'emoji-packs': 'Emoji packs' }, navbar: { diff --git a/src/router/index.js b/src/router/index.js index 40d4d7cd..b61e7b44 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -16,7 +16,7 @@ const settings = { path: 'index', component: () => import('@/views/settings/index'), name: 'Settings', - meta: { title: 'Settings', icon: 'settings', noCache: true } + meta: { title: 'settings', icon: 'settings', noCache: true } } ] } @@ -30,7 +30,7 @@ const statuses = { path: 'index', component: () => import('@/views/statuses/index'), name: 'Statuses', - meta: { title: 'Statuses', icon: 'form', noCache: true } + meta: { title: 'statuses', icon: 'form', noCache: true } } ] } @@ -44,7 +44,7 @@ const reports = { path: 'index', component: () => import('@/views/reports/index'), name: 'Reports', - meta: { title: 'Reports', icon: 'documentation', noCache: true } + meta: { title: 'reports', icon: 'documentation', noCache: true } } ] } @@ -58,7 +58,7 @@ const invites = { path: 'index', component: () => import('@/views/invites/index'), name: 'Invites', - meta: { title: 'Invites', icon: 'guide', noCache: true } + meta: { title: 'invites', icon: 'guide', noCache: true } } ] } @@ -72,7 +72,7 @@ const emojiPacks = { path: 'index', component: () => import('@/views/emojiPacks/index'), name: 'Emoji Packs', - meta: { title: 'Emoji Packs', icon: 'eye-open', noCache: true } + meta: { title: 'emoji-packs', icon: 'eye-open', noCache: true } } ] } @@ -91,6 +91,20 @@ const moderationLog = { ] } +const mediaProxyCacheDisabled = disabledFeatures.includes('media-proxy-cache') +const mediaProxyCache = { + path: '/media_proxy_cache', + component: Layout, + children: [ + { + path: 'index', + component: () => import('@/views/mediaProxyCache/index'), + name: 'MediaProxy Cache', + meta: { title: 'mediaProxyCache', icon: 'example', noCache: true } + } + ] +} + export const constantRouterMap = [ { path: '/redirect', @@ -159,6 +173,7 @@ export const asyncRouterMap = [ ...(invitesDisabled ? [] : [invites]), ...(emojiPacksDisabled ? [] : [emojiPacks]), ...(moderationLogDisabled ? [] : [moderationLog]), + ...(mediaProxyCacheDisabled ? [] : [mediaProxyCache]), ...(settingsDisabled ? [] : [settings]), { path: '/users/:id', From 0aff86e6384d8e70dbdb26d441aae701ed5fd988 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 3 Jul 2020 03:04:17 +0300 Subject: [PATCH 02/28] Create API functions for MediaProxy Cache --- src/api/mediaProxyCache.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/api/mediaProxyCache.js diff --git a/src/api/mediaProxyCache.js b/src/api/mediaProxyCache.js new file mode 100644 index 00000000..0822d984 --- /dev/null +++ b/src/api/mediaProxyCache.js @@ -0,0 +1,34 @@ +import request from '@/utils/request' +import { getToken } from '@/utils/auth' +import { baseName } from './utils' + +export async function listBannedUrls(page, authHost, token) { + return await request({ + baseURL: baseName(authHost), + url: `/api/pleroma/admin/media_proxy_caches?page=${page}`, + method: 'get', + headers: authHeaders(token) + }) +} + +export async function purgeUrls(urls, ban, authHost, token) { + return await request({ + baseURL: baseName(authHost), + url: `/api/pleroma/admin/media_proxy_caches/purge`, + method: 'post', + headers: authHeaders(token), + data: { urls, ban } + }) +} + +export async function removeBannedUrls(urls, authHost, token) { + return await request({ + baseURL: baseName(authHost), + url: `/api/pleroma/admin/media_proxy_caches/delete`, + method: 'post', + headers: authHeaders(token), + data: { urls } + }) +} + +const authHeaders = (token) => token ? { 'Authorization': `Bearer ${getToken()}` } : {} From 9d2a86556cb7e9a493f682de5cd2442c8ffc53e8 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Sun, 5 Jul 2020 02:33:46 +0300 Subject: [PATCH 03/28] Add input for evicting and banning urls --- src/lang/en.js | 7 +++ src/views/mediaProxyCache/index.vue | 72 +++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 src/views/mediaProxyCache/index.vue diff --git a/src/lang/en.js b/src/lang/en.js index 834c3cee..92caee07 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -92,6 +92,13 @@ export default { pleromaFELoginFailed: 'Failed to login via PleromaFE, please login with username/password', pleromaFELoginSucceed: 'Logged in via PleromaFE' }, + mediaProxyCache: { + mediaProxyCache: 'MediaProxy Cache', + ban: 'Ban', + url: 'URL', + evict: 'Evict', + evictedMessage: 'This URL was evicted' + }, documentation: { documentation: 'Documentation', github: 'Github Repository' diff --git a/src/views/mediaProxyCache/index.vue b/src/views/mediaProxyCache/index.vue new file mode 100644 index 00000000..e0bfb5d0 --- /dev/null +++ b/src/views/mediaProxyCache/index.vue @@ -0,0 +1,72 @@ + + + + + From 764621d6fd6739e66d222c964d178313f7016415 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Sun, 5 Jul 2020 02:34:40 +0300 Subject: [PATCH 04/28] Create actions for listing banned urls, purge and remove banned urls form cachex --- src/store/index.js | 4 ++- src/store/modules/mediaProxyCache.js | 49 ++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/store/modules/mediaProxyCache.js diff --git a/src/store/index.js b/src/store/index.js index e2fcd651..bd4a6e5b 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -5,6 +5,7 @@ import emojiPacks from './modules/emojiPacks' import errorLog from './modules/errorLog' import getters from './getters' import invites from './modules/invites' +import mediaProxyCache from './modules/mediaProxyCache' import moderationLog from './modules/moderationLog' import peers from './modules/peers' import permission from './modules/permission' @@ -24,8 +25,9 @@ const store = new Vuex.Store({ app, errorLog, emojiPacks, - moderationLog, invites, + mediaProxyCache, + moderationLog, peers, permission, relays, diff --git a/src/store/modules/mediaProxyCache.js b/src/store/modules/mediaProxyCache.js new file mode 100644 index 00000000..5990c8e8 --- /dev/null +++ b/src/store/modules/mediaProxyCache.js @@ -0,0 +1,49 @@ +import { listBannedUrls, purgeUrls, removeBannedUrls } from '@/api/mediaProxyCache' +import { Message } from 'element-ui' +import i18n from '@/lang' + +const mediaProxyCache = { + state: { + bannedUrls: [], + bannedUrlsCount: 0, + currentPage: 1, + loading: false + }, + mutations: { + SET_BANNED_URLS: (state, urls) => { + state.bannedUrls = urls + }, + SET_BANNED_URLS_COUNT: (state, count) => { + state.bannedUrlsCount = count + }, + SET_LOADING: (state, status) => { + state.loading = status + }, + SET_PAGE: (state, page) => { + state.currentPage = page + } + }, + actions: { + async ListBannedUrls({ commit, getters }, page) { + commit('SET_LOADING', true) + const response = await listBannedUrls(page, getters.authHost, getters.token) + commit('SET_BANNED_URLS', response.data.urls) + // commit('SET_BANNED_URLS_COUNT', count) + commit('SET_PAGE', page) + commit('SET_LOADING', false) + }, + async PurgeUrls({ commit, getters }, { urls, ban }) { + await purgeUrls(urls, ban, getters.authHost, getters.token) + Message({ + message: i18n.t('mediaProxyCache.evictedMessage'), + type: 'success', + duration: 5 * 1000 + }) + }, + async RemoveBannedUrls({ commit, getters }, urls) { + await removeBannedUrls(urls, getters.authHost, getters.token) + } + } +} + +export default mediaProxyCache From 991c17f88e1984ee5d3ede23cc5bc7b7f129b64e Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Sun, 5 Jul 2020 23:18:13 +0300 Subject: [PATCH 05/28] Add table with banned URLs and ability to remove url from cachex --- src/lang/en.js | 4 ++- src/store/modules/mediaProxyCache.js | 2 +- src/views/mediaProxyCache/index.vue | 46 +++++++++++++++++++++++++++- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/src/lang/en.js b/src/lang/en.js index 92caee07..f2b60b86 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -97,7 +97,9 @@ export default { ban: 'Ban', url: 'URL', evict: 'Evict', - evictedMessage: 'This URL was evicted' + evictedMessage: 'This URL was evicted', + actions: 'Actions', + remove: 'Remove from Cachex' }, documentation: { documentation: 'Documentation', diff --git a/src/store/modules/mediaProxyCache.js b/src/store/modules/mediaProxyCache.js index 5990c8e8..c148dbdf 100644 --- a/src/store/modules/mediaProxyCache.js +++ b/src/store/modules/mediaProxyCache.js @@ -11,7 +11,7 @@ const mediaProxyCache = { }, mutations: { SET_BANNED_URLS: (state, urls) => { - state.bannedUrls = urls + state.bannedUrls = urls.map(el => { return { url: el } }) }, SET_BANNED_URLS_COUNT: (state, count) => { state.bannedUrlsCount = count diff --git a/src/views/mediaProxyCache/index.vue b/src/views/mediaProxyCache/index.vue index e0bfb5d0..f13dfb7d 100644 --- a/src/views/mediaProxyCache/index.vue +++ b/src/views/mediaProxyCache/index.vue @@ -13,6 +13,28 @@ {{ $t('mediaProxyCache.ban') }} {{ $t('mediaProxyCache.evict') }} + > + + + + + + @@ -25,7 +47,19 @@ export default { data() { return { url: '', - ban: false + ban: false, + selectedUrls: [] + } + }, + computed: { + bannedUrls() { + return this.$store.state.mediaProxyCache.bannedUrls + }, + isDesktop() { + return this.$store.state.app.device === 'desktop' + }, + loading() { + return this.$store.state.mediaProxyCache.loading } }, mounted() { @@ -37,6 +71,13 @@ export default { evictURL() { const urls = typeof this.url === 'string' ? [this.url] : this.url this.$store.dispatch('PurgeUrls', { urls, ban: this.ban }) + }, + handleSelectionChange(value) { + this.$data.selectedUrls = value + }, + removeUrl(url) { + const urls = typeof this.url === 'string' ? [this.url] : this.url + this.$store.dispatch('RemoveBannedUrls', urls) } } } @@ -46,6 +87,9 @@ export default { h1 { margin: 0; } +.banned-urls-table { + margin: 15px; +} .evict-button { margin-left: 5px; } From cea1485ddc92f8317f3c61ecd428b12b2690344f Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Mon, 6 Jul 2020 00:28:09 +0300 Subject: [PATCH 06/28] Add Invalidation settings on MediaProxy tab --- src/views/settings/components/Inputs.vue | 2 +- src/views/settings/components/MediaProxy.vue | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue index 0b14e282..0578ae2f 100644 --- a/src/views/settings/components/Inputs.vue +++ b/src/views/settings/components/Inputs.vue @@ -87,7 +87,7 @@ diff --git a/src/views/settings/components/MediaProxy.vue b/src/views/settings/components/MediaProxy.vue index 11c9d793..d3fa619d 100644 --- a/src/views/settings/components/MediaProxy.vue +++ b/src/views/settings/components/MediaProxy.vue @@ -3,6 +3,14 @@ + + + + + + + +
Submit
@@ -22,6 +30,12 @@ export default { ...mapGetters([ 'settings' ]), + httpInvalidation() { + return this.settings.description.find(setting => setting.key === 'Pleroma.Web.MediaProxy.Invalidation.Http') + }, + httpInvalidationData() { + return _.get(this.settings.settings, [':pleroma', 'Pleroma.Web.MediaProxy.Invalidation.Http']) || {} + }, isMobile() { return this.$store.state.app.device === 'mobile' }, @@ -51,6 +65,12 @@ export default { }, mediaProxyData() { return _.get(this.settings.settings, [':pleroma', ':media_proxy']) || {} + }, + scriptInvalidation() { + return this.settings.description.find(setting => setting.key === 'Pleroma.Web.MediaProxy.Invalidation.Script') + }, + scriptInvalidationData() { + return _.get(this.settings.settings, [':pleroma', 'Pleroma.Web.MediaProxy.Invalidation.Script']) || {} } }, methods: { From cd689ac75c8748f010648fa0d4e4cd6e9f2e7d16 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Tue, 7 Jul 2020 18:16:35 +0300 Subject: [PATCH 07/28] Enlarge url input, add headers --- src/views/mediaProxyCache/index.vue | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/views/mediaProxyCache/index.vue b/src/views/mediaProxyCache/index.vue index f13dfb7d..9dcdd07e 100644 --- a/src/views/mediaProxyCache/index.vue +++ b/src/views/mediaProxyCache/index.vue @@ -4,6 +4,7 @@

{{ $t('mediaProxyCache.mediaProxyCache') }}

+

Evict object from the MediaProxy cache

{{ $t('mediaProxyCache.ban') }} {{ $t('mediaProxyCache.evict') }}
+

List of all banned MediaProxy URLs

Date: Tue, 7 Jul 2020 22:28:46 +0300 Subject: [PATCH 08/28] Fetch banned objects after banning an url --- src/store/modules/mediaProxyCache.js | 5 ++++- src/views/mediaProxyCache/index.vue | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/store/modules/mediaProxyCache.js b/src/store/modules/mediaProxyCache.js index c148dbdf..d11fad57 100644 --- a/src/store/modules/mediaProxyCache.js +++ b/src/store/modules/mediaProxyCache.js @@ -32,13 +32,16 @@ const mediaProxyCache = { commit('SET_PAGE', page) commit('SET_LOADING', false) }, - async PurgeUrls({ commit, getters }, { urls, ban }) { + async PurgeUrls({ dispatch, getters, state }, { urls, ban }) { await purgeUrls(urls, ban, getters.authHost, getters.token) Message({ message: i18n.t('mediaProxyCache.evictedMessage'), type: 'success', duration: 5 * 1000 }) + if (ban) { + dispatch('ListBannedUrls', state.currentPage) + } }, async RemoveBannedUrls({ commit, getters }, urls) { await removeBannedUrls(urls, getters.authHost, getters.token) diff --git a/src/views/mediaProxyCache/index.vue b/src/views/mediaProxyCache/index.vue index 9dcdd07e..3ca1160a 100644 --- a/src/views/mediaProxyCache/index.vue +++ b/src/views/mediaProxyCache/index.vue @@ -73,6 +73,7 @@ export default { evictURL() { const urls = typeof this.url === 'string' ? [this.url] : this.url this.$store.dispatch('PurgeUrls', { urls, ban: this.ban }) + this.url = '' }, handleSelectionChange(value) { this.$data.selectedUrls = value From a2649dbb640400c045ce15eecdcf921b9a320146 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Tue, 7 Jul 2020 23:54:11 +0300 Subject: [PATCH 09/28] Add ability to evict and ban multiple URLs --- src/lang/en.js | 5 ++++- src/views/mediaProxyCache/index.vue | 27 +++++++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/lang/en.js b/src/lang/en.js index f2b60b86..27d81d91 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -99,7 +99,10 @@ export default { evict: 'Evict', evictedMessage: 'This URL was evicted', actions: 'Actions', - remove: 'Remove from Cachex' + remove: 'Remove from Cachex', + evictObjectsHeader: 'Evict object from the MediaProxy cache', + listBannedUrlsHeader: 'List of all banned MediaProxy URLs', + multipleInput: 'You can enter a single URL or several comma separated links' }, documentation: { documentation: 'Documentation', diff --git a/src/views/mediaProxyCache/index.vue b/src/views/mediaProxyCache/index.vue index 3ca1160a..213e266d 100644 --- a/src/views/mediaProxyCache/index.vue +++ b/src/views/mediaProxyCache/index.vue @@ -4,17 +4,20 @@

{{ $t('mediaProxyCache.mediaProxyCache') }}

-

Evict object from the MediaProxy cache

+

{{ $t('mediaProxyCache.evictObjectsHeader') }}

{{ $t('mediaProxyCache.ban') }} {{ $t('mediaProxyCache.evict') }}
-

List of all banned MediaProxy URLs

+ {{ $t('mediaProxyCache.multipleInput') }} +

{{ $t('mediaProxyCache.listBannedUrlsHeader') }}

url.trim()).filter(el => el.length > 0) this.$store.dispatch('PurgeUrls', { urls, ban: this.ban }) this.url = '' }, @@ -90,6 +93,15 @@ export default { h1 { margin: 0; } +.expl { + color: #666666; + font-size: 13px; + line-height: 22px; + margin: 5px 0 0 0; + overflow-wrap: break-word; + overflow: hidden; + text-overflow: ellipsis; +} .banned-urls-table { margin-top: 15px; margin-bottom: 15px; @@ -114,7 +126,10 @@ h1 { .url-input-container { display: flex; align-items: baseline; - margin: 15px 15px; + margin: 15px 15px 5px 15px; +} +.url-input-expl { + margin-left: 15px; } @media only screen and (max-width:480px) { From 4c32a0708fb9c664beddaeeef542d8520ae5d7fb Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Wed, 8 Jul 2020 02:42:57 +0300 Subject: [PATCH 10/28] Add ability to remove multiple urls --- src/lang/en.js | 3 ++- src/store/modules/mediaProxyCache.js | 3 ++- src/views/mediaProxyCache/index.vue | 28 ++++++++++++++++++++++------ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/lang/en.js b/src/lang/en.js index 27d81d91..3256abcd 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -102,7 +102,8 @@ export default { remove: 'Remove from Cachex', evictObjectsHeader: 'Evict object from the MediaProxy cache', listBannedUrlsHeader: 'List of all banned MediaProxy URLs', - multipleInput: 'You can enter a single URL or several comma separated links' + multipleInput: 'You can enter a single URL or several comma separated links', + removeSelected: 'Remove Selected' }, documentation: { documentation: 'Documentation', diff --git a/src/store/modules/mediaProxyCache.js b/src/store/modules/mediaProxyCache.js index d11fad57..815c14e4 100644 --- a/src/store/modules/mediaProxyCache.js +++ b/src/store/modules/mediaProxyCache.js @@ -43,8 +43,9 @@ const mediaProxyCache = { dispatch('ListBannedUrls', state.currentPage) } }, - async RemoveBannedUrls({ commit, getters }, urls) { + async RemoveBannedUrls({ dispatch, getters, state }, urls) { await removeBannedUrls(urls, getters.authHost, getters.token) + dispatch('ListBannedUrls', state.currentPage) } } } diff --git a/src/views/mediaProxyCache/index.vue b/src/views/mediaProxyCache/index.vue index 213e266d..abe3cd19 100644 --- a/src/views/mediaProxyCache/index.vue +++ b/src/views/mediaProxyCache/index.vue @@ -28,14 +28,20 @@ align="center" width="55"/> - + + @@ -65,6 +71,9 @@ export default { }, loading() { return this.$store.state.mediaProxyCache.loading + }, + removeSelectedDisabled() { + return this.selectedUrls.length === 0 } }, mounted() { @@ -76,14 +85,18 @@ export default { evictURL() { const urls = this.urls.split(',').map(url => url.trim()).filter(el => el.length > 0) this.$store.dispatch('PurgeUrls', { urls, ban: this.ban }) - this.url = '' + this.urls = '' }, handleSelectionChange(value) { this.$data.selectedUrls = value }, - removeUrl(url) { - const urls = typeof this.url === 'string' ? [this.url] : this.url + removeSelected() { + const urls = this.selectedUrls.map(el => el.url) this.$store.dispatch('RemoveBannedUrls', urls) + this.selectedUrls = [] + }, + removeUrl(url) { + this.$store.dispatch('RemoveBannedUrls', [this.url]) } } } @@ -120,6 +133,9 @@ h1 { justify-content: space-between; margin: 10px 15px; } +.remove-url-button { + width: 150px; +} .url-input { margin-right: 15px; } From ab0dd31640cc65bb6595633bbd06f62e28e13697 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Thu, 9 Jul 2020 20:42:37 +0300 Subject: [PATCH 11/28] Fix removing individual url from Cachex --- src/views/mediaProxyCache/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/mediaProxyCache/index.vue b/src/views/mediaProxyCache/index.vue index abe3cd19..6c37082b 100644 --- a/src/views/mediaProxyCache/index.vue +++ b/src/views/mediaProxyCache/index.vue @@ -96,7 +96,7 @@ export default { this.selectedUrls = [] }, removeUrl(url) { - this.$store.dispatch('RemoveBannedUrls', [this.url]) + this.$store.dispatch('RemoveBannedUrls', [url]) } } } From cb89fb09be6ed5c4bcea4fd0934b3d7cbd5371d4 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Thu, 9 Jul 2020 22:27:18 +0300 Subject: [PATCH 12/28] Add input for settings with type ['keyword', 'string'] --- src/store/modules/normalizers.js | 2 +- src/views/settings/components/Inputs.vue | 1 + .../inputComponents/EditableKeywordInput.vue | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index c146d60e..e4eb8816 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -93,7 +93,7 @@ export const parseTuples = (tuples, key) => { return [...acc, { [mascot.tuple[0]]: { ...mascot.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}] }, []) } else if (Array.isArray(item.tuple[1]) && - (item.tuple[0] === ':groups' || item.tuple[0] === ':replace' || item.tuple[0] === ':retries')) { + (item.tuple[0] === ':groups' || item.tuple[0] === ':replace' || item.tuple[0] === ':retries' || item.tuple[0] === ':headers')) { accum[item.tuple[0]] = item.tuple[1].reduce((acc, group) => { return [...acc, { [group.tuple[0]]: { value: group.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}] }, []) diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue index 0578ae2f..44ee957f 100644 --- a/src/views/settings/components/Inputs.vue +++ b/src/views/settings/components/Inputs.vue @@ -283,6 +283,7 @@ export default { return key === ':replace' || type === 'map' || (Array.isArray(type) && type.includes('keyword') && type.includes('integer')) || + (Array.isArray(type) && type.includes('keyword') && type.includes('string')) || (Array.isArray(type) && type.includes('keyword') && type.findIndex(el => el.includes('list') && el.includes('string')) !== -1) }, getFormattedDescription(desc) { diff --git a/src/views/settings/components/inputComponents/EditableKeywordInput.vue b/src/views/settings/components/inputComponents/EditableKeywordInput.vue index 009b2033..76002dd7 100644 --- a/src/views/settings/components/inputComponents/EditableKeywordInput.vue +++ b/src/views/settings/components/inputComponents/EditableKeywordInput.vue @@ -16,6 +16,14 @@ +
+
+ : + + +
+ +
: @@ -54,6 +62,9 @@ export default { editableKeywordWithInteger() { return Array.isArray(this.setting.type) && this.setting.type.includes('keyword') && this.setting.type.includes('integer') }, + editableKeywordWithString() { + return Array.isArray(this.setting.type) && this.setting.type.includes('keyword') && this.setting.type.includes('string') + }, isDesktop() { return this.$store.state.app.device === 'desktop' } From f34157b1db1141f55db0ae6b8f0276ba893f3f14 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 10 Jul 2020 02:22:23 +0300 Subject: [PATCH 13/28] Add ability to wrap and parse nested settings in keyword inputs --- src/store/modules/normalizers.js | 2 +- src/views/settings/components/Inputs.vue | 5 ++- .../inputComponents/EditableKeywordInput.vue | 32 +++++++++++++++++-- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index e4eb8816..927d3d65 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -93,7 +93,7 @@ export const parseTuples = (tuples, key) => { return [...acc, { [mascot.tuple[0]]: { ...mascot.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}] }, []) } 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] === ':groups' || item.tuple[0] === ':replace' || item.tuple[0] === ':retries' || item.tuple[0] === ':headers' || item.tuple[0] === ':params')) { accum[item.tuple[0]] = item.tuple[1].reduce((acc, group) => { return [...acc, { [group.tuple[0]]: { value: group.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}] }, []) diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue index 44ee957f..52cce435 100644 --- a/src/views/settings/components/Inputs.vue +++ b/src/views/settings/components/Inputs.vue @@ -96,7 +96,7 @@ - + @@ -254,6 +254,9 @@ export default { } }, keywordData() { + if (this.settingParent.length > 0) { + return Array.isArray(this.data[this.setting.key]) ? this.data[this.setting.key] : [] + } return Array.isArray(this.data) ? this.data : [] }, reducedSelects() { diff --git a/src/views/settings/components/inputComponents/EditableKeywordInput.vue b/src/views/settings/components/inputComponents/EditableKeywordInput.vue index 76002dd7..a364b3ce 100644 --- a/src/views/settings/components/inputComponents/EditableKeywordInput.vue +++ b/src/views/settings/components/inputComponents/EditableKeywordInput.vue @@ -36,6 +36,8 @@ - - diff --git a/src/views/settings/components/inputComponents/EditableKeywordInput.vue b/src/views/settings/components/inputComponents/EditableKeywordInput.vue index ff641756..6939547a 100644 --- a/src/views/settings/components/inputComponents/EditableKeywordInput.vue +++ b/src/views/settings/components/inputComponents/EditableKeywordInput.vue @@ -1,6 +1,15 @@