From ece69f01b790b4bc02387d31ca911a0588e0664c Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 22 Mar 2023 18:57:23 +0200 Subject: [PATCH 1/6] added mass-draft-push and mass-draft-reset, small stylistic fixes --- .../settings_modal/settings_modal.js | 14 ++++- .../settings_modal/settings_modal.scss | 2 + .../settings_modal/settings_modal.vue | 19 ++++++- src/modules/adminSettings.js | 57 ++++++++++++++++++- 4 files changed, 88 insertions(+), 4 deletions(-) diff --git a/src/components/settings_modal/settings_modal.js b/src/components/settings_modal/settings_modal.js index e033d9997..ff58f2c38 100644 --- a/src/components/settings_modal/settings_modal.js +++ b/src/components/settings_modal/settings_modal.js @@ -5,7 +5,7 @@ import getResettableAsyncComponent from 'src/services/resettable_async_component import Popover from '../popover/popover.vue' import Checkbox from 'src/components/checkbox/checkbox.vue' import { library } from '@fortawesome/fontawesome-svg-core' -import { cloneDeep } from 'lodash' +import { cloneDeep, isEqual } from 'lodash' import { newImporter, newExporter @@ -155,6 +155,12 @@ const SettingsModal = { PLEROMAFE_SETTINGS_MINOR_VERSION ] return clone + }, + resetAdminDraft () { + this.$store.commit('resetAdminDraft') + }, + pushAdminDraft () { + this.$store.dispatch('pushAdminDraft') } }, computed: { @@ -183,6 +189,12 @@ const SettingsModal = { set (value) { this.$store.dispatch('setOption', { name: 'expertLevel', value: value ? 1 : 0 }) } + }, + adminDraftAny () { + return !isEqual( + this.$store.state.adminSettings.config, + this.$store.state.adminSettings.draft + ) } } } diff --git a/src/components/settings_modal/settings_modal.scss b/src/components/settings_modal/settings_modal.scss index 4cce60993..4cb506f93 100644 --- a/src/components/settings_modal/settings_modal.scss +++ b/src/components/settings_modal/settings_modal.scss @@ -51,6 +51,8 @@ .settings-footer { display: flex; + flex-wrap: wrap; + line-height: 2; >* { margin-right: 0.5em; diff --git a/src/components/settings_modal/settings_modal.vue b/src/components/settings_modal/settings_modal.vue index 303050e43..57ec5535b 100644 --- a/src/components/settings_modal/settings_modal.vue +++ b/src/components/settings_modal/settings_modal.vue @@ -45,7 +45,7 @@ - diff --git a/src/modules/adminSettings.js b/src/modules/adminSettings.js index 27d5b37d3..25fb8e501 100644 --- a/src/modules/adminSettings.js +++ b/src/modules/adminSettings.js @@ -1,4 +1,4 @@ -import { set, get, cloneDeep } from 'lodash' +import { set, get, cloneDeep, differenceWith, isEqual, flatten } from 'lodash' export const defaultState = { needsReboot: null, @@ -42,7 +42,7 @@ const adminSettingsStorage = { actions: { setInstanceAdminSettings ({ state, commit, dispatch }, { backendDbConfig }) { const config = state.config || {} - const modifiedPaths = state.modifiedPaths || new Set() + const modifiedPaths = new Set() backendDbConfig.configs.forEach(c => { const path = [c.group, c.key] if (c.db) { @@ -82,6 +82,59 @@ const adminSettingsStorage = { console.log(descriptions[':pleroma']['Pleroma.Captcha']) commit('updateAdminDescriptions', { descriptions }) }, + + // This action takes draft state, diffs it with live config state and then pushes + // only differences between the two. Difference detection only work up to subkey (third) level. + pushAdminDraft ({ rootState, state, commit, dispatch }) { + // TODO cleanup paths in modifiedPaths + const convert = (value) => { + if (typeof value !== 'object') { + return value + } else if (Array.isArray(value)) { + return value.map(convert) + } else { + return Object.entries(value).map(([k, v]) => ({ tuple: [k, v] })) + } + } + + // Getting all group-keys used in config + const allGroupKeys = flatten( + Object + .entries(state.config) + .map( + ([group, lv1data]) => Object + .keys(lv1data) + .map((key) => ({ group, key })) + ) + ) + + // Only using group-keys where there are changes detected + const changedGroupKeys = allGroupKeys.filter(({ group, key }) => { + return !isEqual(state.config[group][key], state.draft[group][key]) + }) + + // Here we take all changed group-keys and get all changed subkeys + const changed = changedGroupKeys.map(({ group, key }) => { + const config = state.config[group][key] + const draft = state.draft[group][key] + + // We convert group-key value into entries arrays + const eConfig = Object.entries(config) + const eDraft = Object.entries(draft) + + // Then those entries array we diff so only changed subkey entries remain + // We use the diffed array to reconstruct the object and then shove it into convert() + return ({ group, key, value: convert(Object.fromEntries(differenceWith(eDraft, eConfig, isEqual))) }) + }) + + rootState.api.backendInteractor.pushInstanceDBConfig({ + payload: { + configs: changed + } + }) + .then(() => rootState.api.backendInteractor.fetchInstanceDBConfig()) + .then(backendDbConfig => dispatch('setInstanceAdminSettings', { backendDbConfig })) + }, pushAdminSetting ({ rootState, state, commit, dispatch }, { path, value }) { const [group, key, ...rest] = Array.isArray(path) ? path : path.split(/\./g) const clone = {} // not actually cloning the entire thing to avoid excessive writes From df9fe6d261ca554b8f886e45ccf70b44b47e53f5 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 22 Mar 2023 19:23:36 +0200 Subject: [PATCH 2/6] localization strings --- src/i18n/en.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/i18n/en.json b/src/i18n/en.json index f84b5a347..dd78d1482 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -842,6 +842,8 @@ "window_title": "Administration", "wip_notice": "This admin dashboard is experimental and WIP, {adminFeLink}.", "old_ui_link": "old admin UI available here", + "reset_all": "Reset all", + "commit_all": "Save all", "tabs": { "instance": "Instance", "limits": "Limits" From 4c3af5c362574aad4d851990265ebc7252c6f990 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 27 Mar 2023 22:57:50 +0300 Subject: [PATCH 3/6] handle db config disabled case --- .../settings_modal_admin_content.js | 18 ++++++++- .../settings_modal_admin_content.vue | 39 +++++++++++++++++++ src/i18n/en.json | 10 ++++- src/modules/adminSettings.js | 30 +++++++++++++- src/modules/users.js | 6 --- 5 files changed, 93 insertions(+), 10 deletions(-) diff --git a/src/components/settings_modal/settings_modal_admin_content.js b/src/components/settings_modal/settings_modal_admin_content.js index 07d4cf2ee..1c239e595 100644 --- a/src/components/settings_modal/settings_modal_admin_content.js +++ b/src/components/settings_modal/settings_modal_admin_content.js @@ -9,7 +9,7 @@ import { library } from '@fortawesome/fontawesome-svg-core' import { faWrench, faHand, - faFilter, + faLaptopCode, faPaintBrush, faBell, faDownload, @@ -20,7 +20,7 @@ import { library.add( faWrench, faHand, - faFilter, + faLaptopCode, faPaintBrush, faBell, faDownload, @@ -38,6 +38,9 @@ const SettingsModalAdminContent = { LimitsTab }, computed: { + user () { + return this.$store.state.users.currentUser + }, isLoggedIn () { return !!this.$store.state.users.currentUser }, @@ -46,6 +49,17 @@ const SettingsModalAdminContent = { }, bodyLock () { return this.$store.state.interface.settingsModalState === 'visible' + }, + adminDbLoaded () { + return this.$store.state.adminSettings.loaded + }, + noDb () { + return this.$store.state.adminSettings.dbConfigEnabled === false + } + }, + created () { + if (this.user.rights.admin) { + this.$store.dispatch('loadAdminStuff') } }, methods: { diff --git a/src/components/settings_modal/settings_modal_admin_content.vue b/src/components/settings_modal/settings_modal_admin_content.vue index 52c6ddf5f..ae670a909 100644 --- a/src/components/settings_modal/settings_modal_admin_content.vue +++ b/src/components/settings_modal/settings_modal_admin_content.vue @@ -4,9 +4,40 @@ class="settings_tab-switcher" :side-tab-bar="true" :scrollable-tabs="true" + :render-only-focused="true" :body-scroll-lock="bodyLock" >
+
+
+

{{ $t('admin_dash.nodb.heading') }}

+ + + + + +

{{ $t('admin_dash.nodb.text2') }}

+
+
+
+
+
+ +
diff --git a/src/i18n/en.json b/src/i18n/en.json index dd78d1482..86ae7f06d 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -845,8 +845,16 @@ "reset_all": "Reset all", "commit_all": "Save all", "tabs": { + "nodb": "No DB Config", "instance": "Instance", - "limits": "Limits" + "limits": "Limits", + "frontends": "Front-ends" + }, + "nodb": { + "heading": "Database config is disabled", + "text": "You need to change backend config files so that {property} is set to {value}, see more in {documentation}.", + "documentation": "documentation", + "text2": "Most configuration options will be unavailable." }, "captcha": { "native": "Native", diff --git a/src/modules/adminSettings.js b/src/modules/adminSettings.js index 25fb8e501..fef73974c 100644 --- a/src/modules/adminSettings.js +++ b/src/modules/adminSettings.js @@ -1,11 +1,13 @@ import { set, get, cloneDeep, differenceWith, isEqual, flatten } from 'lodash' export const defaultState = { + loaded: false, needsReboot: null, config: null, modifiedPaths: null, descriptions: null, - draft: null + draft: null, + dbConfigEnabled: null } export const newUserFlags = { @@ -17,7 +19,13 @@ const adminSettingsStorage = { ...cloneDeep(defaultState) }, mutations: { + setInstanceAdminNoDbConfig (state) { + state.loaded = false + state.dbConfigEnabled = false + }, updateAdminSettings (state, { config, modifiedPaths }) { + state.loaded = true + state.dbConfigEnabled = true state.config = config state.modifiedPaths = modifiedPaths }, @@ -40,6 +48,26 @@ const adminSettingsStorage = { } }, actions: { + loadAdminStuff ({ state, rootState, dispatch, commit }) { + rootState.api.backendInteractor.fetchInstanceDBConfig() + .then(backendDbConfig => { + if (backendDbConfig.error) { + if (backendDbConfig.error.status === 400) { + backendDbConfig.error.json().then(errorJson => { + if (/configurable_from_database/.test(errorJson.error)) { + commit('setInstanceAdminNoDbConfig') + } + }) + } + } else { + dispatch('setInstanceAdminSettings', { backendDbConfig }) + } + }) + if (state.descriptions === null) { + rootState.api.backendInteractor.fetchInstanceConfigDescriptions() + .then(backendDescriptions => this.$store.dispatch('setInstanceAdminDescriptions', { backendDescriptions })) + } + }, setInstanceAdminSettings ({ state, commit, dispatch }, { backendDbConfig }) { const config = state.config || {} const modifiedPaths = new Set() diff --git a/src/modules/users.js b/src/modules/users.js index 45cba334a..a23f6d7d6 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -564,12 +564,6 @@ const users = { user.domainMutes = [] commit('setCurrentUser', user) commit('setServerSideStorage', user) - if (user.rights.admin) { - store.rootState.api.backendInteractor.fetchInstanceDBConfig() - .then(backendDbConfig => dispatch('setInstanceAdminSettings', { backendDbConfig })) - store.rootState.api.backendInteractor.fetchInstanceConfigDescriptions() - .then(backendDescriptions => dispatch('setInstanceAdminDescriptions', { backendDescriptions })) - } commit('addNewUsers', [user]) dispatch('fetchEmoji') From 3ac67ab7274c199766d026fcf168bd2a3d4e2692 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 27 Mar 2023 23:00:52 +0300 Subject: [PATCH 4/6] fix --- src/modules/adminSettings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/adminSettings.js b/src/modules/adminSettings.js index fef73974c..b8265949f 100644 --- a/src/modules/adminSettings.js +++ b/src/modules/adminSettings.js @@ -65,7 +65,7 @@ const adminSettingsStorage = { }) if (state.descriptions === null) { rootState.api.backendInteractor.fetchInstanceConfigDescriptions() - .then(backendDescriptions => this.$store.dispatch('setInstanceAdminDescriptions', { backendDescriptions })) + .then(backendDescriptions => dispatch('setInstanceAdminDescriptions', { backendDescriptions })) } }, setInstanceAdminSettings ({ state, commit, dispatch }, { backendDbConfig }) { From 7bb28bb23c61e2d648eecf5d59969d32631f78e8 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 29 Mar 2023 00:58:07 +0300 Subject: [PATCH 5/6] frontends tab initial implementation, now you can (re)install frontends! yay! --- src/App.scss | 22 +++++- .../admin_tabs/frontends_tab.js | 58 +++++++++++++++ .../admin_tabs/frontends_tab.scss | 13 ++++ .../admin_tabs/frontends_tab.vue | 72 +++++++++++++++++++ .../settings_modal/settings_modal.scss | 1 - .../settings_modal_admin_content.js | 8 +-- src/i18n/en.json | 8 +++ src/modules/adminSettings.js | 15 ++++ src/services/api/api.service.js | 42 ++++++++++- 9 files changed, 229 insertions(+), 10 deletions(-) create mode 100644 src/components/settings_modal/admin_tabs/frontends_tab.js create mode 100644 src/components/settings_modal/admin_tabs/frontends_tab.scss create mode 100644 src/components/settings_modal/admin_tabs/frontends_tab.vue diff --git a/src/App.scss b/src/App.scss index 3f352e8d9..149d640ff 100644 --- a/src/App.scss +++ b/src/App.scss @@ -645,6 +645,19 @@ option { } } +.cards-list { + display: grid; + grid-auto-flow: row dense; + grid-template-columns: 1fr 1fr; + + li { + border: 1px solid var(--border); + border-radius: var(--inputRadius); + padding: 0.5em; + margin: 0.25em; + } +} + .btn-block { display: block; width: 100%; @@ -655,16 +668,19 @@ option { display: inline-flex; vertical-align: middle; - button { + button, + .button-dropdown { position: relative; flex: 1 1 auto; - &:not(:last-child) { + &:not(:last-child), + &:not(:last-child) .button-default { border-top-right-radius: 0; border-bottom-right-radius: 0; } - &:not(:first-child) { + &:not(:first-child), + &:not(:first-child) .button-default { border-top-left-radius: 0; border-bottom-left-radius: 0; } diff --git a/src/components/settings_modal/admin_tabs/frontends_tab.js b/src/components/settings_modal/admin_tabs/frontends_tab.js new file mode 100644 index 000000000..a5d33cbe3 --- /dev/null +++ b/src/components/settings_modal/admin_tabs/frontends_tab.js @@ -0,0 +1,58 @@ +import BooleanSetting from '../helpers/boolean_setting.vue' +import ChoiceSetting from '../helpers/choice_setting.vue' +import IntegerSetting from '../helpers/integer_setting.vue' +import StringSetting from '../helpers/string_setting.vue' +import GroupSetting from '../helpers/group_setting.vue' +import Popover from 'src/components/popover/popover.vue' + +import SharedComputedObject from '../helpers/shared_computed_object.js' +import { library } from '@fortawesome/fontawesome-svg-core' +import { + faGlobe +} from '@fortawesome/free-solid-svg-icons' + +library.add( + faGlobe +) + +const FrontendsTab = { + provide () { + return { + defaultDraftMode: true, + defaultSource: 'admin' + } + }, + components: { + BooleanSetting, + ChoiceSetting, + IntegerSetting, + StringSetting, + GroupSetting, + Popover + }, + created () { + if (this.user.rights.admin) { + this.$store.dispatch('loadFrontendsStuff') + } + }, + computed: { + frontends () { + return this.$store.state.adminSettings.frontends + }, + ...SharedComputedObject() + }, + methods: { + update (frontend, suggestRef) { + const ref = suggestRef || frontend.refs[0] + const { name } = frontend + const payload = { name, ref } + + this.$store.state.api.backendInteractor.installFrontend({ payload }) + .then((externalUser) => { + this.$store.dispatch('loadFrontendsStuff') + }) + } + } +} + +export default FrontendsTab diff --git a/src/components/settings_modal/admin_tabs/frontends_tab.scss b/src/components/settings_modal/admin_tabs/frontends_tab.scss new file mode 100644 index 000000000..1e1881ff8 --- /dev/null +++ b/src/components/settings_modal/admin_tabs/frontends_tab.scss @@ -0,0 +1,13 @@ +.frontends-tab { + .cards-list { + padding: 0; + } + + dd { + text-overflow: ellipsis; + word-wrap: nowrap; + white-space: nowrap; + overflow-x: hidden; + max-width: 80%; + } +} diff --git a/src/components/settings_modal/admin_tabs/frontends_tab.vue b/src/components/settings_modal/admin_tabs/frontends_tab.vue new file mode 100644 index 000000000..48649dfba --- /dev/null +++ b/src/components/settings_modal/admin_tabs/frontends_tab.vue @@ -0,0 +1,72 @@ + + + + + diff --git a/src/components/settings_modal/settings_modal.scss b/src/components/settings_modal/settings_modal.scss index 4cb506f93..98de736bf 100644 --- a/src/components/settings_modal/settings_modal.scss +++ b/src/components/settings_modal/settings_modal.scss @@ -43,7 +43,6 @@ .btn { min-height: 2em; - min-width: 10em; padding: 0 2em; } } diff --git a/src/components/settings_modal/settings_modal_admin_content.js b/src/components/settings_modal/settings_modal_admin_content.js index 1c239e595..b7c0de576 100644 --- a/src/components/settings_modal/settings_modal_admin_content.js +++ b/src/components/settings_modal/settings_modal_admin_content.js @@ -1,9 +1,8 @@ import TabSwitcher from 'src/components/tab_switcher/tab_switcher.jsx' -import DataImportExportTab from './tabs/data_import_export_tab.vue' -import MutesAndBlocksTab from './tabs/mutes_and_blocks_tab.vue' import InstanceTab from './admin_tabs/instance_tab.vue' import LimitsTab from './admin_tabs/limits_tab.vue' +import FrontendsTab from './admin_tabs/frontends_tab.vue' import { library } from '@fortawesome/fontawesome-svg-core' import { @@ -32,10 +31,9 @@ const SettingsModalAdminContent = { components: { TabSwitcher, - DataImportExportTab, - MutesAndBlocksTab, InstanceTab, - LimitsTab + LimitsTab, + FrontendsTab }, computed: { user () { diff --git a/src/i18n/en.json b/src/i18n/en.json index 86ae7f06d..ede5d4942 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -873,6 +873,14 @@ "users": "User profile limits", "profile_fields": "Profile fields limits", "user_uploads": "Profile media limits" + }, + "frontend": { + "repository": "Repository link", + "versions": "Available versions", + "build_url": "Build URL", + "reinstall": "Reinstall", + "install": "Install", + "install_version": "Install version {version}" } }, "time": { diff --git a/src/modules/adminSettings.js b/src/modules/adminSettings.js index b8265949f..cad9c0ca4 100644 --- a/src/modules/adminSettings.js +++ b/src/modules/adminSettings.js @@ -1,6 +1,7 @@ import { set, get, cloneDeep, differenceWith, isEqual, flatten } from 'lodash' export const defaultState = { + frontends: [], loaded: false, needsReboot: null, config: null, @@ -23,6 +24,16 @@ const adminSettingsStorage = { state.loaded = false state.dbConfigEnabled = false }, + setAvailableFrontends (state, { frontends }) { + state.frontends = frontends.map(f => { + if (f.name === 'pleroma-fe') { + f.refs = ['master', 'develop'] + } else { + f.refs = [f.ref] + } + return f + }) + }, updateAdminSettings (state, { config, modifiedPaths }) { state.loaded = true state.dbConfigEnabled = true @@ -48,6 +59,10 @@ const adminSettingsStorage = { } }, actions: { + loadFrontendsStuff ({ state, rootState, dispatch, commit }) { + rootState.api.backendInteractor.fetchAvailableFrontends() + .then(frontends => commit('setAvailableFrontends', { frontends })) + }, loadAdminStuff ({ state, rootState, dispatch, commit }) { rootState.api.backendInteractor.fetchInstanceDBConfig() .then(backendDbConfig => { diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 073f40a34..56e7de714 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -110,6 +110,8 @@ const PLEROMA_DELETE_ANNOUNCEMENT_URL = id => `/api/v1/pleroma/admin/announcemen const PLEROMA_ADMIN_CONFIG_URL = '/api/pleroma/admin/config' const PLEROMA_ADMIN_DESCRIPTIONS_URL = '/api/pleroma/admin/config/descriptions' +const PLEROMA_ADMIN_FRONTENDS_URL = '/api/pleroma/admin/frontends' +const PLEROMA_ADMIN_FRONTENDS_INSTALL_URL = '/api/pleroma/admin/frontends/install' const oldfetch = window.fetch @@ -1693,6 +1695,21 @@ const fetchInstanceConfigDescriptions = ({ credentials }) => { }) } +const fetchAvailableFrontends = ({ credentials }) => { + return fetch(PLEROMA_ADMIN_FRONTENDS_URL, { + headers: authHeaders(credentials) + }) + .then((response) => { + if (response.ok) { + return response.json() + } else { + return { + error: response + } + } + }) +} + const pushInstanceDBConfig = ({ credentials, payload }) => { return fetch(PLEROMA_ADMIN_CONFIG_URL, { headers: { @@ -1714,6 +1731,27 @@ const pushInstanceDBConfig = ({ credentials, payload }) => { }) } +const installFrontend = ({ credentials, payload }) => { + return fetch(PLEROMA_ADMIN_FRONTENDS_INSTALL_URL, { + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + ...authHeaders(credentials) + }, + method: 'POST', + body: JSON.stringify(payload) + }) + .then((response) => { + if (response.ok) { + return response.json() + } else { + return { + error: response + } + } + }) +} + const apiService = { verifyCredentials, fetchTimeline, @@ -1830,7 +1868,9 @@ const apiService = { adminFetchAnnouncements, fetchInstanceDBConfig, fetchInstanceConfigDescriptions, - pushInstanceDBConfig + fetchAvailableFrontends, + pushInstanceDBConfig, + installFrontend } export default apiService From ac75d051b720da2c47393de6b35663afe50d37cc Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 29 Mar 2023 23:26:57 +0300 Subject: [PATCH 6/6] better frontends tab, now you can set default frontend --- src/App.scss | 1 + .../admin_tabs/frontends_tab.js | 6 + .../admin_tabs/frontends_tab.scss | 2 +- .../admin_tabs/frontends_tab.vue | 208 +++++++++++++----- .../settings_modal/helpers/group_setting.js | 1 - .../settings_modal/helpers/setting.js | 4 +- .../helpers/shared_computed_object.js | 3 + .../settings_modal/settings_modal.scss | 3 + .../settings_modal_admin_content.js | 3 + .../settings_modal_admin_content.vue | 1 + src/i18n/en.json | 11 +- 11 files changed, 179 insertions(+), 64 deletions(-) diff --git a/src/App.scss b/src/App.scss index 149d640ff..ef68ac50b 100644 --- a/src/App.scss +++ b/src/App.scss @@ -646,6 +646,7 @@ option { } .cards-list { + list-style: none; display: grid; grid-auto-flow: row dense; grid-template-columns: 1fr 1fr; diff --git a/src/components/settings_modal/admin_tabs/frontends_tab.js b/src/components/settings_modal/admin_tabs/frontends_tab.js index a5d33cbe3..a2c27c2a4 100644 --- a/src/components/settings_modal/admin_tabs/frontends_tab.js +++ b/src/components/settings_modal/admin_tabs/frontends_tab.js @@ -51,6 +51,12 @@ const FrontendsTab = { .then((externalUser) => { this.$store.dispatch('loadFrontendsStuff') }) + }, + setDefault (frontend, suggestRef) { + const ref = suggestRef || frontend.refs[0] + const { name } = frontend + + this.$store.commit('updateAdminDraft', { path: [':pleroma', ':frontends', ':primary'], value: { name, ref } }) } } } diff --git a/src/components/settings_modal/admin_tabs/frontends_tab.scss b/src/components/settings_modal/admin_tabs/frontends_tab.scss index 1e1881ff8..e3e04bc6f 100644 --- a/src/components/settings_modal/admin_tabs/frontends_tab.scss +++ b/src/components/settings_modal/admin_tabs/frontends_tab.scss @@ -8,6 +8,6 @@ word-wrap: nowrap; white-space: nowrap; overflow-x: hidden; - max-width: 80%; + max-width: 10em; } } diff --git a/src/components/settings_modal/admin_tabs/frontends_tab.vue b/src/components/settings_modal/admin_tabs/frontends_tab.vue index 48649dfba..71bbfa69e 100644 --- a/src/components/settings_modal/admin_tabs/frontends_tab.vue +++ b/src/components/settings_modal/admin_tabs/frontends_tab.vue @@ -2,67 +2,157 @@

{{ $t('admin_dash.tabs.frontends') }}

-
    -
  • - {{ frontend.name }} -
    -
    {{ $t('admin_dash.frontend.repository') }}
    -
    {{ frontend.git }}
    -
    {{ $t('admin_dash.frontend.versions') }}
    -
    {{ frontend.refs }}
    -
    {{ $t('admin_dash.frontend.build_url') }}
    -
    {{ frontend.build_url }}
    -
    -
    - - - - - - - -
    +

    {{ $t('admin_dash.frontend.wip_notice') }}

    +
      +
    • +

      {{ $t('admin_dash.frontend.default_frontend') }}

      +

      {{ $t('admin_dash.frontend.default_frontend_tip') }}

      +

      {{ $t('admin_dash.frontend.default_frontend_tip2') }}

      +
    • +
    • + + NAME + +
    • +
    • + + REF + +
    • +
    • +
    +
    +

    {{ $t('admin_dash.frontend.available_frontends') }}

    +
      +
    • + {{ frontend.name }} + {{ ' ' }} + + + + + + +
      +
      {{ $t('admin_dash.frontend.repository') }}
      +
      {{ frontend.git }}
      + +
      {{ $t('admin_dash.frontend.build_url') }}
      +
      {{ frontend.build_url }}
      +
      +
      + + + + + + + + + + {{ ' ' }} + + + + + +
      +
    • +
    +
diff --git a/src/components/settings_modal/helpers/group_setting.js b/src/components/settings_modal/helpers/group_setting.js index 12a490007..23a2a2025 100644 --- a/src/components/settings_modal/helpers/group_setting.js +++ b/src/components/settings_modal/helpers/group_setting.js @@ -7,7 +7,6 @@ export default { computed: { ...Setting.computed, isDirty () { - console.log(this.state, this.draft) return !isEqual(this.state, this.draft) } } diff --git a/src/components/settings_modal/helpers/setting.js b/src/components/settings_modal/helpers/setting.js index d2e1a6f43..4f0be448c 100644 --- a/src/components/settings_modal/helpers/setting.js +++ b/src/components/settings_modal/helpers/setting.js @@ -61,7 +61,7 @@ export default { // TODO allow passing shared draft object? get () { if (this.realSource === 'admin') { - return get(this.$store.state.adminSettings.draft, this.path) + return get(this.$store.state.adminSettings.draft, this.canonPath) } else { return this.localDraft } @@ -75,7 +75,7 @@ export default { } }, state () { - const value = get(this.configSource, this.path) + const value = get(this.configSource, this.canonPath) if (value === undefined) { return this.defaultState } else { diff --git a/src/components/settings_modal/helpers/shared_computed_object.js b/src/components/settings_modal/helpers/shared_computed_object.js index d02db542a..bb3d36ac4 100644 --- a/src/components/settings_modal/helpers/shared_computed_object.js +++ b/src/components/settings_modal/helpers/shared_computed_object.js @@ -10,6 +10,9 @@ const SharedComputedObject = () => ({ }, adminConfig () { return this.$store.state.adminSettings.config + }, + adminDraft () { + return this.$store.state.adminSettings.draft } }) diff --git a/src/components/settings_modal/settings_modal.scss b/src/components/settings_modal/settings_modal.scss index 98de736bf..49ef83e01 100644 --- a/src/components/settings_modal/settings_modal.scss +++ b/src/components/settings_modal/settings_modal.scss @@ -43,6 +43,9 @@ .btn { min-height: 2em; + } + + .btn:not(.dropdown-button) { padding: 0 2em; } } diff --git a/src/components/settings_modal/settings_modal_admin_content.js b/src/components/settings_modal/settings_modal_admin_content.js index b7c0de576..f94721ec7 100644 --- a/src/components/settings_modal/settings_modal_admin_content.js +++ b/src/components/settings_modal/settings_modal_admin_content.js @@ -51,6 +51,9 @@ const SettingsModalAdminContent = { adminDbLoaded () { return this.$store.state.adminSettings.loaded }, + adminDescriptionsLoaded () { + return this.$store.state.adminSettings.descriptions !== null + }, noDb () { return this.$store.state.adminSettings.dbConfigEnabled === false } diff --git a/src/components/settings_modal/settings_modal_admin_content.vue b/src/components/settings_modal/settings_modal_admin_content.vue index ae670a909..a7a2ac9ad 100644 --- a/src/components/settings_modal/settings_modal_admin_content.vue +++ b/src/components/settings_modal/settings_modal_admin_content.vue @@ -1,5 +1,6 @@