From 4d23d31fecf480abfccc4db3ac79c6640078dc3b Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 14 Mar 2023 21:50:43 +0200 Subject: initial admin settings prototype (WIP) --- .../settings_modal/settings_modal_admin_content.vue | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/components/settings_modal/settings_modal_admin_content.vue (limited to 'src/components/settings_modal/settings_modal_admin_content.vue') diff --git a/src/components/settings_modal/settings_modal_admin_content.vue b/src/components/settings_modal/settings_modal_admin_content.vue new file mode 100644 index 00000000..9873b127 --- /dev/null +++ b/src/components/settings_modal/settings_modal_admin_content.vue @@ -0,0 +1,21 @@ + + + + + -- cgit v1.2.3-70-g09d2 From 332ad77e3579d2b512ba236b3f2c94ad8875864d Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 19 Mar 2023 21:27:07 +0200 Subject: limits tab, backend descriptions --- .../settings_modal/admin_tabs/instance_tab.vue | 103 +++++++++++--- .../settings_modal/admin_tabs/limits_tab.js | 29 ++++ .../settings_modal/admin_tabs/limits_tab.vue | 152 +++++++++++++++++++++ .../settings_modal/helpers/boolean_setting.vue | 13 +- .../settings_modal/helpers/integer_setting.vue | 13 +- src/components/settings_modal/helpers/setting.js | 10 ++ .../settings_modal/helpers/string_setting.vue | 13 +- src/components/settings_modal/settings_modal.scss | 6 + .../settings_modal/settings_modal_admin_content.js | 4 +- .../settings_modal_admin_content.vue | 9 +- src/modules/adminSettings.js | 24 +++- src/modules/users.js | 2 + src/services/api/api.service.js | 17 +++ 13 files changed, 370 insertions(+), 25 deletions(-) create mode 100644 src/components/settings_modal/admin_tabs/limits_tab.js create mode 100644 src/components/settings_modal/admin_tabs/limits_tab.vue (limited to 'src/components/settings_modal/settings_modal_admin_content.vue') diff --git a/src/components/settings_modal/admin_tabs/instance_tab.vue b/src/components/settings_modal/admin_tabs/instance_tab.vue index 18ba6127..ad271293 100644 --- a/src/components/settings_modal/admin_tabs/instance_tab.vue +++ b/src/components/settings_modal/admin_tabs/instance_tab.vue @@ -12,6 +12,15 @@ NAME +
  • + + ADMIN EMAIL + +
  • - - POST LIMIT - + SHORT DESCRIPTION + +
  • +
  • + + INSTANCE THUMBNAIL + +
  • +
  • + + BACKGROUND IMAGE + +
  • +
  • + + PUBLIC + +
  • + + +
    +

    {{ $t('admin_dash.registrations') }}

    +
      +
    • + + REGISTRATIONS OPEN + +
        +
      • + + INVITES ENABLED + +
      • +
      +
    • +
    • + + ACTIVATION REQUIRED + +
    • +
    • + + APPROVAL REQUIRED +
    @@ -36,17 +117,3 @@ - - diff --git a/src/components/settings_modal/admin_tabs/limits_tab.js b/src/components/settings_modal/admin_tabs/limits_tab.js new file mode 100644 index 00000000..684739c3 --- /dev/null +++ b/src/components/settings_modal/admin_tabs/limits_tab.js @@ -0,0 +1,29 @@ +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 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 LimitsTab = { + data () {}, + components: { + BooleanSetting, + ChoiceSetting, + IntegerSetting, + StringSetting + }, + computed: { + ...SharedComputedObject() + } +} + +export default LimitsTab diff --git a/src/components/settings_modal/admin_tabs/limits_tab.vue b/src/components/settings_modal/admin_tabs/limits_tab.vue new file mode 100644 index 00000000..3f07c554 --- /dev/null +++ b/src/components/settings_modal/admin_tabs/limits_tab.vue @@ -0,0 +1,152 @@ + + + diff --git a/src/components/settings_modal/helpers/boolean_setting.vue b/src/components/settings_modal/helpers/boolean_setting.vue index 7e05fe85..aedbf23e 100644 --- a/src/components/settings_modal/helpers/boolean_setting.vue +++ b/src/components/settings_modal/helpers/boolean_setting.vue @@ -12,7 +12,12 @@ v-if="!!$slots.default" class="label" > - + + {{ ' ' }} +

    + {{ backendDescriptionDescription + ' ' }} +

    diff --git a/src/components/settings_modal/helpers/integer_setting.vue b/src/components/settings_modal/helpers/integer_setting.vue index e900b87c..e935dfb0 100644 --- a/src/components/settings_modal/helpers/integer_setting.vue +++ b/src/components/settings_modal/helpers/integer_setting.vue @@ -4,7 +4,12 @@ class="IntegerSetting" > +

    + {{ backendDescriptionDescription + ' ' }} +

    diff --git a/src/components/settings_modal/helpers/setting.js b/src/components/settings_modal/helpers/setting.js index 0971b919..f270216f 100644 --- a/src/components/settings_modal/helpers/setting.js +++ b/src/components/settings_modal/helpers/setting.js @@ -59,6 +59,16 @@ export default { return value } }, + backendDescription () { + console.log(get(this.$store.state.adminSettings.descriptions, this.path)) + return get(this.$store.state.adminSettings.descriptions, this.path) + }, + backendDescriptionLabel () { + return this.backendDescription.label + }, + backendDescriptionDescription () { + return this.backendDescription.description + }, shouldBeDisabled () { const parentValue = this.parentPath !== undefined ? get(this.configSource, this.parentPath) : null return this.disabled || (parentValue !== null ? (this.parentInvert ? parentValue : !parentValue) : false) diff --git a/src/components/settings_modal/helpers/string_setting.vue b/src/components/settings_modal/helpers/string_setting.vue index 0a71aeab..91a4afa4 100644 --- a/src/components/settings_modal/helpers/string_setting.vue +++ b/src/components/settings_modal/helpers/string_setting.vue @@ -4,7 +4,12 @@ class="StringSetting" > +

    + {{ backendDescriptionDescription + ' ' }} +

    diff --git a/src/components/settings_modal/settings_modal.scss b/src/components/settings_modal/settings_modal.scss index f5861229..4cce6099 100644 --- a/src/components/settings_modal/settings_modal.scss +++ b/src/components/settings_modal/settings_modal.scss @@ -17,6 +17,12 @@ } } + .setting-description { + margin-top: 0.2em; + margin-bottom: 2em; + font-size: 70%; + } + .settings-modal-panel { overflow: hidden; transition: transform; diff --git a/src/components/settings_modal/settings_modal_admin_content.js b/src/components/settings_modal/settings_modal_admin_content.js index 88ba1755..c6c8837f 100644 --- a/src/components/settings_modal/settings_modal_admin_content.js +++ b/src/components/settings_modal/settings_modal_admin_content.js @@ -3,6 +3,7 @@ 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 { library } from '@fortawesome/fontawesome-svg-core' import { @@ -33,7 +34,8 @@ const SettingsModalAdminContent = { DataImportExportTab, MutesAndBlocksTab, - InstanceTab + InstanceTab, + LimitsTab }, computed: { isLoggedIn () { diff --git a/src/components/settings_modal/settings_modal_admin_content.vue b/src/components/settings_modal/settings_modal_admin_content.vue index 9873b127..16b55828 100644 --- a/src/components/settings_modal/settings_modal_admin_content.vue +++ b/src/components/settings_modal/settings_modal_admin_content.vue @@ -7,12 +7,19 @@ :body-scroll-lock="bodyLock" >
    +
    + +
    diff --git a/src/modules/adminSettings.js b/src/modules/adminSettings.js index d1df67d4..44a4d409 100644 --- a/src/modules/adminSettings.js +++ b/src/modules/adminSettings.js @@ -3,7 +3,8 @@ import { set, cloneDeep } from 'lodash' export const defaultState = { needsReboot: null, config: null, - modifiedPaths: null + modifiedPaths: null, + descriptions: null } export const newUserFlags = { @@ -18,6 +19,9 @@ const adminSettingsStorage = { updateAdminSettings (state, { config, modifiedPaths }) { state.config = config state.modifiedPaths = modifiedPaths + }, + updateAdminDescriptions (state, { descriptions }) { + state.descriptions = descriptions } }, actions: { @@ -40,8 +44,25 @@ const adminSettingsStorage = { } set(config, path, convert(c.value)) }) + console.log(config[':pleroma'][':welcome']) commit('updateAdminSettings', { config, modifiedPaths }) }, + setInstanceAdminDescriptions ({ state, commit, dispatch }, { backendDescriptions }) { + const convert = ({ children, description, label, key = '', group, suggestions }, path, acc) => { + const newPath = group ? group + '.' + key : key + const obj = { description, label, suggestions } + if (Array.isArray(children)) { + children.forEach(c => { + convert(c, '.' + newPath, obj) + }) + } + set(acc, newPath, obj) + } + + const descriptions = {} + backendDescriptions.forEach(d => convert(d, '', descriptions)) + commit('updateAdminDescriptions', { descriptions }) + }, pushAdminSetting ({ rootState, state, commit, dispatch }, { path, value }) { const [group, key, ...rest] = path.split(/\./g) const clone = {} // not actually cloning the entire thing to avoid excessive writes @@ -71,7 +92,6 @@ const adminSettingsStorage = { .then(backendDbConfig => dispatch('setInstanceAdminSettings', { backendDbConfig })) }, resetAdminSetting ({ rootState, state, commit, dispatch }, { path }) { - console.log('ASS') const [group, key, subkey] = path.split(/\./g) state.modifiedPaths.delete(path) diff --git a/src/modules/users.js b/src/modules/users.js index 12e582f4..45cba334 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -567,6 +567,8 @@ const users = { 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]) diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 71ba1dec..073f40a3 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -109,6 +109,7 @@ const PLEROMA_EDIT_ANNOUNCEMENT_URL = id => `/api/v1/pleroma/admin/announcements const PLEROMA_DELETE_ANNOUNCEMENT_URL = id => `/api/v1/pleroma/admin/announcements/${id}` const PLEROMA_ADMIN_CONFIG_URL = '/api/pleroma/admin/config' +const PLEROMA_ADMIN_DESCRIPTIONS_URL = '/api/pleroma/admin/config/descriptions' const oldfetch = window.fetch @@ -1677,6 +1678,21 @@ const fetchInstanceDBConfig = ({ credentials }) => { }) } +const fetchInstanceConfigDescriptions = ({ credentials }) => { + return fetch(PLEROMA_ADMIN_DESCRIPTIONS_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: { @@ -1813,6 +1829,7 @@ const apiService = { deleteAnnouncement, adminFetchAnnouncements, fetchInstanceDBConfig, + fetchInstanceConfigDescriptions, pushInstanceDBConfig } -- cgit v1.2.3-70-g09d2 From 9a97e0d196c879e41dcb8bda8bd8128a039bacdc Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 21 Mar 2023 10:26:25 +0200 Subject: modal update, initial localization --- .../settings_modal/admin_tabs/instance_tab.vue | 10 ++++---- .../settings_modal/admin_tabs/limits_tab.vue | 24 ++++++++++--------- src/components/settings_modal/settings_modal.vue | 15 +++++++++++- .../settings_modal/settings_modal_admin_content.js | 4 ++-- .../settings_modal_admin_content.vue | 6 ++--- src/i18n/en.json | 27 ++++++++++++++++++++++ 6 files changed, 64 insertions(+), 22 deletions(-) (limited to 'src/components/settings_modal/settings_modal_admin_content.vue') diff --git a/src/components/settings_modal/admin_tabs/instance_tab.vue b/src/components/settings_modal/admin_tabs/instance_tab.vue index ff784287..411982cc 100644 --- a/src/components/settings_modal/admin_tabs/instance_tab.vue +++ b/src/components/settings_modal/admin_tabs/instance_tab.vue @@ -1,7 +1,7 @@ diff --git a/src/i18n/en.json b/src/i18n/en.json index dd78d148..86ae7f06 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 25fb8e50..fef73974 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 45cba334..a23f6d7d 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') -- cgit v1.2.3-70-g09d2 From ac75d051b720da2c47393de6b35663afe50d37cc Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 29 Mar 2023 23:26:57 +0300 Subject: better frontends tab, now you can set default frontend --- src/App.scss | 1 + .../settings_modal/admin_tabs/frontends_tab.js | 6 + .../settings_modal/admin_tabs/frontends_tab.scss | 2 +- .../settings_modal/admin_tabs/frontends_tab.vue | 204 +++++++++++++++------ .../settings_modal/helpers/group_setting.js | 1 - src/components/settings_modal/helpers/setting.js | 4 +- .../helpers/shared_computed_object.js | 3 + src/components/settings_modal/settings_modal.scss | 3 + .../settings_modal/settings_modal_admin_content.js | 3 + .../settings_modal_admin_content.vue | 1 + src/i18n/en.json | 11 +- 11 files changed, 177 insertions(+), 62 deletions(-) (limited to 'src/components/settings_modal/settings_modal_admin_content.vue') diff --git a/src/App.scss b/src/App.scss index 149d640f..ef68ac50 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 a5d33cbe..a2c27c2a 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 1e1881ff..e3e04bc6 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 48649dfb..71bbfa69 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 }} + {{ ' ' }} + + + - + + + + + {{ ' ' }} + + + + + +
      +
    • +
    +
    diff --git a/src/components/settings_modal/helpers/group_setting.js b/src/components/settings_modal/helpers/group_setting.js index 12a49000..23a2a202 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 d2e1a6f4..4f0be448 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 d02db542..bb3d36ac 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 98de736b..49ef83e0 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 b7c0de57..f94721ec 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 ae670a90..a7a2ac9a 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 @@