Move licence check out of frontend-core

This commit is contained in:
Adria Navarro 2024-05-30 17:12:46 +02:00
parent 6ce0b3c368
commit 4dbfa28feb
3 changed files with 14 additions and 11 deletions

View File

@ -1,6 +1,6 @@
<script> <script>
import { viewsV2 } from "stores/builder" import { viewsV2 } from "stores/builder"
import { admin } from "stores/portal" import { admin, licensing } from "stores/portal"
import { Grid } from "@budibase/frontend-core" import { Grid } from "@budibase/frontend-core"
import { API } from "api" import { API } from "api"
import GridCreateEditRowModal from "components/backend/DataTable/modals/grid/GridCreateEditRowModal.svelte" import GridCreateEditRowModal from "components/backend/DataTable/modals/grid/GridCreateEditRowModal.svelte"
@ -28,7 +28,8 @@
showAvatars={false} showAvatars={false}
on:updatedatasource={handleGridViewUpdate} on:updatedatasource={handleGridViewUpdate}
isCloud={$admin.cloud} isCloud={$admin.cloud}
allowReadonlyColumns showReadonlyColumnsOptions
canSetReadonlyColumns={$licensing.isViewReadonlyColumnsEnabled}
> >
<svelte:fragment slot="filter"> <svelte:fragment slot="filter">
<GridFilterButton /> <GridFilterButton />

View File

@ -1,11 +1,11 @@
<script> <script>
import { getContext } from "svelte" import { getContext } from "svelte"
import { ActionButton, Popover, Icon, notifications } from "@budibase/bbui" import { ActionButton, Popover, Icon, notifications } from "@budibase/bbui"
import { licensing } from "stores/portal"
import { getColumnIcon } from "../lib/utils" import { getColumnIcon } from "../lib/utils"
import ToggleActionButtonGroup from "./ToggleActionButtonGroup.svelte" import ToggleActionButtonGroup from "./ToggleActionButtonGroup.svelte"
export let allowReadonlyColumns = false export let showReadonlyColumnsOptions = false
export let canSetReadonlyColumns = false
const { columns, datasource, stickyColumn, dispatch } = getContext("grid") const { columns, datasource, stickyColumn, dispatch } = getContext("grid")
@ -35,8 +35,6 @@
return restricted ? `Columns (${restricted} restricted)` : "Columns" return restricted ? `Columns (${restricted} restricted)` : "Columns"
} }
$: isViewReadonlyColumnsEnabled = $licensing.isViewReadonlyColumnsEnabled
const PERMISSION_OPTIONS = { const PERMISSION_OPTIONS = {
WRITABLE: "writable", WRITABLE: "writable",
READONLY: "readonly", READONLY: "readonly",
@ -51,10 +49,10 @@
$: READONLY_OPTION = { $: READONLY_OPTION = {
icon: "Visibility", icon: "Visibility",
value: PERMISSION_OPTIONS.READONLY, value: PERMISSION_OPTIONS.READONLY,
tooltip: isViewReadonlyColumnsEnabled tooltip: canSetReadonlyColumns
? "Read only" ? "Read only"
: "Read only (premium feature)", : "Read only (premium feature)",
disabled: !isViewReadonlyColumnsEnabled, disabled: !canSetReadonlyColumns,
} }
const HIDDEN_OPTION = { const HIDDEN_OPTION = {
icon: "VisibilityOff", icon: "VisibilityOff",
@ -62,7 +60,7 @@
tooltip: "Hidden", tooltip: "Hidden",
} }
$: options = allowReadonlyColumns $: options = showReadonlyColumnsOptions
? [EDIT_OPTION, READONLY_OPTION, HIDDEN_OPTION] ? [EDIT_OPTION, READONLY_OPTION, HIDDEN_OPTION]
: [EDIT_OPTION, HIDDEN_OPTION] : [EDIT_OPTION, HIDDEN_OPTION]

View File

@ -57,7 +57,8 @@
export let buttons = null export let buttons = null
export let darkMode export let darkMode
export let isCloud = null export let isCloud = null
export let allowReadonlyColumns = false export let showReadonlyColumnsOptions = false
export let canSetReadonlyColumns = false
// Unique identifier for DOM nodes inside this instance // Unique identifier for DOM nodes inside this instance
const gridID = `grid-${Math.random().toString().slice(2)}` const gridID = `grid-${Math.random().toString().slice(2)}`
@ -154,7 +155,10 @@
<div class="controls-left"> <div class="controls-left">
<slot name="filter" /> <slot name="filter" />
<SortButton /> <SortButton />
<ColumnsSettingButton {allowReadonlyColumns} /> <ColumnsSettingButton
{showReadonlyColumnsOptions}
{canSetReadonlyColumns}
/>
<SizeButton /> <SizeButton />
<slot name="controls" /> <slot name="controls" />
</div> </div>