From 9ac462c39029c33b26011051c689e8c8cb06cd07 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 31 May 2024 12:44:11 +0200 Subject: [PATCH] Remove double checks --- .../backend/DataTable/ViewV2DataTable.svelte | 3 +-- .../grid/controls/ColumnsSettingButton.svelte | 14 +++++++------- .../src/components/grid/layout/Grid.svelte | 8 ++------ 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/ViewV2DataTable.svelte b/packages/builder/src/components/backend/DataTable/ViewV2DataTable.svelte index 45cdeeee07..646b764a2c 100644 --- a/packages/builder/src/components/backend/DataTable/ViewV2DataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/ViewV2DataTable.svelte @@ -28,8 +28,7 @@ showAvatars={false} on:updatedatasource={handleGridViewUpdate} isCloud={$admin.cloud} - showReadonlyColumnsOptions - canSetReadonlyColumns={$licensing.isViewReadonlyColumnsEnabled} + allowViewReadonlyColumns={$licensing.isViewReadonlyColumnsEnabled} > diff --git a/packages/frontend-core/src/components/grid/controls/ColumnsSettingButton.svelte b/packages/frontend-core/src/components/grid/controls/ColumnsSettingButton.svelte index 4ed91f070f..3f0e2341be 100644 --- a/packages/frontend-core/src/components/grid/controls/ColumnsSettingButton.svelte +++ b/packages/frontend-core/src/components/grid/controls/ColumnsSettingButton.svelte @@ -4,8 +4,7 @@ import { getColumnIcon } from "../lib/utils" import ToggleActionButtonGroup from "./ToggleActionButtonGroup.svelte" - export let showReadonlyColumnsOptions = false - export let canSetReadonlyColumns = false + export let allowViewReadonlyColumns = false const { columns, datasource, stickyColumn, dispatch } = getContext("grid") @@ -43,10 +42,10 @@ $: READONLY_OPTION = { icon: "Visibility", value: PERMISSION_OPTIONS.READONLY, - tooltip: canSetReadonlyColumns + tooltip: allowViewReadonlyColumns ? "Read only" : "Read only (premium feature)", - disabled: !canSetReadonlyColumns, + disabled: !allowViewReadonlyColumns, } const HIDDEN_OPTION = { icon: "VisibilityOff", @@ -54,9 +53,10 @@ tooltip: "Hidden", } - $: options = showReadonlyColumnsOptions - ? [EDIT_OPTION, READONLY_OPTION, HIDDEN_OPTION] - : [EDIT_OPTION, HIDDEN_OPTION] + $: options = + $datasource.type === "viewV2" + ? [EDIT_OPTION, READONLY_OPTION, HIDDEN_OPTION] + : [EDIT_OPTION, HIDDEN_OPTION] function columnToPermissionOptions(column) { if (!column.visible) { diff --git a/packages/frontend-core/src/components/grid/layout/Grid.svelte b/packages/frontend-core/src/components/grid/layout/Grid.svelte index 8d95540fa7..8a82209162 100644 --- a/packages/frontend-core/src/components/grid/layout/Grid.svelte +++ b/packages/frontend-core/src/components/grid/layout/Grid.svelte @@ -57,8 +57,7 @@ export let buttons = null export let darkMode export let isCloud = null - export let showReadonlyColumnsOptions = false - export let canSetReadonlyColumns = false + export let allowViewReadonlyColumns = false // Unique identifier for DOM nodes inside this instance const gridID = `grid-${Math.random().toString().slice(2)}` @@ -155,10 +154,7 @@
- +