-
-
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
Closed
yannicklescure
wants to merge
7
commits into
nextcloud:master
from
yannicklescure:fix/select-groups-display
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
258cb1a
fix broken app groups display
yannicklescure 1abd28d
Merge branch 'master' into fix/select-groups-display
yannicklescure b1e95e5
Merge branch 'master' into fix/select-groups-display
yannicklescure e617917
Merge branch 'master' into fix/select-groups-display
yannicklescure 377f435
Merge branch 'master' of github.com:yannicklescure/nextcloud-server i…
yannicklescure f69ab9d
change package import
yannicklescure b31cf10
Merge branch 'fix/select-groups-display' of github.com:yannicklescure…
yannicklescure File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 'debounce' | ||
| 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: { | ||
| 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> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.