This commit is contained in:
Martin McKeaveney 2021-10-01 15:18:37 +01:00
commit ff34e6fed5
9 changed files with 70 additions and 42 deletions

View File

@ -24,9 +24,7 @@ context("Create a Table", () => {
it("updates a column on the table", () => { it("updates a column on the table", () => {
cy.get(".title").click() cy.get(".title").click()
cy.get(".spectrum-Table-editIcon > use").click() cy.get(".spectrum-Table-editIcon > use").click()
cy.get("input") cy.get("input").eq(1).type("updated", { force: true })
.eq(1)
.type("updated", { force: true })
// Unset table display column // Unset table display column
cy.get(".spectrum-Switch-input").eq(1).click() cy.get(".spectrum-Switch-input").eq(1).click()
cy.contains("Save Column").click() cy.contains("Save Column").click()
@ -45,9 +43,7 @@ context("Create a Table", () => {
it("deletes a row", () => { it("deletes a row", () => {
cy.get(".spectrum-Checkbox-input").check({ force: true }) cy.get(".spectrum-Checkbox-input").check({ force: true })
cy.contains("Delete 1 row(s)").click() cy.contains("Delete 1 row(s)").click()
cy.get(".spectrum-Modal") cy.get(".spectrum-Modal").contains("Delete").click()
.contains("Delete")
.click()
cy.contains("RoverUpdated").should("not.exist") cy.contains("RoverUpdated").should("not.exist")
}) })
@ -56,15 +52,18 @@ context("Create a Table", () => {
cy.get(".spectrum-Table-editIcon > use").click() cy.get(".spectrum-Table-editIcon > use").click()
cy.contains("Delete").click() cy.contains("Delete").click()
cy.wait(50) cy.wait(50)
cy.contains("Delete Column") cy.contains("Delete Column").click()
.click()
cy.contains("nameupdated").should("not.exist") cy.contains("nameupdated").should("not.exist")
}) })
it("deletes a table", () => { it("deletes a table", () => {
cy.get(".actions > :nth-child(1) > .icon > .spectrum-Icon > use") cy.get(".nav-item")
.eq(1) .contains("dog")
.click({ force: true }) .parents(".nav-item")
.first()
.within(() => {
cy.get(".actions .spectrum-Icon").click({ force: true })
})
cy.get(".spectrum-Menu > :nth-child(2)").click() cy.get(".spectrum-Menu > :nth-child(2)").click()
cy.contains("Delete Table").click() cy.contains("Delete Table").click()
cy.contains("dog").should("not.exist") cy.contains("dog").should("not.exist")

View File

@ -28,11 +28,7 @@ context("Create a View", () => {
const headers = Array.from($headers).map(header => const headers = Array.from($headers).map(header =>
header.textContent.trim() header.textContent.trim()
) )
expect(removeSpacing(headers)).to.deep.eq([ expect(removeSpacing(headers)).to.deep.eq(["group", "age", "rating"])
"group",
"age",
"rating",
])
}) })
}) })
@ -57,6 +53,7 @@ context("Create a View", () => {
}) })
it("creates a stats calculation view based on age", () => { it("creates a stats calculation view based on age", () => {
cy.wait(1000)
cy.contains("Calculate").click() cy.contains("Calculate").click()
cy.get(".modal-inner-wrapper").within(() => { cy.get(".modal-inner-wrapper").within(() => {
cy.get(".spectrum-Picker-label").eq(0).click() cy.get(".spectrum-Picker-label").eq(0).click()
@ -104,20 +101,20 @@ context("Create a View", () => {
cy.get(".spectrum-Table-cell").then($values => { cy.get(".spectrum-Table-cell").then($values => {
let values = Array.from($values).map(header => header.textContent.trim()) let values = Array.from($values).map(header => header.textContent.trim())
expect(values).to.deep.eq([ expect(values).to.deep.eq([
"Students", "Students",
"70", "70",
"20", "20",
"25", "25",
"3", "3",
"1650", "1650",
"23.333333333333332", "23.333333333333332",
"Teachers", "Teachers",
"85", "85",
"36", "36",
"49", "49",
"2", "2",
"3697", "3697",
"42.5", "42.5",
]) ])
}) })
}) })

View File

@ -62,7 +62,7 @@
<Modal bind:this={modal}> <Modal bind:this={modal}>
<ModalContent <ModalContent
showConfirmButton={false} showConfirmButton={false}
cancelText="Close" cancelText="View changes"
showCloseIcon={false} showCloseIcon={false}
title="Theme settings" title="Theme settings"
> >

View File

@ -216,6 +216,7 @@
<div class="filter"> <div class="filter">
<div class="select"> <div class="select">
<Select <Select
autoWidth
bind:value={sortBy} bind:value={sortBy}
placeholder={null} placeholder={null}
options={[ options={[
@ -224,7 +225,9 @@
{ label: "Sort by status", value: "status" }, { label: "Sort by status", value: "status" },
]} ]}
/> />
<Search placeholder="Search" bind:value={searchTerm} /> <div class="desktop-search">
<Search placeholder="Search" bind:value={searchTerm} />
</div>
</div> </div>
<ActionGroup> <ActionGroup>
<ActionButton <ActionButton
@ -241,6 +244,9 @@
/> />
</ActionGroup> </ActionGroup>
</div> </div>
<div class="mobile-search">
<Search placeholder="Search" bind:value={searchTerm} />
</div>
<div <div
class:appGrid={layout === "grid"} class:appGrid={layout === "grid"}
class:appTable={layout === "table"} class:appTable={layout === "table"}
@ -318,6 +324,7 @@
flex-direction: row; flex-direction: row;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
gap: 10px;
} }
.select { .select {
@ -325,6 +332,12 @@
grid-template-columns: 1fr 1fr; grid-template-columns: 1fr 1fr;
grid-gap: 10px; grid-gap: 10px;
} }
.filter :global(.spectrum-ActionGroup) {
flex-wrap: nowrap;
}
.mobile-search {
display: none;
}
.appGrid { .appGrid {
display: grid; display: grid;
@ -364,5 +377,11 @@
.appTable { .appTable {
grid-template-columns: 1fr auto; grid-template-columns: 1fr auto;
} }
.desktop-search {
display: none;
}
.mobile-search {
display: block;
}
} }
</style> </style>

View File

@ -7,14 +7,19 @@ if (env.POSTHOG_TOKEN && env.ENABLE_ANALYTICS && !env.SELF_HOSTED) {
posthogClient = new PostHog(env.POSTHOG_TOKEN) posthogClient = new PostHog(env.POSTHOG_TOKEN)
} }
exports.isEnabled = async function (ctx) { exports.isEnabled = async ctx => {
ctx.body = { ctx.body = {
enabled: !env.SELF_HOSTED && env.ENABLE_ANALYTICS === "true", enabled: !env.SELF_HOSTED && env.ENABLE_ANALYTICS === "true",
} }
} }
exports.endUserPing = async (ctx, next) => { exports.endUserPing = async ctx => {
if (!posthogClient) return next() if (!posthogClient) {
ctx.body = {
ping: false,
}
return
}
posthogClient.capture("budibase:end_user_ping", { posthogClient.capture("budibase:end_user_ping", {
userId: ctx.user && ctx.user._id, userId: ctx.user && ctx.user._id,

View File

@ -3,7 +3,8 @@ const controller = require("../controllers/analytics")
const router = Router() const router = Router()
router.get("/api/analytics", controller.isEnabled) router
router.post("/api/analytics/ping", controller.endUserPing) .get("/api/analytics", controller.isEnabled)
.post("/api/analytics/ping", controller.endUserPing)
module.exports = router module.exports = router

View File

@ -99,6 +99,7 @@ function processAutoColumn(
row, row,
opts = { reprocessing: false, noAutoRelationships: false } opts = { reprocessing: false, noAutoRelationships: false }
) { ) {
let noUser = !user || !user.userId
let now = new Date().toISOString() let now = new Date().toISOString()
// if a row doesn't have a revision then it doesn't exist yet // if a row doesn't have a revision then it doesn't exist yet
const creating = !row._rev const creating = !row._rev
@ -108,7 +109,12 @@ function processAutoColumn(
} }
switch (schema.subtype) { switch (schema.subtype) {
case AutoFieldSubTypes.CREATED_BY: case AutoFieldSubTypes.CREATED_BY:
if (creating && !opts.reprocessing && !opts.noAutoRelationships) { if (
creating &&
!opts.reprocessing &&
!opts.noAutoRelationships &&
!noUser
) {
row[key] = [user.userId] row[key] = [user.userId]
} }
break break
@ -118,7 +124,7 @@ function processAutoColumn(
} }
break break
case AutoFieldSubTypes.UPDATED_BY: case AutoFieldSubTypes.UPDATED_BY:
if (!opts.reprocessing && !opts.noAutoRelationships) { if (!opts.reprocessing && !opts.noAutoRelationships && !noUser) {
row[key] = [user.userId] row[key] = [user.userId]
} }
break break

View File

@ -52,7 +52,8 @@ exports.sendSmtpEmail = async (to, from, subject, contents, automation) => {
) )
if (response.status !== 200) { if (response.status !== 200) {
throw "Unable to send email." const error = await response.text()
throw `Unable to send email - ${error}`
} }
return response.json() return response.json()
} }

View File

@ -87,7 +87,7 @@ router
if (ctx.publicEndpoint) { if (ctx.publicEndpoint) {
return next() return next()
} }
if (!ctx.isAuthenticated || !ctx.user.budibaseAccess) { if ((!ctx.isAuthenticated || !ctx.user.budibaseAccess) && !ctx.internal) {
ctx.throw(403, "Unauthorized - no public worker access") ctx.throw(403, "Unauthorized - no public worker access")
} }
return next() return next()