-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix broken app groups display #48504
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
Changes from 4 commits
258cb1a
1abd28d
b1e95e5
e617917
377f435
f69ab9d
b31cf10
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,16 +29,15 @@ | |
| <span>{{ t('settings', 'Limit app usage to groups') }}</span> | ||
| </label> | ||
| <NcSelect v-if="isLimitedToGroups(app)" | ||
| v-model="appGroups" | ||
| input-id="limitToGroups" | ||
| :options="groups" | ||
| :value="appGroups" | ||
| :options="appGroupsOptions" | ||
| :limit="5" | ||
| label="name" | ||
| :multiple="true" | ||
| :loading="loadingGroups" | ||
| :close-on-select="false" | ||
| @option:selected="addGroupLimitation" | ||
| @option:deselected="removeGroupLimitation" | ||
| @search="asyncFindGroup"> | ||
| @search="searchGroup"> | ||
| <span slot="noResult">{{ t('settings', 'No results') }}</span> | ||
| </NcSelect> | ||
| </div> | ||
|
|
@@ -188,6 +187,12 @@ import AppManagement from '../../mixins/AppManagement.js' | |
| import { mdiBug, mdiFeatureSearch, mdiStar, mdiTextBox, mdiTooltipQuestion } from '@mdi/js' | ||
| import { useAppsStore } from '../../store/apps-store' | ||
|
|
||
| import sortedUniq from 'lodash/sortedUniq.js' | ||
| import uniq from 'lodash/uniq.js' | ||
| import debounce from 'lodash/debounce.js' | ||
| import axios from '@nextcloud/axios' | ||
| import { generateOcsUrl } from '@nextcloud/router' | ||
|
|
||
| export default { | ||
| name: 'AppDetailsTab', | ||
|
|
||
|
|
@@ -224,6 +229,10 @@ export default { | |
| data() { | ||
| return { | ||
| groupCheckedAppsData: false, | ||
| groups: [], | ||
| appGroupsOptions: [], | ||
| appGroupsSelected: [], | ||
| loadingGroups: false, | ||
| } | ||
| }, | ||
|
|
||
|
|
@@ -319,19 +328,49 @@ export default { | |
| rateAppUrl() { | ||
| return `${this.appstoreUrl}#comments` | ||
| }, | ||
| appGroups() { | ||
| return this.app.groups.map(group => { return { id: group, name: group } }) | ||
| }, | ||
| groups() { | ||
| return this.$store.getters.getGroups | ||
| .filter(group => group.id !== 'disabled') | ||
| .sort((a, b) => a.name.localeCompare(b.name)) | ||
| appGroups: { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using a computed with setter that dispatches a store event is not really recommended. This should rather be handled in an event handler. |
||
| get() { | ||
| return this.appGroupsSelected | ||
| }, | ||
| set(val) { | ||
| this.appGroupsOptions = this.groups.filter((group) => !val.includes(group)) | ||
| this.appGroupsSelected = val | ||
| this.$store.dispatch('enableApp', { appId: this.app.id, groups: val }) | ||
| }, | ||
| }, | ||
| }, | ||
| mounted() { | ||
| if (this.app.groups.length > 0) { | ||
| this.groupCheckedAppsData = true | ||
| this.appGroupsSelected = this.app.groups | ||
| } | ||
|
|
||
| // Populate the groups with a first set so the dropdown is not empty | ||
| // when opening the page the first time | ||
| this.searchGroup('') | ||
| }, | ||
| methods: { | ||
| searchGroup: debounce(function(query) { | ||
| this.loadingGroups = true | ||
| axios | ||
| .get( | ||
| generateOcsUrl('cloud/groups?offset=0&search={query}&limit=20', { | ||
| query, | ||
| }), | ||
| ) | ||
| .then((res) => res.data.ocs) | ||
| .then((ocs) => ocs.data.groups) | ||
| .then((groups) => { | ||
| this.groups = sortedUniq(uniq(this.groups.concat(groups))) | ||
| if (this.appGroupsOptions.length === 0) { | ||
| this.appGroupsOptions = this.groups.filter((group) => !this.app.groups.includes(group)) | ||
| } | ||
| }) | ||
| .catch((err) => console.error('could not search groups', err)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use the logger instead of the console |
||
| .then(() => { | ||
| this.loadingGroups = false | ||
| }) | ||
| }, 500), | ||
| }, | ||
| } | ||
| </script> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.