Make view readonly columns available for free

This commit is contained in:
Andrew Kingston 2024-09-17 16:29:09 +01:00
parent 61bce0163c
commit fd3c8c4a11
No known key found for this signature in database
7 changed files with 3 additions and 47 deletions

View File

@ -102,10 +102,6 @@ export const useAppBuilders = () => {
return useFeature(Feature.APP_BUILDERS) return useFeature(Feature.APP_BUILDERS)
} }
export const useViewReadonlyColumns = () => {
return useFeature(Feature.VIEW_READONLY_COLUMNS)
}
// QUOTAS // QUOTAS
export const setAutomationLogsQuota = (value: number) => { export const setAutomationLogsQuota = (value: number) => {

View File

@ -30,7 +30,6 @@
showAvatars={false} showAvatars={false}
on:updatedatasource={handleGridViewUpdate} on:updatedatasource={handleGridViewUpdate}
isCloud={$admin.cloud} isCloud={$admin.cloud}
allowViewReadonlyColumns={$licensing.isViewReadonlyColumnsEnabled}
canSetRelationshipSchemas={isEnabled(FeatureFlag.ENRICHED_RELATIONSHIPS)} canSetRelationshipSchemas={isEnabled(FeatureFlag.ENRICHED_RELATIONSHIPS)}
> >
<svelte:fragment slot="filter"> <svelte:fragment slot="filter">

View File

@ -140,10 +140,6 @@ export const createLicensingStore = () => {
Constants.Features.VIEW_PERMISSIONS Constants.Features.VIEW_PERMISSIONS
) )
const isViewReadonlyColumnsEnabled = license.features.includes(
Constants.Features.VIEW_READONLY_COLUMNS
)
const budibaseAIEnabled = license.features.includes( const budibaseAIEnabled = license.features.includes(
Constants.Features.BUDIBASE_AI Constants.Features.BUDIBASE_AI
) )
@ -173,7 +169,6 @@ export const createLicensingStore = () => {
triggerAutomationRunEnabled, triggerAutomationRunEnabled,
isViewPermissionsEnabled, isViewPermissionsEnabled,
perAppBuildersEnabled, perAppBuildersEnabled,
isViewReadonlyColumnsEnabled,
} }
}) })
}, },

View File

@ -4,16 +4,13 @@
import ColumnsSettingContent from "./ColumnsSettingContent.svelte" import ColumnsSettingContent from "./ColumnsSettingContent.svelte"
import { FieldPermissions } from "../../../constants" import { FieldPermissions } from "../../../constants"
export let allowViewReadonlyColumns = false
const { columns, datasource } = getContext("grid") const { columns, datasource } = getContext("grid")
let open = false let open = false
let anchor let anchor
$: anyRestricted = $columns.filter(col => !col.visible || col.readonly).length $: anyRestricted = $columns.filter(col => !col.visible || col.readonly).length
$: text = anyRestricted ? `Columns (${anyRestricted} restricted)` : "Columns" $: text = anyRestricted ? `Columns: ${anyRestricted} restricted` : "Columns"
$: permissions = $: permissions =
$datasource.type === "viewV2" $datasource.type === "viewV2"
? [ ? [
@ -22,9 +19,6 @@
FieldPermissions.HIDDEN, FieldPermissions.HIDDEN,
] ]
: [FieldPermissions.WRITABLE, FieldPermissions.HIDDEN] : [FieldPermissions.WRITABLE, FieldPermissions.HIDDEN]
$: disabledPermissions = allowViewReadonlyColumns
? []
: [FieldPermissions.READONLY]
</script> </script>
<div bind:this={anchor}> <div bind:this={anchor}>
@ -41,9 +35,5 @@
</div> </div>
<Popover bind:open {anchor} align="left"> <Popover bind:open {anchor} align="left">
<ColumnsSettingContent <ColumnsSettingContent columns={$columns} {permissions} />
columns={$columns}
{permissions}
{disabledPermissions}
/>
</Popover> </Popover>

View File

