Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

settings: Refactor appstore and user management code #43769

Merged
merged 4 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(settings): Adjust frontend of appstore and user management to use…
… initial state

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux authored and skjnldsv committed Feb 23, 2024
commit a522d1b5eae986cad7912c3dce40c68ac11a7535
7 changes: 0 additions & 7 deletions apps/settings/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,5 @@
<script>
export default {
name: 'App',
beforeMount() {
// importing server data into the store
const serverDataElmt = document.getElementById('serverData')
if (serverDataElmt !== null) {
this.$store.commit('setServerData', JSON.parse(document.getElementById('serverData').dataset.server))
}
},
}
</script>
2 changes: 1 addition & 1 deletion apps/settings/src/components/AppList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export default {
})
},
bundles() {
return this.$store.getters.getServerData.bundles.filter(bundle => this.bundleApps(bundle.id).length > 0)
return this.$store.getters.getAppBundles.filter(bundle => this.bundleApps(bundle.id).length > 0)
},
bundleApps() {
return function(bundle) {
Expand Down
7 changes: 6 additions & 1 deletion apps/settings/src/store/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ import api from './api.js'
import Vue from 'vue'
import { generateUrl } from '@nextcloud/router'
import { showError, showInfo } from '@nextcloud/dialogs'
import { loadState } from '@nextcloud/initial-state'

const state = {
apps: [],
bundles: loadState('settings', 'appstoreBundles', []),
categories: [],
updateCount: 0,
updateCount: loadState('settings', 'appstoreUpdateCount', 0),
loading: {},
loadingList: false,
gettingCategoriesPromise: null,
Expand Down Expand Up @@ -164,6 +166,9 @@ const getters = {
getAllApps(state) {
return state.apps
},
getAppBundles(state) {
return state.bundles
},
getUpdateCount(state) {
return state.updateCount
},
Expand Down
2 changes: 1 addition & 1 deletion apps/settings/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import Vue from 'vue'
import Vuex, { Store } from 'vuex'
import users from './users.js'
import apps from './apps.js'
import settings from './settings.js'
import settings from './users-settings.js'
import oc from './oc.js'
import { showError } from '@nextcloud/dialogs'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
*
*/

import { loadState } from '@nextcloud/initial-state'

const state = {
serverData: {},
serverData: loadState('settings', 'usersSettings', {}),
}
const mutations = {
setServerData(state, data) {
Expand Down
2 changes: 1 addition & 1 deletion apps/settings/src/store/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import axios from '@nextcloud/axios'
import { generateOcsUrl } from '@nextcloud/router'
import { getCapabilities } from '@nextcloud/capabilities'
import logger from '../logger.js'
import { parseFileSize } from "@nextcloud/files"
import { parseFileSize } from '@nextcloud/files'

const orderGroups = function(groups, orderBy) {
/* const SORT_USERCOUNT = 1;
Expand Down
15 changes: 9 additions & 6 deletions apps/settings/src/views/Apps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<NcAppNavigationSpacer />

<!-- App store categories -->
<template v-if="settings.appstoreEnabled">
<template v-if="appstoreEnabled">
<NcAppNavigationItem id="app-category-featured"
:to="{ name: 'apps-category', params: { category: 'featured' } }"
icon="icon-favorite"
Expand Down Expand Up @@ -165,9 +165,13 @@ import AppScore from '../components/AppList/AppScore.vue'
import Markdown from '../components/Markdown.vue'

import { APPS_SECTION_ENUM } from './../constants/AppsConstants.js'
import { loadState } from '@nextcloud/initial-state'

Vue.use(VueLocalStorage)

const appstoreEnabled = loadState('settings', 'appstoreEnabled')
const developerDocumentation = loadState('settings', 'appstoreDeveloperDocs')

export default {
name: 'Apps',
APPS_SECTION_ENUM,
Expand Down Expand Up @@ -208,6 +212,9 @@ export default {
},

computed: {
appstoreEnabled() {
return appstoreEnabled
},
pageHeading() {
if (this.$options.APPS_SECTION_ENUM[this.category]) {
return this.$options.APPS_SECTION_ENUM[this.category]
Expand All @@ -233,9 +240,6 @@ export default {
updateCount() {
return this.$store.getters.getUpdateCount
},
settings() {
return this.$store.getters.getServerData
},

hasRating() {
return this.app.appstoreData && this.app.appstoreData.ratingNumOverall > 5
Expand Down Expand Up @@ -302,7 +306,6 @@ export default {
this.$store.dispatch('getCategories', { shouldRefetchCategories: true })
this.$store.dispatch('getAllApps')
this.$store.dispatch('getGroups', { offset: 0, limit: 5 })
this.$store.commit('setUpdateCount', this.$store.getters.getServerData.updateCount)
},

mounted() {
Expand All @@ -329,7 +332,7 @@ export default {
})
},
openDeveloperDocumentation() {
window.open(this.settings.developerDocumentation)
window.open(developerDocumentation)
},
},
}
Expand Down