From 2267b58ed274b7c65f0668d22a8ace3f9e474c99 Mon Sep 17 00:00:00 2001 From: Axolotle Date: Thu, 8 Oct 2020 15:15:44 +0200 Subject: [PATCH] add experimental option feature in TooWebAdmin --- app/src/i18n/locales/en.json | 5 ++- app/src/store/settings.js | 13 +++++-- app/src/views/tool/ToolWebadmin.vue | 57 +++++++++++++++++++++++------ 3 files changed, 60 insertions(+), 15 deletions(-) diff --git a/app/src/i18n/locales/en.json b/app/src/i18n/locales/en.json index 4bd0ea1a..c8465f04 100644 --- a/app/src/i18n/locales/en.json +++ b/app/src/i18n/locales/en.json @@ -125,6 +125,7 @@ "error_server_unexpected": "Unexpected server error (%s)", "error_connection_interrupted": "The server closed the connection instead of answering it. Has nginx or the yunohost-api been restarted or stoppted for some reason? (Error code/message: %s)", "everything_good": "Everything good!", + "experimental": "Experimental", "experimental_warning": "Warning: this feature is experimental and not consider stable, you shouldn't be using it except if you know what you are doing.", "firewall": "Firewall", "footer": { @@ -349,7 +350,9 @@ "locale": "Locale", "fallback_locale": "Fallback locale", "cache": "Cache", - "cache_description": "Consider disabling the cache if you plan on working with the CLI while also navigating in this web-admin." + "cache_description": "Consider disabling the cache if you plan on working with the CLI while also navigating in this web-admin.", + "experimental": "Experimental mode", + "experimental_description": "Gives you access to experimental features. These are considered unstable and may break your system.
Enabled this only if you know what you are doing." }, "tools_webadmin_settings": "Web-admin settings", "udp": "UDP", diff --git a/app/src/store/settings.js b/app/src/store/settings.js index 9913a31c..3cce91d1 100644 --- a/app/src/store/settings.js +++ b/app/src/store/settings.js @@ -12,6 +12,7 @@ export default { locale: localStorage.getItem('locale'), fallbackLocale: localStorage.getItem('fallbackLocale'), cache: localStorage.getItem('cache') !== 'false', + experimental: localStorage.getItem('experimental') === 'true', supportedLocales: supportedLocales }, @@ -26,9 +27,14 @@ export default { state.fallbackLocale = locale }, - 'SET_CACHE' (state, enable) { - localStorage.setItem('cache', enable) - state.cache = enable + 'SET_CACHE' (state, boolean) { + localStorage.setItem('cache', boolean) + state.cache = boolean + }, + + 'SET_EXPERIMENTAL' (state, boolean) { + localStorage.setItem('experimental', boolean) + state.experimental = boolean } }, @@ -55,6 +61,7 @@ export default { locale: state => (state.locale), fallbackLocale: state => (state.fallbackLocale), cache: state => (state.cache), + experimental: state => state.experimental, availableLocales: state => { return Object.entries(state.supportedLocales).map(([locale, { name }]) => { diff --git a/app/src/views/tool/ToolWebadmin.vue b/app/src/views/tool/ToolWebadmin.vue index 0f0b6e16..f0951705 100644 --- a/app/src/views/tool/ToolWebadmin.vue +++ b/app/src/views/tool/ToolWebadmin.vue @@ -1,7 +1,10 @@ @@ -48,6 +75,7 @@ export default { 'locale', 'fallbackLocale', 'cache', + 'experimental', 'availableLocales' ]), @@ -70,6 +98,13 @@ export default { set: function (newValue) { this.$store.commit('SET_CACHE', newValue) } + }, + + currentExperimental: { + get: function () { return this.experimental }, + set: function (newValue) { + this.$store.commit('SET_EXPERIMENTAL', newValue) + } } },