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

View File

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

View File

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