Merge pull request #10511 from Budibase/budi-6158/prevent_duplicated_group_names
Display error when populated from the backend
This commit is contained in:
commit
3ba81ddbf4
3 changed files with 26 additions and 5 deletions
|
@ -78,9 +78,13 @@
|
||||||
try {
|
try {
|
||||||
await groups.actions.save(group)
|
await groups.actions.save(group)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error.message) {
|
||||||
|
notifications.error(error.message)
|
||||||
|
} else {
|
||||||
notifications.error(`Failed to save user group`)
|
notifications.error(`Failed to save user group`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const removeApp = async app => {
|
const removeApp = async app => {
|
||||||
await groups.actions.removeApp(groupId, apps.getProdAppID(app.devId))
|
await groups.actions.removeApp(groupId, apps.getProdAppID(app.devId))
|
||||||
|
|
|
@ -66,6 +66,8 @@
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.status === 400) {
|
if (error.status === 400) {
|
||||||
notifications.error(error.message)
|
notifications.error(error.message)
|
||||||
|
} else if (error.message) {
|
||||||
|
notifications.error(error.message)
|
||||||
} else {
|
} else {
|
||||||
notifications.error(`Failed to save group`)
|
notifications.error(`Failed to save group`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,25 @@
|
||||||
|
import { generator } from "@budibase/backend-core/tests"
|
||||||
|
import { db } from "@budibase/backend-core"
|
||||||
|
import { UserGroupRoles } from "@budibase/types"
|
||||||
|
|
||||||
export const UserGroup = () => {
|
export const UserGroup = () => {
|
||||||
|
const appsCount = generator.integer({ min: 0, max: 3 })
|
||||||
|
const roles = Array.from({ length: appsCount }).reduce(
|
||||||
|
(p: UserGroupRoles, v) => {
|
||||||
|
return {
|
||||||
|
...p,
|
||||||
|
[db.generateAppID()]: generator.pickone(["ADMIN", "POWER", "BASIC"]),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
|
||||||
let group = {
|
let group = {
|
||||||
apps: [],
|
apps: [],
|
||||||
color: "var(--spectrum-global-color-blue-600)",
|
color: generator.color(),
|
||||||
icon: "UserGroup",
|
icon: generator.word(),
|
||||||
name: "New group",
|
name: generator.word({ length: 2 }),
|
||||||
roles: { app_uuid1: "ADMIN", app_uuid2: "POWER" },
|
roles: roles,
|
||||||
users: [],
|
users: [],
|
||||||
}
|
}
|
||||||
return group
|
return group
|
||||||
|
|
Loading…
Reference in a new issue