Fix issue when using an invalid group ID in url

This commit is contained in:
Andrew Kingston 2022-08-04 11:28:55 +01:00
parent 7cc728ca69
commit 24fdef92b4
4 changed files with 9 additions and 17 deletions

View File

@ -1,7 +1,7 @@
<script>
import { PickerDropdown, notifications } from "@budibase/bbui"
import { PickerDropdown } from "@budibase/bbui"
import { groups } from "stores/portal"
import { onMount, createEventDispatcher } from "svelte"
import { createEventDispatcher } from "svelte"
const dispatch = createEventDispatcher()
@ -25,14 +25,6 @@
const appIds = groupSelected?.apps.map(x => x.appId) || null
dispatch("change", appIds)
}
onMount(async () => {
try {
await groups.actions.init()
} catch (error) {
notifications.error("Error")
}
})
</script>
<PickerDropdown

View File

@ -45,6 +45,11 @@
$users.data?.filter(x => !group?.users.map(y => y._id).includes(x._id)) ||
[]
$: groupApps = $apps.filter(x => group?.apps.includes(x.appId))
$: {
if (loaded && !group?._id) {
$goto("./")
}
}
async function addAll() {
selectedUsers = [...selectedUsers, ...filtered.map(u => u._id)]

View File

@ -73,9 +73,7 @@
onMount(async () => {
try {
if ($auth.groupsEnabled) {
await groups.actions.init()
}
} catch (error) {
notifications.error("Error getting user groups")
}

View File

@ -1,7 +1,6 @@
import { writable, get } from "svelte/store"
import { API } from "api"
import { auth } from "stores/portal"
import { Constants } from "@budibase/frontend-core"
export function createGroupsStore() {
const store = writable([])
@ -10,9 +9,7 @@ export function createGroupsStore() {
init: async () => {
// only init if these is a groups license, just to be sure but the feature will be blocked
// on the backend anyway
if (
get(auth).user.license.features.includes(Constants.Features.USER_GROUPS)
) {
if (get(auth).groupsEnabled) {
const users = await API.getGroups()
store.set(users)
}