diff --git a/docs/databases/connections/athena.md b/docs/databases/connections/athena.md index f64554b92d72c33ca9cc896cd3f4ca3f2d3bf72f..c174f27260d15d9022d26a78c61f6089f697a54a 100644 --- a/docs/databases/connections/athena.md +++ b/docs/databases/connections/athena.md @@ -97,19 +97,6 @@ Turn this option **ON** to scan a sample of values every time Metabase runs a [s A fingerprinting query examines the first 10,000 rows from each column and uses that data to guesstimate how many unique values each column has, what the minimum and maximum values are for numeric and timestamp columns, and so on. If you leave this option **OFF**, Metabase will only fingerprint your columns once during setup. -### Default result cache duration - -{% include plans-blockquote.html feature="Database-specific caching" %} - -How long to keep question results. By default, Metabase will use the value you supply on the [cache settings page](../../configuring-metabase/caching.md), but if this database has other factors that influence the freshness of data, it could make sense to set a custom duration. You can also choose custom durations on individual questions or dashboards to help improve performance. - -Options are: - -- **Use instance default (TTL)**. TTL is time to live, meaning how long the cache remains valid before Metabase should run the query again. -- **Custom**. - -If you are on a paid plan, you can also set cache duration per questions. See [Advanced caching controls](../../configuring-metabase/caching.md#advanced-caching-controls). - ## Permissions and IAM Policies Most issues that we see when people attempt to connect to AWS Athena involve permissions. Querying AWS Athena requires permissions to: diff --git a/docs/databases/connections/bigquery.md b/docs/databases/connections/bigquery.md index e28c737ac0e489a911e5af07cafcc3472f0af068..659f72656f26114f442f8689ee24d51fbf9f794a 100644 --- a/docs/databases/connections/bigquery.md +++ b/docs/databases/connections/bigquery.md @@ -120,19 +120,6 @@ Turn this option **ON** to scan a sample of values every time Metabase runs a [s A fingerprinting query examines the first 10,000 rows from each column and uses that data to guesstimate how many unique values each column has, what the minimum and maximum values are for numeric and timestamp columns, and so on. If you leave this option **OFF**, Metabase will only fingerprint your columns once during setup. -### Default result cache duration - -{% include plans-blockquote.html feature="Database-specific caching" %} - -How long to keep question results. By default, Metabase will use the value you supply on the [cache settings page](../../configuring-metabase/caching.md), but if this database has other factors that influence the freshness of data, it could make sense to set a custom duration. You can also choose custom durations on individual questions or dashboards to help improve performance. - -Options are: - -- **Use instance default (TTL)**. TTL is time to live, meaning how long the cache remains valid before Metabase should run the query again. -- **Custom**. - -If you are on a paid plan, you can also set cache duration per questions. See [Advanced caching controls](../../configuring-metabase/caching.md#advanced-caching-controls). - ## Connecting Metabase to Google Drive data sources You can connect Metabase to Google Drive data sources via BigQuery. There is some setup involved, but basically what you'll be doing is creating a dataset in BigQuery and adding an external table to that dataset that points to a Google Sheet. Useful for uploading CSVs to Google Sheets, and then analyzing and visualizing the data with Metabase. diff --git a/docs/databases/connections/druid.md b/docs/databases/connections/druid.md index a1ee1e4ff3beb5d6b6ecfa2fdaa533f13fa638dc..c2982926a8e16e0d6acfa54ff7ef953c911b8f05 100644 --- a/docs/databases/connections/druid.md +++ b/docs/databases/connections/druid.md @@ -63,19 +63,6 @@ Turn this option **ON** to scan a sample of values every time Metabase runs a [s A fingerprinting query examines the first 10,000 rows from each column and uses that data to guesstimate how many unique values each column has, what the minimum and maximum values are for numeric and timestamp columns, and so on. If you leave this option **OFF**, Metabase will only fingerprint your columns once during setup. -### Default result cache duration - -{% include plans-blockquote.html feature="Database-specific caching" %} - -How long to keep question results. By default, Metabase will use the value you supply on the [cache settings page](../../configuring-metabase/caching.md), but if this database has other factors that influence the freshness of data, it could make sense to set a custom duration. You can also choose custom durations on individual questions or dashboards to help improve performance. - -Options are: - -- **Use instance default (TTL)**. TTL is time to live, meaning how long the cache remains valid before Metabase should run the query again. -- **Custom**. - -If you are on a paid plan, you can also set cache duration per questions. See [Advanced caching controls](../../configuring-metabase/caching.md#advanced-caching-controls). - ## Further reading - [Managing databases](../../databases/connecting.md) diff --git a/docs/databases/connections/mysql.md b/docs/databases/connections/mysql.md index 2d7a2cd7d7c3e0bfcc665ee4e1c66ac2af36be31..bf634b4c42c7796ced9ff116ef21f3b41c402a04 100644 --- a/docs/databases/connections/mysql.md +++ b/docs/databases/connections/mysql.md @@ -87,19 +87,6 @@ Turn this option **ON** to scan a sample of values every time Metabase runs a [s A fingerprinting query examines the first 10,000 rows from each column and uses that data to guesstimate how many unique values each column has, what the minimum and maximum values are for numeric and timestamp columns, and so on. If you leave this option **OFF**, Metabase will only fingerprint your columns once during setup. -### Default result cache duration - -{% include plans-blockquote.html feature="Database-specific caching" %} - -How long to keep question results. By default, Metabase will use the value you supply on the [cache settings page](../../configuring-metabase/caching.md), but if this database has other factors that influence the freshness of data, it could make sense to set a custom duration. You can also choose custom durations on individual questions or dashboards to help improve performance. - -Options are: - -- **Use instance default (TTL)**. TTL is time to live, meaning how long the cache remains valid before Metabase should run the query again. -- **Custom**. - -If you are on a paid plan, you can also set cache duration per questions. See [Advanced caching controls](../../configuring-metabase/caching.md#advanced-caching-controls). - ## Connecting to MySQL 8+ servers Metabase uses the MariaDB connector to connect to MariaDB and MySQL servers. The MariaDB connector does not currently support MySQL 8's default authentication plugin, so in order to connect, you'll need to change the plugin used by the Metabase user to diff --git a/docs/databases/connections/oracle.md b/docs/databases/connections/oracle.md index c087302c05c44d1185e7e5de248443f6d3d5e69e..250e93b14bd8cb2635734b992a7c80a099c9026f 100644 --- a/docs/databases/connections/oracle.md +++ b/docs/databases/connections/oracle.md @@ -71,19 +71,6 @@ For more information on setting up a truststore for AWS RDS Oracle instances, se If you need to connect to other databases using SSL, instead of creating a new truststore, you'll probably want to add the RDS CA to your existing truststore file (likely called `cacerts`). -### Default result cache duration - -{% include plans-blockquote.html feature="Database-specific caching" %} - -How long to keep question results. By default, Metabase will use the value you supply on the [cache settings page](../../configuring-metabase/caching.md), but if this database has other factors that influence the freshness of data, it could make sense to set a custom duration. You can also choose custom durations on individual questions or dashboards to help improve performance. - -Options are: - -- **Use instance default (TTL)**. TTL is time to live, meaning how long the cache remains valid before Metabase should run the query again. -- **Custom**. - -If you are on a paid plan, you can also set cache duration per questions. See [Advanced caching controls](../../configuring-metabase/caching.md#advanced-caching-controls). - ## Downloading the Oracle JDBC Driver JAR You can download a JDBC driver from [Oracle's JDBC driver downloads page](https://www.oracle.com/technetwork/database/application-development/jdbc/downloads/index.html). diff --git a/docs/databases/connections/postgresql.md b/docs/databases/connections/postgresql.md index 4ed2a19c8c590e9d78f84fc736a7b1685bedd80e..093009073355adf95cdfe53e82f8d399421f0681 100644 --- a/docs/databases/connections/postgresql.md +++ b/docs/databases/connections/postgresql.md @@ -160,19 +160,6 @@ Turn this option **ON** to scan a sample of values every time Metabase runs a [s A fingerprinting query examines the first 10,000 rows from each column and uses that data to guesstimate how many unique values each column has, what the minimum and maximum values are for numeric and timestamp columns, and so on. If you leave this option **OFF**, Metabase will only fingerprint your columns once during setup. -### Default result cache duration - -{% include plans-blockquote.html feature="Database-specific caching" %} - -How long to keep question results. By default, Metabase will use the value you supply on the [cache settings page](../../configuring-metabase/caching.md), but if this database has other factors that influence the freshness of data, it could make sense to set a custom duration. You can also choose custom durations on individual questions or dashboards to help improve performance. - -Options are: - -- **Use instance default (TTL)**. TTL is time to live, meaning how long the cache remains valid before Metabase should run the query again. -- **Custom**. - -If you are on a paid plan, you can also set cache duration per questions. See [Advanced caching controls](../../configuring-metabase/caching.md#advanced-caching-controls). - ## Further reading - [Managing databases](../../databases/connecting.md) diff --git a/docs/databases/connections/presto.md b/docs/databases/connections/presto.md index a126f971a77e5708c88812bfc104663171fdba92..3f0b060ede1ffaa9fae10b28e532c3faf2ddf431 100644 --- a/docs/databases/connections/presto.md +++ b/docs/databases/connections/presto.md @@ -107,19 +107,6 @@ Turn this option **ON** to scan a sample of values every time Metabase runs a [s A fingerprinting query examines the first 10,000 rows from each column and uses that data to guesstimate how many unique values each column has, what the minimum and maximum values are for numeric and timestamp columns, and so on. If you leave this option **OFF**, Metabase will only fingerprint your columns once during setup. -### Default result cache duration - -{% include plans-blockquote.html feature="Database-specific caching" %} - -How long to keep question results. By default, Metabase will use the value you supply on the [cache settings page](../../configuring-metabase/caching.md), but if this database has other factors that influence the freshness of data, it could make sense to set a custom duration. You can also choose custom durations on individual questions or dashboards to help improve performance. - -Options are: - -- **Use instance default (TTL)**. TTL is time to live, meaning how long the cache remains valid before Metabase should run the query again. -- **Custom**. - -If you are on a paid plan, you can also set cache duration per questions. See [Advanced caching controls](../../configuring-metabase/caching.md#advanced-caching-controls). - ## Further reading - [Managing databases](../../databases/connecting.md) diff --git a/docs/databases/connections/redshift.md b/docs/databases/connections/redshift.md index 710952c76abb263df33e55693306aef53c950e13..ace4fa7429ab31519548d86ff49d0602495aa14b 100644 --- a/docs/databases/connections/redshift.md +++ b/docs/databases/connections/redshift.md @@ -102,19 +102,6 @@ Turn this option **ON** to scan a sample of values every time Metabase runs a [s A fingerprinting query examines the first 10,000 rows from each column and uses that data to guesstimate how many unique values each column has, what the minimum and maximum values are for numeric and timestamp columns, and so on. If you leave this option **OFF**, Metabase will only fingerprint your columns once during setup. -## Default result cache duration - -{% include plans-blockquote.html feature="Database-specific caching" %} - -How long to keep question results. By default, Metabase will use the value you supply on the [cache settings page](../../configuring-metabase/caching.md), but if this database has other factors that influence the freshness of data, it could make sense to set a custom duration. You can also choose custom durations on individual questions or dashboards to help improve performance. - -Options are: - -- **Use instance default (TTL)**. TTL is time to live, meaning how long the cache remains valid before Metabase should run the query again. -- **Custom**. - -If you are on a paid plan, you can also set cache duration per questions. See [Advanced caching controls](../../configuring-metabase/caching.md#advanced-caching-controls). - ## Further reading - [Managing databases](../../databases/connecting.md) diff --git a/docs/databases/connections/snowflake.md b/docs/databases/connections/snowflake.md index 1fd4e78b644b0f6536749a932952d0e4ee760ea7..592d4231d27daf9ce2f4e93822ef03a38ae95492 100644 --- a/docs/databases/connections/snowflake.md +++ b/docs/databases/connections/snowflake.md @@ -124,19 +124,6 @@ Turn this option **ON** to scan a sample of values every time Metabase runs a [s A fingerprinting query examines the first 10,000 rows from each column and uses that data to guesstimate how many unique values each column has, what the minimum and maximum values are for numeric and timestamp columns, and so on. If you leave this option **OFF**, Metabase will only fingerprint your columns once during setup. -### Default result cache duration - -{% include plans-blockquote.html feature="Database-specific caching" %} - -How long to keep question results. By default, Metabase will use the value you supply on the [cache settings page](../../configuring-metabase/caching.md), but if this database has other factors that influence the freshness of data, it could make sense to set a custom duration. You can also choose custom durations on individual questions or dashboards to help improve performance. - -Options are: - -- **Use instance default (TTL)**. TTL is time to live, meaning how long the cache remains valid before Metabase should run the query again. -- **Custom**. - -If you are on a paid plan, you can also set cache duration per questions. See [Advanced caching controls](../../configuring-metabase/caching.md#advanced-caching-controls). - ## Further reading - [Managing databases](../../databases/connecting.md) diff --git a/docs/databases/connections/sparksql.md b/docs/databases/connections/sparksql.md index 3ae8b6530c6bf4fb9897b996be1b89a6413ac7b2..7cf7e4dd2c72022af38dd47b95959f932b9d1998 100644 --- a/docs/databases/connections/sparksql.md +++ b/docs/databases/connections/sparksql.md @@ -73,19 +73,6 @@ Turn this option **ON** to scan a sample of values every time Metabase runs a [s A fingerprinting query examines the first 10,000 rows from each column and uses that data to guesstimate how many unique values each column has, what the minimum and maximum values are for numeric and timestamp columns, and so on. If you leave this option **OFF**, Metabase will only fingerprint your columns once during setup. -### Default result cache duration - -{% include plans-blockquote.html feature="Database-specific caching" %} - -How long to keep question results. By default, Metabase will use the value you supply on the [cache settings page](../../configuring-metabase/caching.md), but if this database has other factors that influence the freshness of data, it could make sense to set a custom duration. You can also choose custom durations on individual questions or dashboards to help improve performance. - -Options are: - -- **Use instance default (TTL)**. TTL is time to live, meaning how long the cache remains valid before Metabase should run the query again. -- **Custom**. - -If you are on a paid plan, you can also set cache duration per questions. See [Advanced caching controls](../../configuring-metabase/caching.md#advanced-caching-controls). - ## Further reading - [Managing databases](../../databases/connecting.md) diff --git a/docs/databases/connections/sql-server.md b/docs/databases/connections/sql-server.md index 19dd173da469be4d47772093c82801ac41d0d818..6d29e4478f928706599fe229e20c89f3f3f0b0d4 100644 --- a/docs/databases/connections/sql-server.md +++ b/docs/databases/connections/sql-server.md @@ -91,19 +91,6 @@ Turn this option **ON** to scan a sample of values every time Metabase runs a [s A fingerprinting query examines the first 10,000 rows from each column and uses that data to guesstimate how many unique values each column has, what the minimum and maximum values are for numeric and timestamp columns, and so on. If you leave this option **OFF**, Metabase will only fingerprint your columns once during setup. -### Default result cache duration - -{% include plans-blockquote.html feature="Database-specific caching" %} - -How long to keep question results. By default, Metabase will use the value you supply on the [cache settings page](../../configuring-metabase/caching.md), but if this database has other factors that influence the freshness of data, it could make sense to set a custom duration. You can also choose custom durations on individual questions or dashboards to help improve performance. - -Options are: - -- **Use instance default (TTL)**. TTL is time to live, meaning how long the cache remains valid before Metabase should run the query again. -- **Custom**. - -If you are on a paid plan, you can also set cache duration per questions. See [Advanced caching controls](../../configuring-metabase/caching.md#advanced-caching-controls). - ## Further reading - [Managing databases](../../databases/connecting.md) diff --git a/docs/databases/connections/sqlite.md b/docs/databases/connections/sqlite.md index 378f090095117c5e65d8eb55cd798527a3794b21..89093e48bdd864e8e48d574bf60d336207e279df 100644 --- a/docs/databases/connections/sqlite.md +++ b/docs/databases/connections/sqlite.md @@ -55,19 +55,6 @@ Turn this option **ON** to scan a sample of values every time Metabase runs a [s A fingerprinting query examines the first 10,000 rows from each column and uses that data to guesstimate how many unique values each column has, what the minimum and maximum values are for numeric and timestamp columns, and so on. If you leave this option **OFF**, Metabase will only fingerprint your columns once during setup. -### Default result cache duration - -{% include plans-blockquote.html feature="Database-specific caching" %} - -How long to keep question results. By default, Metabase will use the value you supply on the [cache settings page](../../configuring-metabase/caching.md), but if this database has other factors that influence the freshness of data, it could make sense to set a custom duration. You can also choose custom durations on individual questions or dashboards to help improve performance. - -Options are: - -- **Use instance default (TTL)**. TTL is time to live, meaning how long the cache remains valid before Metabase should run the query again. -- **Custom**. - -If you are on a paid plan, you can also set cache duration per questions. See [Advanced caching controls](../../configuring-metabase/caching.md#advanced-caching-controls). - ## Further reading - [Managing databases](../../databases/connecting.md) diff --git a/e2e/test/scenarios/admin/databases/default-sample-database.cy.spec.js b/e2e/test/scenarios/admin/databases/default-sample-database.cy.spec.js index 376279afeac6490dc1f3c3bd757edcade8954f1a..11e90d0631899349a0f61b9c6db9909b1b93d657 100644 --- a/e2e/test/scenarios/admin/databases/default-sample-database.cy.spec.js +++ b/e2e/test/scenarios/admin/databases/default-sample-database.cy.spec.js @@ -1,13 +1,7 @@ import { SAMPLE_DB_ID } from "e2e/support/cypress_data"; import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database"; import { ORDERS_QUESTION_ID } from "e2e/support/cypress_sample_instance_data"; -import { - restore, - popover, - modal, - describeEE, - setTokenFeatures, -} from "e2e/support/helpers"; +import { modal, popover, restore } from "e2e/support/helpers"; import { createMetric, createSegment, @@ -301,35 +295,4 @@ describe("scenarios > admin > databases > sample database", () => { cy.findByText("Sample Database").should("exist"); }); }); - - describeEE("custom caching", () => { - it("should set custom cache ttl", () => { - setTokenFeatures("all"); - cy.request("PUT", "api/setting/enable-query-caching", { value: true }); - - visitDatabase(SAMPLE_DB_ID).then(({ response: { body } }) => { - expect(body.cache_ttl).to.be.null; - }); - - // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage - cy.findByText("Show advanced options").click(); - - setCustomCacheTTLValue("48"); - - cy.button("Save changes").click(); - cy.wait("@databaseUpdate").then(({ request, response }) => { - expect(request.body.cache_ttl).to.equal(48); - expect(response.body.cache_ttl).to.equal(48); - }); - - function setCustomCacheTTLValue(value) { - cy.findAllByTestId("select-button") - .contains("Use instance default (TTL)") - .click(); - - popover().findByText("Custom").click(); - cy.findByDisplayValue("24").clear().type(value).blur(); - } - }); - }); }); diff --git a/enterprise/frontend/src/metabase-enterprise/caching/components/DatabaseCacheTTLField/DatabaseCacheTTLField.jsx b/enterprise/frontend/src/metabase-enterprise/caching/components/DatabaseCacheTTLField/DatabaseCacheTTLField.jsx deleted file mode 100644 index e6c1707a19444e3575b19f167c44676a86b370da..0000000000000000000000000000000000000000 --- a/enterprise/frontend/src/metabase-enterprise/caching/components/DatabaseCacheTTLField/DatabaseCacheTTLField.jsx +++ /dev/null @@ -1,62 +0,0 @@ -import PropTypes from "prop-types"; -import { useCallback, useEffect, useState } from "react"; -import { t } from "ttag"; - -import Select, { Option } from "metabase/core/components/Select"; - -import CacheTTLField from "../CacheTTLField"; - -import { - CacheFieldContainer, - FieldContainer, -} from "./DatabaseCacheTTLField.styled"; - -const MODE = { - INSTANCE_DEFAULT: "instance-default", - CUSTOM: "custom", -}; - -const INSTANCE_DEFAULT_CACHE_TTL = null; -const DEFAULT_CUSTOM_CACHE_TTL = 24; // hours - -const propTypes = { - field: PropTypes.object.isRequired, -}; - -function DatabaseCacheTTLField({ field }) { - const [mode, setMode] = useState( - field.value > 0 ? MODE.CUSTOM : MODE.INSTANCE_DEFAULT, - ); - - const onModeChange = useCallback(e => { - setMode(e.target.value); - }, []); - - useEffect(() => { - if (mode === MODE.INSTANCE_DEFAULT) { - field.onChange(INSTANCE_DEFAULT_CACHE_TTL); - } else if (field.value == null) { - field.onChange(DEFAULT_CUSTOM_CACHE_TTL); - } - }, [field, mode]); - - return ( - <FieldContainer> - <Select value={mode} onChange={onModeChange}> - <Option value={MODE.INSTANCE_DEFAULT}> - {t`Use instance default (TTL)`} - </Option> - <Option value={MODE.CUSTOM}>{t`Custom`}</Option> - </Select> - {mode === MODE.CUSTOM && ( - <CacheFieldContainer> - <CacheTTLField field={field} /> - </CacheFieldContainer> - )} - </FieldContainer> - ); -} - -DatabaseCacheTTLField.propTypes = propTypes; - -export default DatabaseCacheTTLField; diff --git a/enterprise/frontend/src/metabase-enterprise/caching/components/DatabaseCacheTTLField/DatabaseCacheTTLField.styled.tsx b/enterprise/frontend/src/metabase-enterprise/caching/components/DatabaseCacheTTLField/DatabaseCacheTTLField.styled.tsx deleted file mode 100644 index e0d88ee182dfb60b8ef365bbb9b9e1c11d0e7ec1..0000000000000000000000000000000000000000 --- a/enterprise/frontend/src/metabase-enterprise/caching/components/DatabaseCacheTTLField/DatabaseCacheTTLField.styled.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import styled from "@emotion/styled"; - -import { space } from "metabase/styled-components/theme"; - -export const FieldContainer = styled.div` - display: flex; - flex-direction: row; - align-items: center; -`; - -export const CacheFieldContainer = styled.div` - margin-left: ${space(2)}; -`; diff --git a/enterprise/frontend/src/metabase-enterprise/caching/components/DatabaseCacheTTLField/DatabaseCacheTTLField.unit.spec.js b/enterprise/frontend/src/metabase-enterprise/caching/components/DatabaseCacheTTLField/DatabaseCacheTTLField.unit.spec.js deleted file mode 100644 index 52e20bf2aaa7d9e4d7b99931adeae874d9a3be08..0000000000000000000000000000000000000000 --- a/enterprise/frontend/src/metabase-enterprise/caching/components/DatabaseCacheTTLField/DatabaseCacheTTLField.unit.spec.js +++ /dev/null @@ -1,68 +0,0 @@ -import { render, screen, waitFor } from "@testing-library/react"; -import userEvent from "@testing-library/user-event"; - -import DatabaseCacheTTLField from "./DatabaseCacheTTLField"; - -function setup({ value = null } = {}) { - const onChange = jest.fn(); - render( - <DatabaseCacheTTLField field={{ name: "cache_ttl", value, onChange }} />, - ); - return { onChange }; -} - -async function selectMode(nextMode) { - const currentModeLabel = - nextMode === "custom" ? "Use instance default (TTL)" : "Custom"; - const nextModeLabel = - nextMode === "instance-default" ? "Use instance default (TTL)" : "Custom"; - - await userEvent.click(screen.getByText(currentModeLabel)); - await userEvent.click(screen.getByText(nextModeLabel)); -} - -describe("DatabaseCacheTTLField", () => { - it("displays 'Use instance default' option when cache_ttl is null", () => { - setup({ value: null }); - expect(screen.getByText("Use instance default (TTL)")).toBeInTheDocument(); - expect(screen.queryByLabelText("Cache TTL Field")).not.toBeInTheDocument(); - }); - - it("displays 'Use instance default' option when cache_ttl is 0", () => { - setup({ value: 0 }); - expect(screen.getByText("Use instance default (TTL)")).toBeInTheDocument(); - expect(screen.queryByLabelText("Cache TTL Field")).not.toBeInTheDocument(); - }); - - it("sets 24 hours as a default TTL custom value", async () => { - const { onChange } = setup(); - await selectMode("custom"); - await waitFor(() => expect(onChange).toHaveBeenLastCalledWith(24)); - }); - - it("can select and fill custom cache TTL value", async () => { - const { onChange } = setup(); - - await selectMode("custom"); - const input = screen.getByPlaceholderText("24"); - await userEvent.type(input, "{selectall}{backspace}14"); - input.blur(); - - expect(onChange).toHaveBeenLastCalledWith(14); - }); - - it("displays input when cache_ttl has value", () => { - setup({ value: 4 }); - expect(screen.getByDisplayValue("4")).toBeInTheDocument(); - expect(screen.getByText("Custom")).toBeInTheDocument(); - expect( - screen.queryByText("Use instance default (TTL)"), - ).not.toBeInTheDocument(); - }); - - it("can reset cache_ttl to instance default", async () => { - const { onChange } = setup({ value: 48 }); - await selectMode("instance-default"); - await waitFor(() => expect(onChange).toHaveBeenLastCalledWith(null)); - }); -}); diff --git a/enterprise/frontend/src/metabase-enterprise/caching/components/DatabaseCacheTTLField/index.js b/enterprise/frontend/src/metabase-enterprise/caching/components/DatabaseCacheTTLField/index.js deleted file mode 100644 index eedffdc43ac4ffe356f2dddf31c1a3328531e83d..0000000000000000000000000000000000000000 --- a/enterprise/frontend/src/metabase-enterprise/caching/components/DatabaseCacheTTLField/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from "./DatabaseCacheTTLField"; diff --git a/enterprise/frontend/src/metabase-enterprise/caching/components/DatabaseCacheTimeField/DatabaseCacheTimeField.tsx b/enterprise/frontend/src/metabase-enterprise/caching/components/DatabaseCacheTimeField/DatabaseCacheTimeField.tsx deleted file mode 100644 index f4bd0eeaa3065a3a3303455436db667480126e16..0000000000000000000000000000000000000000 --- a/enterprise/frontend/src/metabase-enterprise/caching/components/DatabaseCacheTimeField/DatabaseCacheTimeField.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import { useField, useFormikContext } from "formik"; -import { useCallback } from "react"; -import { jt, t } from "ttag"; - -import FormField from "metabase/core/components/FormField"; -import Link from "metabase/core/components/Link/Link"; -import { useUniqueId } from "metabase/hooks/use-unique-id"; -import type { DatabaseData } from "metabase-types/api"; - -import DatabaseCacheTimeInput from "../DatabaseCacheTimeInput"; - -const FIELD = "cache_ttl"; -const SECTION = "advanced-options"; - -const DatabaseCacheTimeField = () => { - const id = useUniqueId(); - const [{ value, onBlur }, { error, touched }, { setValue }] = useField(FIELD); - const { values } = useFormikContext<DatabaseData>(); - - const handleChange = useCallback( - (value?: number) => setValue(value != null ? value : null), - [setValue], - ); - - if (!values.details[SECTION]) { - return null; - } - - return ( - <FormField - title={t`Default result cache duration`} - description={<DatabaseCacheTimeDescription />} - htmlFor={id} - error={touched ? error : undefined} - > - <DatabaseCacheTimeInput - id={id} - name={FIELD} - value={value ?? undefined} - error={touched && error != null} - onChange={handleChange} - onBlur={onBlur} - /> - </FormField> - ); -}; - -const DatabaseCacheTimeDescription = (): JSX.Element => { - return ( - <div> - {/* eslint-disable-next-line no-literal-metabase-strings -- Metabase settings */} - {jt`How long to keep question results. By default, Metabase will use the value you supply on the ${( - <Link key="link" to="/admin/settings/caching"> - {t`cache settings page`} - </Link> - )}, but if this database has other factors that influence the freshness of data, it could make sense to set a custom duration. You can also choose custom durations on individual questions or dashboards to help improve performance.`} - </div> - ); -}; - -// eslint-disable-next-line import/no-default-export -- deprecated usage -export default DatabaseCacheTimeField; diff --git a/enterprise/frontend/src/metabase-enterprise/caching/components/DatabaseCacheTimeField/index.ts b/enterprise/frontend/src/metabase-enterprise/caching/components/DatabaseCacheTimeField/index.ts deleted file mode 100644 index 66eba6e7c54e1a7293dde42855a13e366a42096a..0000000000000000000000000000000000000000 --- a/enterprise/frontend/src/metabase-enterprise/caching/components/DatabaseCacheTimeField/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -// eslint-disable-next-line import/no-default-export -- deprecated usage -export { default } from "./DatabaseCacheTimeField"; diff --git a/enterprise/frontend/src/metabase-enterprise/caching/index.tsx b/enterprise/frontend/src/metabase-enterprise/caching/index.tsx index 32c1c23248007f80720d8c7cebaab9c15342a562..0ad0c236d314c57d1af1ad774f6a9a4d10296dfc 100644 --- a/enterprise/frontend/src/metabase-enterprise/caching/index.tsx +++ b/enterprise/frontend/src/metabase-enterprise/caching/index.tsx @@ -3,8 +3,6 @@ import { hasPremiumFeature } from "metabase-enterprise/settings"; import CacheTTLField from "./components/CacheTTLField"; import { DashboardStrategySidebar } from "./components/DashboardStrategySidebar"; -import DatabaseCacheTTLField from "./components/DatabaseCacheTTLField"; -import DatabaseCacheTimeField from "./components/DatabaseCacheTimeField"; import { GranularControlsExplanation } from "./components/GranularControlsExplanation"; import { InvalidateNowButton } from "./components/InvalidateNowButton"; import QuestionCacheTTLField from "./components/QuestionCacheTTLField"; @@ -26,11 +24,9 @@ if (hasPremiumFeature("cache_granular_controls")) { }; PLUGIN_FORM_WIDGETS.dashboardCacheTTL = CacheTTLField; - PLUGIN_FORM_WIDGETS.databaseCacheTTL = DatabaseCacheTTLField; PLUGIN_FORM_WIDGETS.questionCacheTTL = QuestionCacheTTLField; PLUGIN_CACHING.getQuestionsImplicitCacheTTL = getQuestionsImplicitCacheTTL; - PLUGIN_CACHING.DatabaseCacheTimeField = DatabaseCacheTimeField; PLUGIN_CACHING.StrategyFormLauncherPanel = StrategyFormLauncherPanel; PLUGIN_CACHING.isEnabled = () => true; PLUGIN_CACHING.hasQuestionCacheSection = hasQuestionCacheSection; diff --git a/frontend/src/metabase/admin/databases/containers/DatabaseEditApp.unit.spec.tsx b/frontend/src/metabase/admin/databases/containers/DatabaseEditApp.unit.spec.tsx index 2cb243e9b5df4ba438d0795c8a4e5570b6a8e5ea..1dd8601df5cd91fd18ee62e36537f1c32a242a59 100644 --- a/frontend/src/metabase/admin/databases/containers/DatabaseEditApp.unit.spec.tsx +++ b/frontend/src/metabase/admin/databases/containers/DatabaseEditApp.unit.spec.tsx @@ -1,7 +1,6 @@ import userEvent from "@testing-library/user-event"; import { IndexRoute, Route } from "react-router"; -import { setupEnterpriseTest } from "__support__/enterprise"; import { callMockEvent } from "__support__/events"; import { setupDatabaseEndpoints, @@ -204,38 +203,4 @@ describe("DatabaseEditApp", () => { ).not.toBeInTheDocument(); }); }); - - describe("Cache TTL field", () => { - describe("OSS", () => { - it("is invisible", async () => { - await setup({ cachingEnabled: true }); - - expect( - screen.queryByText("Default result cache duration"), - ).not.toBeInTheDocument(); - }); - }); - - describe("EE", () => { - beforeEach(() => { - setupEnterpriseTest(); - }); - - it("is visible", async () => { - await setup({ cachingEnabled: true }); - - expect( - screen.getByText("Default result cache duration"), - ).toBeInTheDocument(); - }); - - it("is invisible when caching disabled", async () => { - await setup({ cachingEnabled: false }); - - expect( - screen.queryByText("Default result cache duration"), - ).not.toBeInTheDocument(); - }); - }); - }); }); diff --git a/frontend/src/metabase/databases/components/DatabaseForm/DatabaseForm.tsx b/frontend/src/metabase/databases/components/DatabaseForm/DatabaseForm.tsx index 3f2e94fe01f78a96e8a75fb057408229f12facd5..27dad758fdef3503363f4117587766f50e7f8932 100644 --- a/frontend/src/metabase/databases/components/DatabaseForm/DatabaseForm.tsx +++ b/frontend/src/metabase/databases/components/DatabaseForm/DatabaseForm.tsx @@ -8,10 +8,9 @@ import FormFooter from "metabase/core/components/FormFooter"; import FormSubmitButton from "metabase/core/components/FormSubmitButton"; import { Form, FormProvider } from "metabase/forms"; import { useSelector } from "metabase/lib/redux"; -import { PLUGIN_CACHING } from "metabase/plugins"; import type { DatabaseData, Engine } from "metabase-types/api"; -import { getEngines, getIsCachingEnabled, getIsHosted } from "../../selectors"; +import { getEngines, getIsHosted } from "../../selectors"; import { getDefaultEngineKey } from "../../utils/engine"; import { getSubmitValues, @@ -46,7 +45,6 @@ export const DatabaseForm = ({ }: DatabaseFormProps): JSX.Element => { const engines = useSelector(getEngines); const isHosted = useSelector(getIsHosted); - const isCachingEnabled = useSelector(getIsCachingEnabled); const initialEngineKey = getEngineKey(engines, initialData, isAdvanced); const [engineKey, setEngineKey] = useState(initialEngineKey); const engine = getEngine(engines, engineKey); @@ -91,7 +89,6 @@ export const DatabaseForm = ({ autofocusFieldName={autofocusFieldName} isHosted={isHosted} isAdvanced={isAdvanced} - isCachingEnabled={isCachingEnabled} onEngineChange={handleEngineChange} onCancel={onCancel} setIsDirty={setIsDirty} @@ -107,7 +104,6 @@ interface DatabaseFormBodyProps { autofocusFieldName?: string; isHosted: boolean; isAdvanced: boolean; - isCachingEnabled: boolean; onEngineChange: (engineKey: string | undefined) => void; onCancel?: () => void; setIsDirty?: (isDirty: boolean) => void; @@ -120,7 +116,6 @@ const DatabaseFormBody = ({ autofocusFieldName, isHosted, isAdvanced, - isCachingEnabled, onEngineChange, onCancel, setIsDirty, @@ -158,7 +153,6 @@ const DatabaseFormBody = ({ data-kek={field.name} /> ))} - {isCachingEnabled && <PLUGIN_CACHING.DatabaseCacheTimeField />} <DatabaseFormFooter isDirty={dirty} isAdvanced={isAdvanced} diff --git a/frontend/src/metabase/databases/components/DatabaseForm/tests/cache-granular-controls.unit.spec.tsx b/frontend/src/metabase/databases/components/DatabaseForm/tests/cache-granular-controls.unit.spec.tsx index 35a245e74bbe4cd3e1aed1c16069e8533cd75007..263daf90eeb21568666706600a25713e23141e99 100644 --- a/frontend/src/metabase/databases/components/DatabaseForm/tests/cache-granular-controls.unit.spec.tsx +++ b/frontend/src/metabase/databases/components/DatabaseForm/tests/cache-granular-controls.unit.spec.tsx @@ -1,6 +1,6 @@ import userEvent from "@testing-library/user-event"; -import { screen, waitFor } from "__support__/ui"; +import { screen } from "__support__/ui"; import { createMockSettings, createMockTokenFeatures, @@ -23,56 +23,11 @@ const setupGranularCacheControls = (opts: SetupOpts) => { }; describe("DatabaseForm", () => { - it("should show caching controls in advanced options when caching is enabled", async () => { - setupGranularCacheControls({ isCachingEnabled: true }); - expect(screen.getByText("Display name")).toBeInTheDocument(); - expect( - screen.queryByText("Default result cache duration"), - ).not.toBeInTheDocument(); - - await userEvent.click(screen.getByText("Show advanced options")); - expect( - screen.getByText("Default result cache duration"), - ).toBeInTheDocument(); - }); - it("should not allow to configure cache ttl when query caching is not enabled", async () => { setupGranularCacheControls({ isCachingEnabled: false }); await userEvent.click(screen.getByText("Show advanced options")); expect( screen.getByText("Choose when syncs and scans happen"), ).toBeInTheDocument(); - expect( - screen.queryByText("Default result cache duration"), - ).not.toBeInTheDocument(); - }); - - it("should allow to submit the form with the cache ttl value", async () => { - const { onSubmit } = setupGranularCacheControls({ isCachingEnabled: true }); - - await userEvent.type(screen.getByLabelText("Display name"), "H2"); - await userEvent.type( - screen.getByLabelText("Connection String"), - "file:/db", - ); - await userEvent.click(screen.getByText("Show advanced options")); - await userEvent.click(screen.getByText("Use instance default (TTL)")); - await userEvent.click(screen.getByText("Custom")); - - const cacheInput = screen.getByPlaceholderText("24"); - await userEvent.clear(cacheInput); - await userEvent.type(cacheInput, "10"); - - const saveButton = screen.getByRole("button", { name: "Save" }); - await waitFor(() => expect(saveButton).toBeEnabled()); - - await userEvent.click(saveButton); - await waitFor(() => { - expect(onSubmit).toHaveBeenCalledWith( - expect.objectContaining({ - cache_ttl: 10, - }), - ); - }); }); }); diff --git a/frontend/src/metabase/databases/components/DatabaseForm/tests/common.unit.spec.tsx b/frontend/src/metabase/databases/components/DatabaseForm/tests/common.unit.spec.tsx index 674bbeab20361c68c85fc94ff2c07ae19a0fa4e0..e76c08f1e793bbbc9059560639774af7895a37cc 100644 --- a/frontend/src/metabase/databases/components/DatabaseForm/tests/common.unit.spec.tsx +++ b/frontend/src/metabase/databases/components/DatabaseForm/tests/common.unit.spec.tsx @@ -42,9 +42,6 @@ describe("DatabaseForm", () => { expect( screen.getByText("Choose when syncs and scans happen"), ).toBeInTheDocument(); - expect( - screen.queryByText("Default result cache duration"), - ).not.toBeInTheDocument(); }); }); diff --git a/frontend/src/metabase/databases/components/DatabaseForm/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/databases/components/DatabaseForm/tests/enterprise.unit.spec.tsx deleted file mode 100644 index 4db3f76b59e25dee5bdd0f0f386556cb05fe0daf..0000000000000000000000000000000000000000 --- a/frontend/src/metabase/databases/components/DatabaseForm/tests/enterprise.unit.spec.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import userEvent from "@testing-library/user-event"; - -import { screen } from "__support__/ui"; - -import type { SetupOpts } from "./setup"; -import { setup } from "./setup"; - -const setupEnterprise = (opts?: SetupOpts) => { - return setup({ - ...opts, - hasEnterprisePlugins: true, - }); -}; - -describe("DatabaseForm", () => { - it("should not allow to configure cache ttl", async () => { - setupEnterprise({ isCachingEnabled: true }); - await userEvent.click(screen.getByText("Show advanced options")); - expect( - screen.getByText("Choose when syncs and scans happen"), - ).toBeInTheDocument(); - expect( - screen.queryByText("Default result cache duration"), - ).not.toBeInTheDocument(); - }); -}); diff --git a/frontend/src/metabase/plugins/index.ts b/frontend/src/metabase/plugins/index.ts index f753535ffe919ea53f08055e2632af1bb3cddb33..0c4cd8f8793c9134b8083b09e2193ec2c12e2bff 100644 --- a/frontend/src/metabase/plugins/index.ts +++ b/frontend/src/metabase/plugins/index.ts @@ -351,7 +351,6 @@ export const PLUGIN_CACHING = { dashboardCacheTTLFormField: null, questionCacheTTLFormField: null, getQuestionsImplicitCacheTTL: (_question?: any) => null as number | null, - DatabaseCacheTimeField: PluginPlaceholder as any, StrategyFormLauncherPanel: PluginPlaceholder as any, GranularControlsExplanation: PluginPlaceholder as any, DashboardStrategySidebar: PluginPlaceholder as any,