BB logo on free plan
This commit is contained in:
parent
1ea509909f
commit
402c217800
7 changed files with 63 additions and 8 deletions
|
@ -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"
|
href="https://www.budibase.com/?utm_source=budibase-apps-public-screens&utm_medium=badge&utm_campaign=made-in-budibase"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<img src="https://i.imgur.com/Xhdt1YP.png" alt="Budibase" />
|
<img src="https://i.imgur.com/Xhdt1YP.png" alt="Budibase" />
|
||||||
<p>Made In Budibase</p>
|
<p>Made In Budibase</p>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</Link>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
div {
|
div {
|
||||||
position: absolute;
|
position: fixed;
|
||||||
right: 20px;
|
right: 20px;
|
||||||
bottom: 20px;
|
bottom: 20px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
@ -30,11 +34,6 @@
|
||||||
color: var(--spectrum-heading-m-text-color);
|
color: var(--spectrum-heading-m-text-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
a:visited {
|
|
||||||
text-decoration: none;
|
|
||||||
color: var(--spectrum-heading-m-text-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
img {
|
img {
|
||||||
height: 20px;
|
height: 20px;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
import { Heading, Icon } from "@budibase/bbui"
|
import { Heading, Icon } from "@budibase/bbui"
|
||||||
import { FieldTypes } from "../../constants"
|
import { FieldTypes } from "../../constants"
|
||||||
import active from "svelte-spa-router/active"
|
import active from "svelte-spa-router/active"
|
||||||
|
import MadeInBudibase from "../MadeInBudibase.svelte"
|
||||||
|
import licensing from "../../licensing"
|
||||||
|
|
||||||
const { routeStore, styleable, linkable, builderStore } = getContext("sdk")
|
const { routeStore, styleable, linkable, builderStore } = getContext("sdk")
|
||||||
const component = getContext("component")
|
const component = getContext("component")
|
||||||
|
@ -164,6 +166,11 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if !$builderStore.inBuilder && licensing.logoEnabled()}
|
||||||
|
<MadeInBudibase />
|
||||||
|
{/if}
|
||||||
|
|
||||||
<div class="main-wrapper">
|
<div class="main-wrapper">
|
||||||
<div class="main size--{widthClass}">
|
<div class="main size--{widthClass}">
|
||||||
<slot />
|
<slot />
|
||||||
|
|
6
packages/client/src/licensing/constants.js
Normal file
6
packages/client/src/licensing/constants.js
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
export const PlanType = {
|
||||||
|
FREE: "free",
|
||||||
|
TEAM: "team",
|
||||||
|
BUSINESS: "business",
|
||||||
|
ENTERPRISE: "enterprise",
|
||||||
|
}
|
5
packages/client/src/licensing/features.js
Normal file
5
packages/client/src/licensing/features.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import { isFreePlan } from "./utils.js"
|
||||||
|
|
||||||
|
export const logoEnabled = () => {
|
||||||
|
return isFreePlan()
|
||||||
|
}
|
7
packages/client/src/licensing/index.js
Normal file
7
packages/client/src/licensing/index.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import * as features from "./features"
|
||||||
|
|
||||||
|
const licensing = {
|
||||||
|
...features,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default licensing
|
20
packages/client/src/licensing/utils.js
Normal file
20
packages/client/src/licensing/utils.js
Normal 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
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,15 @@ const { getFullUser } = require("../../utilities/users")
|
||||||
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
||||||
const { getAppDB, getAppId } = require("@budibase/backend-core/context")
|
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 => {
|
exports.fetchSelf = async ctx => {
|
||||||
let userId = ctx.user.userId || ctx.user._id
|
let userId = ctx.user.userId || ctx.user._id
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
|
@ -55,4 +64,6 @@ exports.fetchSelf = async ctx => {
|
||||||
} else {
|
} else {
|
||||||
ctx.body = user
|
ctx.body = user
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addSessionAttributesToUser(ctx)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue