From 655584c8771255bfd0fc232e7c7e23419b65debc Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 17 Apr 2020 22:27:00 +0000 Subject: [PATCH] Show reboot button on every page --- CHANGELOG.md | 6 + package.json | 4 +- src/api/__mocks__/app.js | 7 + src/api/__mocks__/users.js | 4 + src/api/app.js | 23 + src/api/settings.js | 9 - src/components/RebootButton/index.vue | 36 + src/lang/en.js | 2 +- src/store/modules/app.js | 23 +- src/store/modules/settings.js | 11 +- src/styles/sidebar.scss | 2 +- src/views/emojiPacks/index.vue | 60 +- src/views/invites/index.vue | 30 +- src/views/layout/components/Navbar.vue | 2 +- src/views/moderation_log/index.vue | 25 +- src/views/reports/components/Report.vue | 6 +- src/views/reports/index.vue | 42 +- src/views/settings/components/ActivityPub.vue | 5 +- .../settings/components/Authentication.vue | 5 +- src/views/settings/components/AutoLinker.vue | 5 +- src/views/settings/components/Captcha.vue | 5 +- src/views/settings/components/Esshd.vue | 5 +- src/views/settings/components/Frontend.vue | 5 +- src/views/settings/components/Gopher.vue | 5 +- src/views/settings/components/Http.vue | 5 +- src/views/settings/components/JobQueue.vue | 5 +- src/views/settings/components/Logger.vue | 5 +- src/views/settings/components/MRF.vue | 5 +- src/views/settings/components/Mailer.vue | 5 +- src/views/settings/components/MediaProxy.vue | 5 +- src/views/settings/components/Metadata.vue | 5 +- src/views/settings/components/Other.vue | 5 +- .../settings/components/RateLimiters.vue | 5 +- src/views/settings/components/Upload.vue | 5 +- src/views/settings/components/WebPush.vue | 5 +- src/views/settings/index.vue | 42 +- src/views/settings/styles/main.scss | 73 +- src/views/statuses/index.vue | 60 +- .../users/components/ModerationDropdown.vue | 5 + src/views/users/components/UsersFilter.vue | 6 - src/views/users/index.vue | 55 +- src/views/users/show.vue | 63 +- test/views/invites/index.test.js | 2 + test/views/invites/store.conf.js | 2 + test/views/layout/index.test.js | 4 +- test/views/reports/index.test.js | 1 + test/views/reports/store.conf.js | 2 + test/views/settings/index.test.js | 6 +- test/views/users/index.test.js | 1 + test/views/users/store.conf.js | 2 + yarn.lock | 2290 +++++++++++------ 51 files changed, 2032 insertions(+), 964 deletions(-) create mode 100644 src/api/__mocks__/app.js create mode 100644 src/api/app.js create mode 100644 src/components/RebootButton/index.vue diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a7c65a1..e5f172e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Link settings that enable registrations and invites +### Changed + +- Put Instance Reboot button on all pages of admin-fe +- Make Instance Reboot button's positon fixed on Settings page +- Update jest and babel-jest + ### Fixed - Disable Invites tab when invites are disabled on BE diff --git a/package.json b/package.json index 876205ca..1a757a57 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "autoprefixer": "8.5.0", "babel-eslint": "8.2.6", "babel-helper-vue-jsx-merge-props": "2.0.3", - "babel-jest": "^24.1.0", + "babel-jest": "^25.3.0", "babel-loader": "^8.0.5", "babel-plugin-dynamic-import-node-babel-7": "^2.0.7", "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2", @@ -101,7 +101,7 @@ "hash-sum": "1.0.2", "html-webpack-plugin": "^3.2.0", "husky": "0.14.3", - "jest": "^24.1.0", + "jest": "^25.3.0", "jest-transform-stub": "^2.0.0", "lint-staged": "7.2.2", "mini-css-extract-plugin": "0.4.1", diff --git a/src/api/__mocks__/app.js b/src/api/__mocks__/app.js new file mode 100644 index 00000000..4349a432 --- /dev/null +++ b/src/api/__mocks__/app.js @@ -0,0 +1,7 @@ +export async function needReboot(authHost, token) { + return Promise.resolve({ data: false }) +} + +export async function restartApp(authHost, token) { + return Promise.resolve() +} diff --git a/src/api/__mocks__/users.js b/src/api/__mocks__/users.js index 31657293..9a3afd41 100644 --- a/src/api/__mocks__/users.js +++ b/src/api/__mocks__/users.js @@ -28,6 +28,10 @@ export async function fetchUser(id, authHost, token) { return Promise.resolve({ data: userProfile }) } +export async function fetchUserCredentials(nickname, authHost, token) { + return Promise.resolve({ data: {}}) +} + export async function fetchUsers(filters, authHost, token, page = 1) { const filteredUsers = filterUsers(filters) return Promise.resolve({ data: { diff --git a/src/api/app.js b/src/api/app.js new file mode 100644 index 00000000..0d32fb25 --- /dev/null +++ b/src/api/app.js @@ -0,0 +1,23 @@ +import request from '@/utils/request' +import { getToken } from '@/utils/auth' +import { baseName } from './utils' + +export async function needReboot(authHost, token) { + return await request({ + baseURL: baseName(authHost), + url: `/api/pleroma/admin/need_reboot`, + method: 'get', + headers: authHeaders(token) + }) +} + +export async function restartApp(authHost, token) { + return await request({ + baseURL: baseName(authHost), + url: `/api/pleroma/admin/restart`, + method: 'get', + headers: authHeaders(token) + }) +} + +const authHeaders = (token) => token ? { 'Authorization': `Bearer ${getToken()}` } : {} diff --git a/src/api/settings.js b/src/api/settings.js index 82aa36e7..9d1c2890 100644 --- a/src/api/settings.js +++ b/src/api/settings.js @@ -40,13 +40,4 @@ export async function removeSettings(configs, authHost, token) { }) } -export async function restartApp(authHost, token) { - return await request({ - baseURL: baseName(authHost), - url: `/api/pleroma/admin/restart`, - method: 'get', - headers: authHeaders(token) - }) -} - const authHeaders = (token) => token ? { 'Authorization': `Bearer ${getToken()}` } : {} diff --git a/src/components/RebootButton/index.vue b/src/components/RebootButton/index.vue new file mode 100644 index 00000000..67b9cf95 --- /dev/null +++ b/src/components/RebootButton/index.vue @@ -0,0 +1,36 @@ + + + diff --git a/src/lang/en.js b/src/lang/en.js index 30dd1ffb..74891c59 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -383,7 +383,7 @@ export default { emoji: 'Emoji', markup: 'Markup settings', corsPlug: 'CORS plug config', - instanceReboot: 'Instance Reboot', + instanceReboot: 'Reboot Instance', restartApp: 'You must restart the instance to apply settings', restartSuccess: 'Instance rebooted successfully!' }, diff --git a/src/store/modules/app.js b/src/store/modules/app.js index 073ac434..e06953aa 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -1,4 +1,5 @@ import Cookies from 'js-cookie' +import { needReboot, restartApp } from '@/api/app' const app = { state: { @@ -8,6 +9,7 @@ const app = { }, device: 'desktop', language: Cookies.get('language') || 'en', + needReboot: false, size: Cookies.get('size') || 'medium', invitesEnabled: false }, @@ -36,20 +38,25 @@ const app = { state.language = language Cookies.set('language', language) }, + TOGGLE_REBOOT: (state, needReboot) => { + state.needReboot = needReboot + }, SET_SIZE: (state, size) => { state.size = size Cookies.set('size', size) } }, actions: { - toggleSideBar({ commit }) { - commit('TOGGLE_SIDEBAR') - }, closeSideBar({ commit }, { withoutAnimation }) { commit('CLOSE_SIDEBAR', withoutAnimation) }, - toggleDevice({ commit }, device) { - commit('TOGGLE_DEVICE', device) + async NeedReboot({ commit, getters }) { + const response = await needReboot(getters.authHost, getters.token) + commit('TOGGLE_REBOOT', response.data['need_reboot']) + }, + async RestartApplication({ commit, getters }) { + await restartApp(getters.authHost, getters.token) + commit('TOGGLE_REBOOT', false) }, SetInvitesEnabled({ commit }, invitesEnabled) { commit('SET_INVITES_ENABLED', invitesEnabled) @@ -59,6 +66,12 @@ const app = { }, setSize({ commit }, size) { commit('SET_SIZE', size) + }, + toggleDevice({ commit }, device) { + commit('TOGGLE_DEVICE', device) + }, + toggleSideBar({ commit }) { + commit('TOGGLE_SIDEBAR') } } } diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js index 5adc16a0..6053ec2d 100644 --- a/src/store/modules/settings.js +++ b/src/store/modules/settings.js @@ -1,4 +1,4 @@ -import { fetchDescription, fetchSettings, removeSettings, restartApp, updateSettings } from '@/api/settings' +import { fetchDescription, fetchSettings, removeSettings, updateSettings } from '@/api/settings' import { checkPartialUpdate, formSearchObject, parseNonTuples, parseTuples, valueHasTuples, wrapUpdatedSettings } from './normalizers' import _ from 'lodash' @@ -9,7 +9,6 @@ const settings = { db: {}, description: [], loading: true, - needReboot: false, searchData: {}, settings: {}, updatedSettings: {} @@ -55,9 +54,6 @@ const settings = { state.settings = newSettings state.db = newDbSettings }, - TOGGLE_REBOOT: (state, needReboot) => { - state.needReboot = needReboot || false - }, TOGGLE_TABS: (state, status) => { state.configDisabled = status }, @@ -84,7 +80,6 @@ const settings = { const searchObject = formSearchObject(description.data) commit('SET_SEARCH', searchObject) commit('SET_SETTINGS', response.data.configs) - commit('TOGGLE_REBOOT', response.data.need_reboot) } catch (_e) { commit('TOGGLE_TABS', true) commit('SET_ACTIVE_TAB', 'relays') @@ -102,10 +97,6 @@ const settings = { commit('TOGGLE_REBOOT', response.data.need_reboot) commit('REMOVE_SETTING_FROM_UPDATED', { group, key, subkeys: subkeys || [] }) }, - async RestartApplication({ commit, getters }) { - await restartApp(getters.authHost, getters.token) - commit('TOGGLE_REBOOT', false) - }, SetActiveTab({ commit }, tab) { commit('SET_ACTIVE_TAB', tab) }, diff --git a/src/styles/sidebar.scss b/src/styles/sidebar.scss index ce619fd3..688a295a 100644 --- a/src/styles/sidebar.scss +++ b/src/styles/sidebar.scss @@ -18,7 +18,7 @@ top: 0; bottom: 0; left: 0; - z-index: 1001; + z-index: 5000; overflow: hidden; //reset element-ui css diff --git a/src/views/emojiPacks/index.vue b/src/views/emojiPacks/index.vue index 8154f254..a66507fe 100644 --- a/src/views/emojiPacks/index.vue +++ b/src/views/emojiPacks/index.vue @@ -1,13 +1,18 @@