Skip to content
Snippets Groups Projects
Unverified Commit 1945feea authored by Anton Kulyk's avatar Anton Kulyk Committed by GitHub
Browse files

Hide automatic datetime fields from writeback form (#24050)

parent 430c9977
No related branches found
No related tags found
No related merge requests found
import { TYPE } from "metabase/lib/types";
import { getTemplateTagParameterTarget } from "metabase/parameters/utils/cards";
import Database from "metabase-lib/lib/metadata/Database";
......@@ -19,6 +21,27 @@ export const isDatabaseWritebackEnabled = (database?: IDatabase | null) =>
export const isWritebackSupported = (database?: Database | null) =>
!!database?.hasFeature(DB_WRITEBACK_FEATURE);
const AUTOMATIC_DATE_TIME_FIELDS = [
TYPE.CreationDate,
TYPE.CreationTemporal,
TYPE.CreationTime,
TYPE.CreationTimestamp,
TYPE.DeletionDate,
TYPE.DeletionTemporal,
TYPE.DeletionTime,
TYPE.DeletionTimestamp,
TYPE.UpdatedDate,
TYPE.UpdatedTemporal,
TYPE.UpdatedTime,
TYPE.UpdatedTimestamp,
];
export const isAutomaticDateTimeField = (field: Field) => {
return AUTOMATIC_DATE_TIME_FIELDS.includes(field.semantic_type);
};
export const isEditableField = (field: Field) => {
const isRealField = typeof field.id === "number";
if (!isRealField) {
......@@ -33,6 +56,10 @@ export const isEditableField = (field: Field) => {
return field.database_required;
}
if (isAutomaticDateTimeField(field)) {
return field.database_required;
}
return true;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment