diff --git a/CHANGELOG.md b/CHANGELOG.md index f7ab238c..24db7aec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Report notes - Ability to moderate users on the statuses page - Ability to moderate user on the user's page +- Ability to restart an application when settings that require instance reboot were changed - Mobile UI for Settings tab ### Fixed diff --git a/src/api/settings.js b/src/api/settings.js index 9d1c2890..82aa36e7 100644 --- a/src/api/settings.js +++ b/src/api/settings.js @@ -40,4 +40,13 @@ 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/lang/en.js b/src/lang/en.js index 3fa42e8c..3f9643ca 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -363,7 +363,10 @@ export default { assets: 'Assets', emoji: 'Emoji', markup: 'Markup settings', - corsPlug: 'CORS plug config' + corsPlug: 'CORS plug config', + instanceReboot: 'Instance Reboot', + restartApp: 'You must restart the instance to apply settings', + restartSuccess: 'Instance rebooted successfully!' }, invites: { inviteTokens: 'Invite tokens', diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js index 0ecbc9a2..ab7a3b36 100644 --- a/src/store/modules/settings.js +++ b/src/store/modules/settings.js @@ -1,4 +1,4 @@ -import { fetchDescription, fetchSettings, removeSettings, updateSettings } from '@/api/settings' +import { fetchDescription, fetchSettings, removeSettings, restartApp, updateSettings } from '@/api/settings' import { checkPartialUpdate, parseNonTuples, parseTuples, valueHasTuples, wrapUpdatedSettings } from './normalizers' import _ from 'lodash' @@ -6,11 +6,12 @@ const settings = { state: { activeTab: 'instance', configDisabled: true, - description: [], - settings: {}, - updatedSettings: {}, db: {}, - loading: true + description: [], + loading: true, + needReboot: false, + settings: {}, + updatedSettings: {} }, mutations: { CLEAR_UPDATED_SETTINGS: (state) => { @@ -50,6 +51,9 @@ const settings = { state.settings = newSettings state.db = newDbSettings }, + TOGGLE_REBOOT: (state, needReboot) => { + state.needReboot = needReboot || false + }, TOGGLE_TABS: (state, status) => { state.configDisabled = status }, @@ -74,6 +78,7 @@ const settings = { const description = await fetchDescription(getters.authHost, getters.token) commit('SET_DESCRIPTION', description.data) commit('SET_SETTINGS', response.data.configs) + commit('TOGGLE_REBOOT', response.data.need_reboot) } catch (_e) { commit('TOGGLE_TABS', true) commit('SET_ACTIVE_TAB', 'relays') @@ -88,8 +93,13 @@ const settings = { const response = await fetchSettings(getters.authHost, getters.token) const { group, key, subkeys } = configs[0] commit('SET_SETTINGS', response.data.configs) + 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) }, @@ -102,6 +112,7 @@ const settings = { await updateSettings(configs, getters.authHost, getters.token) const response = await fetchSettings(getters.authHost, getters.token) commit('SET_SETTINGS', response.data.configs) + commit('TOGGLE_REBOOT', response.data.need_reboot) commit('CLEAR_UPDATED_SETTINGS') }, UpdateSettings({ commit }, { group, key, input, value, type }) { diff --git a/src/views/settings/components/Http.vue b/src/views/settings/components/Http.vue index a94000b2..a12a1efa 100644 --- a/src/views/settings/components/Http.vue +++ b/src/views/settings/components/Http.vue @@ -3,6 +3,10 @@ + + + + {{ $t('settings.corsPlug') }} @@ -82,6 +86,12 @@ export default { loading() { return this.settings.loading }, + teslaAdapter() { + return this.settings.description.find(setting => setting.group === ':tesla') + }, + teslaAdapterData() { + return _.get(this.settings.settings, [':tesla']) || {} + }, webCacheTtl() { return this.settings.description.find(setting => setting.key === ':web_cache_ttl') }, diff --git a/src/views/settings/components/Other.vue b/src/views/settings/components/Other.vue index d748c2da..4a3b465f 100644 --- a/src/views/settings/components/Other.vue +++ b/src/views/settings/components/Other.vue @@ -1,9 +1,5 @@