1
0
Fork 0
mirror of synced 2024-06-28 02:50:50 +12:00

Merge pull request #5583 from Budibase/feature/bb-logo

BB logo on free plan
This commit is contained in:
Rory Powell 2022-09-15 13:29:37 +01:00 committed by GitHub
commit 22fa30036a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 109 additions and 10 deletions

View file

@ -1,15 +1,20 @@
<a
<script>
import { Link } from "@budibase/bbui"
</script>
<Link
href="https://www.budibase.com/?utm_source=budibase-apps-public-screens&utm_medium=badge&utm_campaign=made-in-budibase"
target="_blank"
>
<div>
<img src="https://i.imgur.com/Xhdt1YP.png" alt="Budibase" />
<p>Made In Budibase</p>
</div>
</a>
</Link>
<style>
div {
position: absolute;
position: fixed;
right: 20px;
bottom: 20px;
padding: 10px;
@ -27,12 +32,7 @@
p {
text-decoration: none;
color: var(--spectrum-heading-m-text-color);
}
a:visited {
text-decoration: none;
color: var(--spectrum-heading-m-text-color);
color: var(--spectrum-global-color-gray-900);
}
img {

View file

@ -5,9 +5,18 @@
import { FieldTypes } from "constants"
import active from "svelte-spa-router/active"
import { RoleUtils } from "@budibase/frontend-core"
import MadeInBudibase from "../MadeInBudibase.svelte"
import licensing from "../../licensing"
const sdk = getContext("sdk")
const { routeStore, styleable, linkable, builderStore, currentRole } = sdk
const {
routeStore,
styleable,
linkable,
builderStore,
currentRole,
environmentStore,
} = sdk
const component = getContext("component")
const context = getContext("context")
@ -225,6 +234,11 @@
</div>
</div>
{/if}
{#if !$builderStore.inBuilder && licensing.logoEnabled() && $environmentStore.cloud}
<MadeInBudibase />
{/if}
<div class="main-wrapper">
<div class="main size--{pageWidthClass}">
<slot />

View file

@ -0,0 +1,6 @@
export const PlanType = {
FREE: "free",
TEAM: "team",
BUSINESS: "business",
ENTERPRISE: "enterprise",
}

View file

@ -0,0 +1,5 @@
import { isFreePlan } from "./utils.js"
export const logoEnabled = () => {
return isFreePlan()
}

View file

@ -0,0 +1,7 @@
import * as features from "./features"
const licensing = {
...features,
}
export default licensing

View file

@ -0,0 +1,20 @@
import { authStore } from "../stores/auth.js"
import { get } from "svelte/store"
import { PlanType } from "./constants"
const getLicense = () => {
const user = get(authStore)
if (user) {
return user.license
}
}
export const isFreePlan = () => {
const license = getLicense()
if (license) {
return license.plan.type === PlanType.FREE
} else {
// safety net - no license means free plan
return true
}
}

View file

@ -9,6 +9,7 @@ import {
rowSelectionStore,
componentStore,
currentRole,
environmentStore,
} from "stores"
import { styleable } from "utils/styleable"
import { linkable } from "utils/linkable"
@ -27,6 +28,7 @@ export default {
builderStore,
uploadStore,
componentStore,
environmentStore,
currentRole,
styleable,
linkable,

View file

@ -0,0 +1,31 @@
import { API } from "api"
import { writable } from "svelte/store"
const initialState = {
cloud: false,
}
const createEnvironmentStore = () => {
const store = writable(initialState)
const actions = {
fetchEnvironment: async () => {
try {
const environment = await API.getEnvironment()
store.set({
...initialState,
...environment,
})
} catch (error) {
store.set(initialState)
}
},
}
return {
subscribe: store.subscribe,
actions,
}
}
export const environmentStore = createEnvironmentStore()

View file

@ -17,6 +17,7 @@ export { devToolsStore } from "./devTools"
export { componentStore } from "./components"
export { uploadStore } from "./uploads.js"
export { rowSelectionStore } from "./rowSelection.js"
export { environmentStore } from "./environment"
// Context stores are layered and duplicated, so it is not a singleton
export { createContextStore } from "./context"

View file

@ -1,7 +1,9 @@
import { routeStore } from "./routes"
import { appStore } from "./app"
import { environmentStore } from "./environment"
export async function initialise() {
await routeStore.actions.fetchRoutes()
await appStore.actions.fetchAppDefinition()
await environmentStore.actions.fetchEnvironment()
}

View file

@ -4,6 +4,15 @@ const { getFullUser } = require("../../utilities/users")
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
const { getAppDB, getAppId } = require("@budibase/backend-core/context")
/**
* Add the attributes that are session based to the current user.
*/
const addSessionAttributesToUser = ctx => {
if (ctx.user) {
ctx.body.license = ctx.user.license
}
}
exports.fetchSelf = async ctx => {
let userId = ctx.user.userId || ctx.user._id
/* istanbul ignore next */
@ -55,4 +64,6 @@ exports.fetchSelf = async ctx => {
} else {
ctx.body = user
}
addSessionAttributesToUser(ctx)
}