Compare commits

...

6 Commits

Author SHA1 Message Date
Raphael Krut-Landau
985e3d3704 Fix type 2024-03-29 11:29:12 -04:00
Raphael Krut-Landau
5201f3d614 Fix type 2024-03-29 11:16:57 -04:00
Raphael Krut-Landau
682b5e53e3 Fix types 2024-03-29 11:13:08 -04:00
Raphael Krut-Landau
f93225b2de Specify types for PluginPlaceholders in PLUGIN_CACHING 2024-03-29 10:17:31 -04:00
Raphael Krut-Landau
6f1ef18599 wip 2024-03-29 10:17:31 -04:00
Raphael Krut-Landau
566e937720 wip 2024-03-29 10:17:31 -04:00
4 changed files with 23 additions and 20 deletions

View File

@@ -1,12 +1,7 @@
import type { Dashboard } from "metabase-types/api";
import type { DashboardCacheSectionProps } from "metabase/plugins";
import CacheSection from "../CacheSection";
interface DashboardCacheSectionProps {
dashboard: Dashboard;
onSave: (cache_ttl: number | null) => Promise<Dashboard>;
}
const DashboardCacheSection = ({
dashboard,
onSave,

View File

@@ -1,16 +1,11 @@
import { t } from "ttag";
import { getRelativeTime } from "metabase/lib/time";
import type { QuestionCacheSectionProps } from "metabase/plugins";
import { Stack, Text } from "metabase/ui";
import type Question from "metabase-lib/v1/Question";
import CacheSection from "../CacheSection";
export interface QuestionCacheSectionProps {
question: Question;
onSave: (cache_ttl: number | null) => Promise<Question>;
}
const QuestionCacheSection = ({
question,
onSave,

View File

@@ -9,9 +9,9 @@ import QuestionCacheSection from "./components/QuestionCacheSection";
import QuestionCacheTTLField from "./components/QuestionCacheTTLField";
import {
getQuestionsImplicitCacheTTL,
validateCacheTTL,
normalizeCacheTTL,
hasQuestionCacheSection,
normalizeCacheTTL,
validateCacheTTL,
} from "./utils";
if (hasPremiumFeature("cache_granular_controls")) {
@@ -20,11 +20,9 @@ if (hasPremiumFeature("cache_granular_controls")) {
validate: validateCacheTTL,
normalize: normalizeCacheTTL,
};
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.DashboardCacheSection = DashboardCacheSection;

View File

@@ -275,13 +275,28 @@ export const PLUGIN_MODERATION = {
) => [],
};
export interface QuestionCacheSectionProps {
question: Question;
onSave: (cache_ttl: number | null) => Promise<Question>;
}
export interface DashboardCacheSectionProps {
dashboard: Dashboard;
onSave: (cache_ttl: number | null) => Promise<Dashboard>;
}
export const PLUGIN_CACHING = {
cacheTTLFormField: {} as any,
dashboardCacheTTLFormField: null,
questionCacheTTLFormField: null,
getQuestionsImplicitCacheTTL: (_question?: any) => null,
QuestionCacheSection: PluginPlaceholder,
DashboardCacheSection: PluginPlaceholder,
DatabaseCacheTimeField: PluginPlaceholder,
getQuestionsImplicitCacheTTL: (_question?: any) => null as number | null,
QuestionCacheSection:
PluginPlaceholder as React.ComponentType<QuestionCacheSectionProps>,
DashboardCacheSection:
PluginPlaceholder as React.ComponentType<DashboardCacheSectionProps>,
DatabaseCacheTimeField: PluginPlaceholder as React.ComponentType<
Record<string, never>
>,
isEnabled: () => false,
hasQuestionCacheSection: (_question: Question) => false,
};