From 31863b7c492f706840d567058a2d27a625c24cfc Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Mon, 28 Dec 2020 02:41:37 +0300 Subject: [PATCH 01/19] Add rules for rendering settings. Do not render :proxy_remote setting if :uploader is set to Local --- src/views/settings/components/Setting.vue | 11 ++++++++++ src/views/settings/rules.js | 26 +++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/views/settings/rules.js diff --git a/src/views/settings/components/Setting.vue b/src/views/settings/components/Setting.vue index 7593fb3d..28080b21 100644 --- a/src/views/settings/components/Setting.vue +++ b/src/views/settings/components/Setting.vue @@ -7,6 +7,7 @@
@@ -15,6 +16,7 @@ v-for="setting in emailAdapterChildren" :key="setting.key"> @@ -24,6 +26,7 @@
{ + return state[group][groupKey][targetKey] !== notEqual +} + +const rulesMap = { + renderIfNotEqual +} + +export const settingFollowsRules = (settingKey, settingGroupKey, state) => { + const rule = rules.find(rule => rule.groupKey === settingGroupKey && rule.key === settingKey) + if (!rule) return true + + const ruleFn = rulesMap[rule.name] + if (!ruleFn) return true + return ruleFn(state, rule) +} From 2aede0f1798e31907bd9507abe404777c1f98249 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Mon, 28 Dec 2020 02:45:48 +0300 Subject: [PATCH 02/19] Update Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2f8d43c..1d35eb1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Filter users by actor type: Person, Bot or Application - Add ability to configure Media Preview Proxy, User Backup, Websocket based federation and Pleroma.Web.Endpoint.MetricsExporter settings - Mobile and Tablet UI for Single Report show page +- Ability to set rules and conditions for rendering settings (e.g. `:proxy_remote` setting is hidden if `:uploader` setting is set to `Pleroma.Uploaders.Local`) ### Changed - Hide Tag actions on Users tab if MRF TagPolicy is disabled. Add ability to enable TagPolicy from Moderation menu From cc6c8b2b387639387b9871be6715cb0c0475bf8a Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Tue, 29 Dec 2020 00:54:15 +0300 Subject: [PATCH 03/19] Add tests for function that checks if setting follows rules --- .../settings/settingFollowsRules.test.js | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/views/settings/settingFollowsRules.test.js diff --git a/test/views/settings/settingFollowsRules.test.js b/test/views/settings/settingFollowsRules.test.js new file mode 100644 index 00000000..a67745c2 --- /dev/null +++ b/test/views/settings/settingFollowsRules.test.js @@ -0,0 +1,35 @@ +import { settingFollowsRules } from '@/views/settings/rules' + +describe('Check if settings follow rules', () => { + it('does not render :proxy_remote when local :uploader is selected', () => { + const state = { ':pleroma': { 'Pleroma.Upload': { ':uploader': 'Pleroma.Uploaders.Local' }}} + + expect(settingFollowsRules(':proxy_remote', 'Pleroma.Upload', state)).toBeFalsy() + }) + + it('render :proxy_remote when local :uploader is not selected', () => { + const state = { ':pleroma': { 'Pleroma.Upload': { ':uploader': 'Pleroma.Uploaders.S3' }}} + + expect(settingFollowsRules(':proxy_remote', 'Pleroma.Upload', state)).toBeTruthy() + }) + + it('render setting when there is no rule', () => { + const state = { ':pleroma': { 'Pleroma.Upload': { ':uploader': 'Pleroma.Uploaders.Local' }}} + + expect(settingFollowsRules(':filters', 'Pleroma.Upload', state)).toBeTruthy() + }) + + it('render setting when one of the keys is undefined', () => { + const state = { ':pleroma': {}} + + expect(settingFollowsRules(':level', undefined, state)).toBeTruthy() + + expect(settingFollowsRules(':admin_token', undefined, state)).toBeTruthy() + }) + + it('render setting when state is empty', () => { + const state = { ':pleroma': { 'Pleroma.Upload': {}}} + + expect(settingFollowsRules(':proxy_remote', 'Pleroma.Upload', state)).toBeTruthy() + }) +}) \ No newline at end of file From 5ca76701c2a24ded6181b93511ac9aa13a2387c1 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Tue, 2 Mar 2021 00:22:26 +0300 Subject: [PATCH 04/19] Fix displaying messages for multiple errors --- src/utils/request.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/utils/request.js b/src/utils/request.js index b7e3d5f1..163ce872 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -6,27 +6,32 @@ const service = axios.create({ timeout: 60000 // request timeout }) +const isJson = ({ headers }) => headers['content-type'].includes('application/json') + // response interceptor service.interceptors.response.use( response => response, error => { - let errorMessage console.log(`Error ${error}`) - if (error.response) { - const edata = error.response.data.error ? error.response.data.error : error.response.data - errorMessage = !error.response.headers['content-type'].includes('application/json') - ? `${error.message}` - : `${error.message} - ${edata}` + if (!error.response) { + Message({ + message: error, + type: 'error', + duration: 5 * 1000 + }) } else { - errorMessage = error + const errors = Array.isArray(error.response.data) ? error.response.data : [error.response.data] + errors.forEach(errorData => { + const edata = errorData.error || errorData + Message({ + message: isJson(error.response) ? `${error.message} - ${edata}` : `${error.message}`, + type: 'error', + duration: 5 * 1000 + }) + }) } - Message({ - message: errorMessage, - type: 'error', - duration: 5 * 1000 - }) return Promise.reject(error) } ) From 6722a9e34ae4b8d6b86adfc699670a15b31e76ef Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Mon, 8 Feb 2021 01:42:31 +0300 Subject: [PATCH 05/19] Replace router push with the one that catches errors --- src/router/index.js | 13 +++++++++++++ test/views/layout/index.test.js | 1 + 2 files changed, 14 insertions(+) diff --git a/src/router/index.js b/src/router/index.js index 661fb7f2..d151daeb 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -3,6 +3,19 @@ import Router from 'vue-router' Vue.use(Router) +const originalPush = Router.prototype.push +Router.prototype.push = function push(location, onResolve, onReject) { + if (onResolve || onReject) { return originalPush.call(this, location, onResolve, onReject) } + return originalPush.call(this, location).catch((err) => { + if (Router.isNavigationFailure(err)) { + // resolve err + return err + } + // rethrow error + return Promise.reject(err) + }) +} + /* Layout */ import Layout from '@/views/layout/Layout' diff --git a/test/views/layout/index.test.js b/test/views/layout/index.test.js index 686a4226..af71ee17 100644 --- a/test/views/layout/index.test.js +++ b/test/views/layout/index.test.js @@ -16,6 +16,7 @@ localVue.use(VueRouter) localVue.use(Element) jest.mock('@/api/reports') +jest.mock('@/api/settings') describe('Log out', () => { let store From c6169f36f7f118da465b772f96d30e1d02dd2bc1 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Tue, 2 Mar 2021 00:30:35 +0300 Subject: [PATCH 06/19] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac48d297..c80c1793 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,7 +34,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix wrapping `:icons` setting and parsing tuples in settings with key `:headers` - Update keys for Pleroma.Web.Plugs.RemoteIp and PurgeExpiredActivity settings - Update switching between local and remote emoji packs panels: the panel with the pack's metadata will be closed when another panel is opened - +- Fix displaying messages for multiple errors ## [2.2] - 2020-11-18 ### Added From 837474f179e726aa0bc175b71797e2ac12aa8493 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Mon, 8 Mar 2021 23:57:11 +0800 Subject: [PATCH 07/19] Update webpack config to generate render function --- build/webpack.dev.conf.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/build/webpack.dev.conf.js b/build/webpack.dev.conf.js index 1b6d4d75..85086449 100644 --- a/build/webpack.dev.conf.js +++ b/build/webpack.dev.conf.js @@ -48,7 +48,7 @@ const devWebpackConfig = merge(baseWebpackConfig, { poll: config.dev.poll }, headers: { - 'content-security-policy': "base-uri 'self'; frame-ancestors 'none'; img-src 'self' data: https: http:; media-src 'self' https:; style-src 'self' 'unsafe-inline'; font-src 'self'; manifest-src 'self'; script-src 'self';" + 'content-security-policy': "script-src 'self' 'unsafe-eval'; base-uri 'self'; frame-ancestors 'none'; img-src 'self' data: https: http:; media-src 'self' https:; style-src 'self' 'unsafe-inline'; font-src 'self'; manifest-src 'self'" } }, plugins: [ @@ -67,7 +67,12 @@ const devWebpackConfig = merge(baseWebpackConfig, { BASE_URL: devEnv.ASSETS_PUBLIC_PATH + config.dev.assetsSubDirectory, }, }), - ] + ], + resolve: { + alias: { + vue: 'vue/dist/vue.js' + } + } }) module.exports = new Promise((resolve, reject) => { From 0087e951415f109b0502fe4cd2066bf1400934d1 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 12 Jun 2020 21:34:48 +0300 Subject: [PATCH 08/19] Remove unused Error log view files --- src/lang/en.js | 5 ----- src/lang/es.js | 5 ----- src/lang/oc.js | 5 ----- src/lang/zh.js | 5 ----- src/views/errorLog/errorTestA.vue | 13 ------------ src/views/errorLog/errorTestB.vue | 11 ----------- src/views/errorLog/index.vue | 33 ------------------------------- 7 files changed, 77 deletions(-) delete mode 100644 src/views/errorLog/errorTestA.vue delete mode 100644 src/views/errorLog/errorTestB.vue delete mode 100644 src/views/errorLog/index.vue diff --git a/src/lang/en.js b/src/lang/en.js index e21a156d..9be8fe96 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -158,11 +158,6 @@ export default { confirm: 'Confirm', unfollow: 'Unfollow' }, - errorLog: { - tips: 'Please click the bug icon in the upper right corner', - description: 'Now the management system are basically the form of the spa, it enhances the user experience, but it also increases the possibility of page problems, a small negligence may lead to the entire page deadlock. Fortunately Vue provides a way to catch handling exceptions, where you can handle errors or report exceptions.', - documentation: 'Document introduction' - }, excel: { export: 'Export', selectedExport: 'Export Selected Items', diff --git a/src/lang/es.js b/src/lang/es.js index 25231eca..fd094b36 100755 --- a/src/lang/es.js +++ b/src/lang/es.js @@ -127,11 +127,6 @@ export default { cancel: 'Cancelar', confirm: 'Confirmar' }, - errorLog: { - tips: 'Please click the bug icon in the upper right corner', - description: 'Now the management system are basically the form of the spa, it enhances the user experience, but it also increases the possibility of page problems, a small negligence may lead to the entire page deadlock. Fortunately Vue provides a way to catch handling exceptions, where you can handle errors or report exceptions.', - documentation: 'Documento de introducción' - }, excel: { export: 'Exportar', selectedExport: 'Exportar seleccionados', diff --git a/src/lang/oc.js b/src/lang/oc.js index 088f5acb..e181ab86 100644 --- a/src/lang/oc.js +++ b/src/lang/oc.js @@ -128,11 +128,6 @@ export default { cancel: 'Anullar', confirm: 'Confirmar' }, - errorLog: { - tips: 'Mercés de clicar l’’icòna del babau amont a man drecha', - description: 'Ara que lo sistèma de gestion es coma un spa, melhora l’experiéncia dels utilizaire mas aumenta tanben lo risc de problèmas sus la pagina, una pichona negligéncia pòt menar a un blocatge complèt de la pagina. Urosament Vue fornís de manièras per gerir las excepcions, trobar las errors o senhalar las excepcions.', - documentation: 'Presentacion del document' - }, excel: { export: 'Exportar', selectedExport: 'Exportar los elements seleccionats', diff --git a/src/lang/zh.js b/src/lang/zh.js index a28771c5..7933d584 100644 --- a/src/lang/zh.js +++ b/src/lang/zh.js @@ -127,11 +127,6 @@ export default { cancel: '取 消', confirm: '确 定' }, - errorLog: { - tips: '请点击右上角bug小图标', - description: '现在的管理后台基本都是spa的形式了,它增强了用户体验,但同时也会增加页面出问题的可能性,可能一个小小的疏忽就导致整个页面的死锁。好在 Vue 官网提供了一个方法来捕获处理异常,你可以在其中进行错误处理或者异常上报。', - documentation: '文档介绍' - }, excel: { export: '导出', selectedExport: '导出已选择项', diff --git a/src/views/errorLog/errorTestA.vue b/src/views/errorLog/errorTestA.vue deleted file mode 100644 index 52654e0e..00000000 --- a/src/views/errorLog/errorTestA.vue +++ /dev/null @@ -1,13 +0,0 @@ - - - diff --git a/src/views/errorLog/errorTestB.vue b/src/views/errorLog/errorTestB.vue deleted file mode 100644 index b04c2511..00000000 --- a/src/views/errorLog/errorTestB.vue +++ /dev/null @@ -1,11 +0,0 @@ - - - diff --git a/src/views/errorLog/index.vue b/src/views/errorLog/index.vue deleted file mode 100644 index 47db4ae5..00000000 --- a/src/views/errorLog/index.vue +++ /dev/null @@ -1,33 +0,0 @@ - - - - - From 14cf2a460c35ead7440ced8d1b0677d880d9a56b Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Sat, 13 Jun 2020 00:09:52 +0300 Subject: [PATCH 09/19] Update 401 Error Page --- src/lang/en.js | 6 +++ src/styles/index.scss | 37 ++++---------- src/views/errorPage/401.vue | 96 ++++++++++++------------------------- 3 files changed, 45 insertions(+), 94 deletions(-) diff --git a/src/lang/en.js b/src/lang/en.js index 9be8fe96..f73fe226 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -73,6 +73,12 @@ export default { mediaProxyCache: 'MediaProxy Cache', 'emoji-packs': 'Emoji packs' }, + errLog: { + error401: 'Oops! 401 Error', + unauth: 'Unauthorized', + back: 'Back', + login: 'Login' + }, navbar: { logOut: 'Log Out', dashboard: 'Dashboard', diff --git a/src/styles/index.scss b/src/styles/index.scss index b35df6ad..5a906d5b 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -22,8 +22,16 @@ label { html { height: 100%; box-sizing: border-box; + font-size: 62.5%; } +h1 { + font-size: 3.2em; +} + +h2 { + font-size: 2.4em; +} #app { height: 100%; } @@ -171,32 +179,3 @@ code { background: #d0d0d0; } } - -.link-type, -.link-type:focus { - color: #337ab7; - cursor: pointer; - - &:hover { - color: rgb(32, 160, 255); - } -} - -.filter-container { - padding-bottom: 10px; - - .filter-item { - display: inline-block; - vertical-align: middle; - margin-bottom: 10px; - } -} - -//refine vue-multiselect plugin -.multiselect { - line-height: 16px; -} - -.multiselect--active { - z-index: 1000 !important; -} diff --git a/src/views/errorPage/401.vue b/src/views/errorPage/401.vue index 2901c942..f57cae67 100644 --- a/src/views/errorPage/401.vue +++ b/src/views/errorPage/401.vue @@ -1,91 +1,57 @@ From a3f952b346a5f65a02d9412997ea07a3eb3daa86 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Sun, 14 Jun 2020 01:05:27 +0300 Subject: [PATCH 10/19] Redo 404 Error page --- src/lang/en.js | 6 +- src/views/errorPage/404.vue | 236 ++++++------------------------------ 2 files changed, 40 insertions(+), 202 deletions(-) diff --git a/src/lang/en.js b/src/lang/en.js index f73fe226..d631bc8d 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -75,9 +75,13 @@ export default { }, errLog: { error401: 'Oops! 401 Error', + error404: 'Oops! 404 Error', + pageNotFound: 'Page not found', + correctUrl: 'Please make sure you URL is correct', unauth: 'Unauthorized', back: 'Back', - login: 'Login' + login: 'Login', + homePage: 'Home Page' }, navbar: { logOut: 'Log Out', diff --git a/src/views/errorPage/404.vue b/src/views/errorPage/404.vue index d20a4ef4..1ce4ab42 100644 --- a/src/views/errorPage/404.vue +++ b/src/views/errorPage/404.vue @@ -1,17 +1,13 @@