Merge branch 'develop' into budi-6158/paginage-group-users
This commit is contained in:
commit
ad257366cf
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "2.6.8-alpha.2",
|
||||
"version": "2.6.8-alpha.4",
|
||||
"npmClient": "yarn",
|
||||
"packages": [
|
||||
"packages/backend-core",
|
||||
|
|
|
@ -9,15 +9,23 @@
|
|||
|
||||
export let group
|
||||
export let saveGroup
|
||||
|
||||
let nameError
|
||||
</script>
|
||||
|
||||
<ModalContent
|
||||
onConfirm={() => saveGroup(group)}
|
||||
onConfirm={() => {
|
||||
if (!group.name?.trim()) {
|
||||
nameError = "Group name cannot be empty"
|
||||
return false
|
||||
}
|
||||
saveGroup(group)
|
||||
}}
|
||||
size="M"
|
||||
title={group?._rev ? "Edit group" : "Create group"}
|
||||
confirmText="Save"
|
||||
>
|
||||
<Input bind:value={group.name} label="Name" />
|
||||
<Input bind:value={group.name} label="Name" error={nameError} />
|
||||
<div class="modal-format">
|
||||
<div class="modal-inner">
|
||||
<Body size="XS">Icon</Body>
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 64ff0f044f8d80f2feb24331ca4fc0f51197c813
|
||||
Subproject commit 4d640bfa74945d2e8675af0022fba42c738679f0
|
|
@ -15,7 +15,7 @@ import {
|
|||
} from "@budibase/types"
|
||||
import { OAuth2Client } from "google-auth-library"
|
||||
import { buildExternalTableId, finaliseExternalTables } from "./utils"
|
||||
import { GoogleSpreadsheet } from "google-spreadsheet"
|
||||
import { GoogleSpreadsheet, GoogleSpreadsheetRow } from "google-spreadsheet"
|
||||
import fetch from "node-fetch"
|
||||
import { configs, HTTPError } from "@budibase/backend-core"
|
||||
import { dataFilters } from "@budibase/shared-core"
|
||||
|
@ -434,7 +434,20 @@ class GoogleSheetsIntegration implements DatasourcePlus {
|
|||
try {
|
||||
await this.connect()
|
||||
const sheet = this.client.sheetsByTitle[query.sheet]
|
||||
const rows = await sheet.getRows()
|
||||
let rows: GoogleSpreadsheetRow[] = []
|
||||
if (query.paginate) {
|
||||
const limit = query.paginate.limit || 100
|
||||
let page: number =
|
||||
typeof query.paginate.page === "number"
|
||||
? query.paginate.page
|
||||
: parseInt(query.paginate.page || "1")
|
||||
rows = await sheet.getRows({
|
||||
limit,
|
||||
offset: (page - 1) * limit,
|
||||
})
|
||||
} else {
|
||||
rows = await sheet.getRows()
|
||||
}
|
||||
const filtered = dataFilters.runLuceneQuery(rows, query.filters)
|
||||
const headerValues = sheet.headerValues
|
||||
let response = []
|
||||
|
|
|
@ -13,6 +13,7 @@ describe("/api/global/groups", () => {
|
|||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
jest.resetAllMocks()
|
||||
mocks.licenses.useGroups()
|
||||
})
|
||||
|
||||
|
@ -24,6 +25,63 @@ describe("/api/global/groups", () => {
|
|||
expect(events.group.updated).not.toBeCalled()
|
||||
expect(events.group.permissionsEdited).not.toBeCalled()
|
||||
})
|
||||
|
||||
it("should not allow undefined names", async () => {
|
||||
const group = { ...structures.groups.UserGroup(), name: undefined } as any
|
||||
const response = await config.api.groups.saveGroup(group, { expect: 400 })
|
||||
expect(JSON.parse(response.text).message).toEqual(
|
||||
'Invalid body - "name" is required'
|
||||
)
|
||||
})
|
||||
|
||||
it("should not allow empty names", async () => {
|
||||
const group = { ...structures.groups.UserGroup(), name: "" }
|
||||
const response = await config.api.groups.saveGroup(group, { expect: 400 })
|
||||
expect(JSON.parse(response.text).message).toEqual(
|
||||
'Invalid body - "name" is not allowed to be empty'
|
||||
)
|
||||
})
|
||||
|
||||
it("should not allow whitespace names", async () => {
|
||||
const group = { ...structures.groups.UserGroup(), name: " " }
|
||||
const response = await config.api.groups.saveGroup(group, { expect: 400 })
|
||||
expect(JSON.parse(response.text).message).toEqual(
|
||||
'Invalid body - "name" is not allowed to be empty'
|
||||
)
|
||||
})
|
||||
|
||||
it("should trim names", async () => {
|
||||
const group = { ...structures.groups.UserGroup(), name: " group name " }
|
||||
await config.api.groups.saveGroup(group)
|
||||
expect(events.group.created).toBeCalledWith(
|
||||
expect.objectContaining({ name: "group name" })
|
||||
)
|
||||
})
|
||||
|
||||
describe("name max length", () => {
|
||||
const maxLength = 50
|
||||
|
||||
it(`should allow names shorter than ${maxLength} characters`, async () => {
|
||||
const group = {
|
||||
...structures.groups.UserGroup(),
|
||||
name: structures.generator.word({ length: maxLength }),
|
||||
}
|
||||
await config.api.groups.saveGroup(group, { expect: 200 })
|
||||
})
|
||||
|
||||
it(`should not allow names longer than ${maxLength} characters`, async () => {
|
||||
const group = {
|
||||
...structures.groups.UserGroup(),
|
||||
name: structures.generator.word({ length: maxLength + 1 }),
|
||||
}
|
||||
const response = await config.api.groups.saveGroup(group, {
|
||||
expect: 400,
|
||||
})
|
||||
expect(JSON.parse(response.text).message).toEqual(
|
||||
'Invalid body - "name" length must be less than or equal to 50 characters long'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("update", () => {
|
||||
|
|
|
@ -7,13 +7,13 @@ export class GroupsAPI extends TestAPI {
|
|||
super(config)
|
||||
}
|
||||
|
||||
saveGroup = (group: UserGroup) => {
|
||||
saveGroup = (group: UserGroup, { expect } = { expect: 200 }) => {
|
||||
return this.request
|
||||
.post(`/api/global/groups`)
|
||||
.send(group)
|
||||
.set(this.config.defaultHeaders())
|
||||
.expect("Content-Type", /json/)
|
||||
.expect(200)
|
||||
.expect(expect)
|
||||
}
|
||||
|
||||
deleteGroup = (id: string, rev: string) => {
|
||||
|
|
Loading…
Reference in New Issue