@ -58,7 +58,6 @@
export let buttons = null export let buttons = null
export let darkMode export let darkMode
export let isCloud = null export let isCloud = null
export let allowViewReadonlyColumns = false
export let rowConditions = null export let rowConditions = null
// Unique identifier for DOM nodes inside this instance // Unique identifier for DOM nodes inside this instance
@ -115,7 +114,6 @@
buttons, buttons,
darkMode, darkMode,
isCloud, isCloud,
allowViewReadonlyColumns,
rowConditions, rowConditions,
}) })
@ -157,7 +155,7 @@
<div class="controls-left"> <div class="controls-left">
<slot name="filter" /> <slot name="filter" />
<SortButton /> <SortButton />
<ColumnsSettingButton {allowViewReadonlyColumns} /> <ColumnsSettingButton />
<SizeButton /> <SizeButton />
<slot name="controls" /> <slot name="controls" />
</div> </div>

View File

@ -309,10 +309,6 @@ describe.each([
}) })
describe("readonly fields", () => { describe("readonly fields", () => {
beforeEach(() => {
mocks.licenses.useViewReadonlyColumns()
})
it("readonly fields are persisted", async () => { it("readonly fields are persisted", async () => {
const table = await config.api.table.save( const table = await config.api.table.save(
saveTableRequest({ saveTableRequest({
@ -513,7 +509,6 @@ describe.each([
}) })
it("display fields can be readonly", async () => { it("display fields can be readonly", async () => {
mocks.licenses.useViewReadonlyColumns()
const table = await config.api.table.save( const table = await config.api.table.save(
saveTableRequest({ saveTableRequest({
schema: { schema: {
@ -588,7 +583,6 @@ describe.each([
}) })
it("can update all fields", async () => { it("can update all fields", async () => {
mocks.licenses.useViewReadonlyColumns()
const tableId = table._id! const tableId = table._id!
const updatedData: Required<UpdateViewRequest> = { const updatedData: Required<UpdateViewRequest> = {
@ -803,8 +797,6 @@ describe.each([
}) })
it("cannot update views with readonly on on free license", async () => { it("cannot update views with readonly on on free license", async () => {
mocks.licenses.useViewReadonlyColumns()
view = await config.api.viewV2.update({ view = await config.api.viewV2.update({
...view, ...view,
schema: { schema: {
@ -826,8 +818,6 @@ describe.each([
}) })
it("can remove readonly config after license downgrade", async () => { it("can remove readonly config after license downgrade", async () => {
mocks.licenses.useViewReadonlyColumns()
view = await config.api.viewV2.update({ view = await config.api.viewV2.update({
...view, ...view,
schema: { schema: {
@ -1046,7 +1036,6 @@ describe.each([
}) })
it("should be able to fetch readonly config after downgrades", async () => { it("should be able to fetch readonly config after downgrades", async () => {
mocks.licenses.useViewReadonlyColumns()
const res = await config.api.viewV2.create({ const res = await config.api.viewV2.create({
name: generator.name(), name: generator.name(),
tableId: table._id!, tableId: table._id!,
@ -1112,8 +1101,6 @@ describe.each([
}) })
it("rejects if field is readonly in any view", async () => { it("rejects if field is readonly in any view", async () => {
mocks.licenses.useViewReadonlyColumns()
await config.api.viewV2.create({ await config.api.viewV2.create({
name: "view a", name: "view a",
tableId: table._id!, tableId: table._id!,
@ -1538,7 +1525,6 @@ describe.each([
}) })
it("can't persist readonly columns", async () => { it("can't persist readonly columns", async () => {
mocks.licenses.useViewReadonlyColumns()
const view = await config.api.viewV2.create({ const view = await config.api.viewV2.create({
tableId: table._id!, tableId: table._id!,
name: generator.guid(), name: generator.guid(),
@ -1607,7 +1593,6 @@ describe.each([
}) })
it("can't update readonly columns", async () => { it("can't update readonly columns", async () => {
mocks.licenses.useViewReadonlyColumns()
const view = await config.api.viewV2.create({ const view = await config.api.viewV2.create({
tableId: table._id!, tableId: table._id!,
name: generator.guid(), name: generator.guid(),

View File

@ -59,13 +59,6 @@ async function guardViewSchema(
} }
if (viewSchema[field].readonly) { if (viewSchema[field].readonly) {
if (
!(await features.isViewReadonlyColumnsEnabled()) &&
!(tableSchemaField as ViewFieldMetadata).readonly
) {
throw new HTTPError(`Readonly fields are not enabled`, 400)
}
if (!viewSchema[field].visible) { if (!viewSchema[field].visible) {
throw new HTTPError( throw new HTTPError(
`Field "${field}" must be visible if you want to make it readonly`, `Field "${field}" must be visible if you want to make it readonly`,