Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Budibase/budibase into dependabot…
Browse files Browse the repository at this point in the history
…/npm_and_yarn/examples/nextjs-api-sales/next-14.2.15
  • Loading branch information
mike12345567 committed Dec 18, 2024
2 parents 75a18e1 + b9c6f27 commit 480308d
Show file tree
Hide file tree
Showing 24 changed files with 303 additions and 186 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
...datasource,
name,
}
await datasources.update({
await datasources.save({
datasource: updatedDatasource,
integration: integrationForDatasource(get(integrations), datasource),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
get(integrations),
datasource
)
await datasources.update({ datasource, integration })
await datasources.save({ datasource, integration })
await afterSave({ datasource, action })
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
notifications.success(`Request saved successfully`)
if (dynamicVariables) {
datasource.config.dynamicVariables = rebuildVariables(saveId)
datasource = await datasources.update({
datasource = await datasources.save({
integration: integrationInfo,
datasource,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,20 +368,22 @@
const payload = [
{
email: newUserEmail,
builder: {
global: creationRoleType === Constants.BudibaseRoles.Admin,
creator: creationRoleType === Constants.BudibaseRoles.Creator,
userInfo: {
builder: {
global: creationRoleType === Constants.BudibaseRoles.Admin,
creator: creationRoleType === Constants.BudibaseRoles.Creator,
},
admin: { global: creationRoleType === Constants.BudibaseRoles.Admin },
},
admin: { global: creationRoleType === Constants.BudibaseRoles.Admin },
},
]
const notCreatingAdmin = creationRoleType !== Constants.BudibaseRoles.Admin
const isCreator = creationAccessType === Constants.Roles.CREATOR
if (notCreatingAdmin && isCreator) {
payload[0].builder.apps = [prodAppId]
payload[0].userInfo.builder.apps = [prodAppId]
} else if (notCreatingAdmin && !isCreator) {
payload[0].apps = { [prodAppId]: creationAccessType }
payload[0].userInfo.apps = { [prodAppId]: creationAccessType }
}
let userInviteResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
async function saveDatasource({ config, name }) {
try {
await datasources.update({
await datasources.save({
integration,
datasource: { ...datasource, config, name },
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
get(integrations),
updatedDatasource
)
await datasources.update({ datasource: updatedDatasource, integration })
await datasources.save({ datasource: updatedDatasource, integration })
notifications.success(
`Datasource ${updatedDatasource.name} updated successfully`
)
Expand Down
41 changes: 19 additions & 22 deletions packages/builder/src/stores/BudiStore.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,41 @@
import { writable, Writable } from "svelte/store"
import { writable, Writable, Readable } from "svelte/store"

interface BudiStoreOpts {
debug?: boolean
}

export default class BudiStore<T> implements Writable<T> {
export class BudiStore<T> {
store: Writable<T>
subscribe: Writable<T>["subscribe"]
update: Writable<T>["update"]
set: Writable<T>["set"]

constructor(init: T, opts?: BudiStoreOpts) {
const store = writable<T>(init)

/**
* Internal Svelte store
*/
this.store = store

/**
* Exposes the svelte subscribe fn to allow $ notation access
* @example
* $navigation.selectedScreenId
*/
this.store = writable<T>(init)
this.subscribe = this.store.subscribe

/**
* Exposes the svelte update fn.
* *Store modification should be kept to a minimum
*/
this.update = this.store.update
this.set = this.store.set

/**
* Optional debug mode to output the store updates to console
*/
// Optional debug mode to output the store updates to console
if (opts?.debug) {
this.subscribe(state => {
console.warn(`${this.constructor.name}`, state)
})
}
}
}

export class DerivedBudiStore<T, DerivedT extends T> extends BudiStore<T> {
derivedStore: Readable<DerivedT>
subscribe: Readable<DerivedT>["subscribe"]

constructor(
init: T,
makeDerivedStore: (store: Writable<T>) => Readable<DerivedT>,
opts?: BudiStoreOpts
) {
super(init, opts)
this.derivedStore = makeDerivedStore(this.store)
this.subscribe = this.derivedStore.subscribe
}
}
2 changes: 1 addition & 1 deletion packages/builder/src/stores/builder/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { API } from "api"
import BudiStore from "../BudiStore"
import { BudiStore } from "../BudiStore"

export const INITIAL_APP_META_STATE = {
appId: "",
Expand Down
2 changes: 1 addition & 1 deletion packages/builder/src/stores/builder/builder.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { get } from "svelte/store"
import { createBuilderWebsocket } from "./websocket.js"
import { BuilderSocketEvent } from "@budibase/shared-core"
import BudiStore from "../BudiStore.js"
import { BudiStore } from "../BudiStore.js"
import { TOUR_KEYS } from "components/portal/onboarding/tours.js"

export const INITIAL_BUILDER_STATE = {
Expand Down
2 changes: 1 addition & 1 deletion packages/builder/src/stores/builder/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
DB_TYPE_INTERNAL,
DB_TYPE_EXTERNAL,
} from "constants/backend"
import BudiStore from "../BudiStore"
import { BudiStore } from "../BudiStore"
import { Utils } from "@budibase/frontend-core"
import { FieldType } from "@budibase/types"
import { utils } from "@budibase/shared-core"
Expand Down
Loading

0 comments on commit 480308d

Please sign in to comment.