Fix issue when using an invalid group ID in url
This commit is contained in:
parent
7cc728ca69
commit
24fdef92b4
|
@ -1,7 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { PickerDropdown, notifications } from "@budibase/bbui"
|
import { PickerDropdown } from "@budibase/bbui"
|
||||||
import { groups } from "stores/portal"
|
import { groups } from "stores/portal"
|
||||||
import { onMount, createEventDispatcher } from "svelte"
|
import { createEventDispatcher } from "svelte"
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
|
@ -25,14 +25,6 @@
|
||||||
const appIds = groupSelected?.apps.map(x => x.appId) || null
|
const appIds = groupSelected?.apps.map(x => x.appId) || null
|
||||||
dispatch("change", appIds)
|
dispatch("change", appIds)
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(async () => {
|
|
||||||
try {
|
|
||||||
await groups.actions.init()
|
|
||||||
} catch (error) {
|
|
||||||
notifications.error("Error")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<PickerDropdown
|
<PickerDropdown
|
||||||
|
|
|
@ -45,6 +45,11 @@
|
||||||
$users.data?.filter(x => !group?.users.map(y => y._id).includes(x._id)) ||
|
$users.data?.filter(x => !group?.users.map(y => y._id).includes(x._id)) ||
|
||||||
[]
|
[]
|
||||||
$: groupApps = $apps.filter(x => group?.apps.includes(x.appId))
|
$: groupApps = $apps.filter(x => group?.apps.includes(x.appId))
|
||||||
|
$: {
|
||||||
|
if (loaded && !group?._id) {
|
||||||
|
$goto("./")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function addAll() {
|
async function addAll() {
|
||||||
selectedUsers = [...selectedUsers, ...filtered.map(u => u._id)]
|
selectedUsers = [...selectedUsers, ...filtered.map(u => u._id)]
|
||||||
|
|
|
@ -73,9 +73,7 @@
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
try {
|
try {
|
||||||
if ($auth.groupsEnabled) {
|
|
||||||
await groups.actions.init()
|
await groups.actions.init()
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
notifications.error("Error getting user groups")
|
notifications.error("Error getting user groups")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { writable, get } from "svelte/store"
|
import { writable, get } from "svelte/store"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import { auth } from "stores/portal"
|
import { auth } from "stores/portal"
|
||||||
import { Constants } from "@budibase/frontend-core"
|
|
||||||
|
|
||||||
export function createGroupsStore() {
|
export function createGroupsStore() {
|
||||||
const store = writable([])
|
const store = writable([])
|
||||||
|
@ -10,9 +9,7 @@ export function createGroupsStore() {
|
||||||
init: async () => {
|
init: async () => {
|
||||||
// only init if these is a groups license, just to be sure but the feature will be blocked
|
// only init if these is a groups license, just to be sure but the feature will be blocked
|
||||||
// on the backend anyway
|
// on the backend anyway
|
||||||
if (
|
if (get(auth).groupsEnabled) {
|
||||||
get(auth).user.license.features.includes(Constants.Features.USER_GROUPS)
|
|
||||||
) {
|
|
||||||
const users = await API.getGroups()
|
const users = await API.getGroups()
|
||||||
store.set(users)
|
store.set(users)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue