1
0
Fork 0
mirror of synced 2024-06-28 11:00:55 +12:00

BB logo on free plan

This commit is contained in:
Rory Powell 2022-04-26 11:28:31 +01:00
parent 1ea509909f
commit 402c217800
7 changed files with 63 additions and 8 deletions

View file

@ -1,15 +1,19 @@
<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"
>
<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;
@ -30,11 +34,6 @@
color: var(--spectrum-heading-m-text-color);
}
a:visited {
text-decoration: none;
color: var(--spectrum-heading-m-text-color);
}
img {
height: 20px;
margin-right: 10px;

View file

@ -4,6 +4,8 @@
import { Heading, Icon } from "@budibase/bbui"
import { FieldTypes } from "../../constants"
import active from "svelte-spa-router/active"
import MadeInBudibase from "../MadeInBudibase.svelte"
import licensing from "../../licensing"
const { routeStore, styleable, linkable, builderStore } = getContext("sdk")
const component = getContext("component")
@ -164,6 +166,11 @@
</div>
</div>
{/if}
{#if !$builderStore.inBuilder && licensing.logoEnabled()}
<MadeInBudibase />
{/if}
<div class="main-wrapper">
<div class="main size--{widthClass}">
<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

@ -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)
}