Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch for v1.3.19-alpha.1 #26

Open
wants to merge 1 commit into
base: origin-v1.3.19-alpha.1-1722986811
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/bbui/src/Tooltip/TooltipWrapper.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
display: flex;
justify-content: center;
top: 15px;
z-index: 100;
z-index: 200;
width: 160px;
}
.icon {
Expand Down
60 changes: 60 additions & 0 deletions packages/bbui/src/Tooltip/TooltipWrapper.svelte.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<script>
import Tooltip from "./Tooltip.svelte"
import Icon from "../Icon/Icon.svelte"

export let tooltip = ""
export let size = "M"
export let disabled = true

let showTooltip = false
</script>

<div class:container={!!tooltip}>
<slot />
{#if tooltip}
<div class="icon-container">
<div
class="icon"
class:icon-small={size === "M" || size === "S"}
on:mouseover={() => (showTooltip = true)}
on:mouseleave={() => (showTooltip = false)}
on:focus
>
<Icon name="InfoOutline" size="S" {disabled} />
</div>
{#if showTooltip}
<div class="tooltip">
<Tooltip textWrapping={true} direction={"bottom"} text={tooltip} />
</div>
{/if}
</div>
{/if}
</div>

<style>
.container {
display: flex;
align-items: center;
}
.icon-container {
position: relative;
display: flex;
justify-content: center;
margin-left: 5px;
margin-right: 5px;
}
.tooltip {
position: absolute;
display: flex;
justify-content: center;
top: 15px;
z-index: 100;
width: 160px;
}
.icon {
transform: scale(0.75);
}
.icon-small {
margin-bottom: -2px;
}
</style>
12 changes: 5 additions & 7 deletions packages/builder/src/builderStore/dataBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
import { store } from "builderStore"
import {
queries as queriesStores,
tables as tablesStore,
roles as rolesStore,
tables as tablesStore,
} from "stores/backend"
import {
makePropSafe,
isJSBinding,
decodeJSBinding,
encodeJSBinding,
isJSBinding,
makePropSafe,
} from "@budibase/string-templates"
import { TableNames } from "../constants"
import { JSONUtils } from "@budibase/frontend-core"
Expand Down Expand Up @@ -118,8 +118,7 @@ export const readableToRuntimeMap = (bindings, ctx) => {
return {}
}
return Object.keys(ctx).reduce((acc, key) => {
let parsedQuery = readableToRuntimeBinding(bindings, ctx[key])
acc[key] = parsedQuery
acc[key] = readableToRuntimeBinding(bindings, ctx[key])
return acc
}, {})
}
Expand All @@ -132,8 +131,7 @@ export const runtimeToReadableMap = (bindings, ctx) => {
return {}
}
return Object.keys(ctx).reduce((acc, key) => {
let parsedQuery = runtimeToReadableBinding(bindings, ctx[key])
acc[key] = parsedQuery
acc[key] = runtimeToReadableBinding(bindings, ctx[key])
return acc
}, {})
}
Expand Down
18 changes: 16 additions & 2 deletions packages/builder/src/helpers/data/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { IntegrationTypes } from "constants/backend"
import { findHBSBlocks } from "@budibase/string-templates"

export function schemaToFields(schema) {
const response = {}
Expand Down Expand Up @@ -31,7 +32,8 @@ export function breakQueryString(qs) {
let paramObj = {}
for (let param of params) {
const split = param.split("=")
paramObj[split[0]] = split.slice(1).join("=")
console.log(split[1])
paramObj[split[0]] = decodeURIComponent(split.slice(1).join("="))
}
return paramObj
}
Expand All @@ -46,7 +48,19 @@ export function buildQueryString(obj) {
if (str !== "") {
str += "&"
}
str += `${key}=${encodeURIComponent(value || "")}`
const bindings = findHBSBlocks(value)
let count = 0
const bindingMarkers = {}
bindings.forEach(binding => {
const marker = `BINDING...${count++}`
value = value.replace(binding, marker)
bindingMarkers[marker] = binding
})
let encoded = encodeURIComponent(value || "")
Object.entries(bindingMarkers).forEach(([marker, binding]) => {
encoded = encoded.replace(marker, binding)
})
str += `${key}=${encoded}`
}
}
return str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@
const datasourceUrl = datasource?.config.url
const qs = query?.fields.queryString
breakQs = restUtils.breakQueryString(qs)
console.log(breakQs)
breakQs = runtimeToReadableMap(mergedBindings, breakQs)

const path = query.fields.path
Expand Down Expand Up @@ -708,6 +709,7 @@
.url-block {
display: flex;
gap: var(--spacing-s);
z-index: 200;
}
.verb {
flex: 1;
Expand Down
31 changes: 14 additions & 17 deletions packages/worker/src/api/controllers/global/self.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,15 @@ const addSessionAttributesToUser = ctx => {
ctx.body.csrfToken = ctx.user.csrfToken
}

/**
* Remove the attributes that are session based from the current user,
* so that stale values are not written to the db
*/
const removeSessionAttributesFromUser = ctx => {
delete ctx.request.body.csrfToken
delete ctx.request.body.account
delete ctx.request.body.accountPortalAccess
delete ctx.request.body.budibaseAccess
delete ctx.request.body.license
const sanitiseUserUpdate = ctx => {
const allowed = ["firstName", "lastName", "password", "forceResetPassword"]
const resp = {}
for (let [key, value] of Object.entries(ctx.request.body)) {
if (allowed.includes(key)) {
resp[key] = value
}
}
return resp
}

exports.getSelf = async ctx => {
Expand Down Expand Up @@ -117,25 +116,23 @@ exports.updateSelf = async ctx => {
const db = getGlobalDB()
const user = await db.get(ctx.user._id)
let passwordChange = false
if (ctx.request.body.password) {

const userUpdateObj = sanitiseUserUpdate(ctx)
if (userUpdateObj.password) {
// changing password
passwordChange = true
ctx.request.body.password = await hash(ctx.request.body.password)
userUpdateObj.password = await hash(userUpdateObj.password)
// Log all other sessions out apart from the current one
await platformLogout({
ctx,
userId: ctx.user._id,
keepActiveSession: true,
})
}
// don't allow sending up an ID/Rev, always use the existing one
delete ctx.request.body._id
delete ctx.request.body._rev
removeSessionAttributesFromUser(ctx)

const response = await db.put({
...user,
...ctx.request.body,
...userUpdateObj,
})
await userCache.invalidateUser(user._id)
ctx.body = {
Expand Down
5 changes: 1 addition & 4 deletions packages/worker/src/api/controllers/global/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
errors,
events,
tenancy,
users as usersCore,
} from "@budibase/backend-core"
import { checkAnyUserExists } from "../../../utilities/users"
import { groups as groupUtils } from "@budibase/pro"
Expand Down Expand Up @@ -148,9 +147,7 @@ export const bulkDelete = async (ctx: any) => {
}

try {
let response = await users.bulkDelete(userIds)

ctx.body = response
ctx.body = await users.bulkDelete(userIds)
} catch (err) {
ctx.throw(err)
}
Expand Down
Loading