Remove FieldTypeSubtypes

This commit is contained in:
Adria Navarro 2024-04-26 12:09:32 +02:00
parent fe226ae54b
commit 61bb40d0d3
7 changed files with 21 additions and 36 deletions

View File

@ -4,7 +4,6 @@ import {
INTERNAL_TABLE_SOURCE_ID, INTERNAL_TABLE_SOURCE_ID,
AutoFieldSubType, AutoFieldSubType,
Hosting, Hosting,
FieldTypeSubtypes,
} from "@budibase/types" } from "@budibase/types"
import { Constants } from "@budibase/frontend-core" import { Constants } from "@budibase/frontend-core"
@ -162,26 +161,20 @@ export const FIELDS = {
name: "User", name: "User",
type: FieldType.BB_REFERENCE_SINGLE, type: FieldType.BB_REFERENCE_SINGLE,
subtype: FieldSubtype.USER, subtype: FieldSubtype.USER,
icon: TypeIconMap[FieldType.BB_REFERENCE_SINGLE][ icon: TypeIconMap[FieldType.BB_REFERENCE_SINGLE][FieldSubtype.USER],
FieldTypeSubtypes.BB_REFERENCE.USER
],
}, },
// Used for display of editing existing columns // Used for display of editing existing columns
OLD_USER: { OLD_USER: {
name: "User", name: "User",
type: FieldType.BB_REFERENCE, type: FieldType.BB_REFERENCE,
subtype: FieldSubtype.USER, subtype: FieldSubtype.USER,
icon: TypeIconMap[FieldType.BB_REFERENCE_SINGLE][ icon: TypeIconMap[FieldType.BB_REFERENCE_SINGLE][FieldSubtype.USER],
FieldTypeSubtypes.BB_REFERENCE.USER
],
}, },
USERS: { USERS: {
name: "User List", name: "User List",
type: FieldType.BB_REFERENCE, type: FieldType.BB_REFERENCE,
subtype: FieldSubtype.USERS, subtype: FieldSubtype.USERS,
icon: TypeIconMap[FieldType.BB_REFERENCE][ icon: TypeIconMap[FieldType.BB_REFERENCE][FieldSubtype.USERS],
FieldTypeSubtypes.BB_REFERENCE.USERS
],
constraints: { constraints: {
type: "array", type: "array",
}, },

View File

@ -4,7 +4,7 @@
export { OperatorOptions, SqlNumberTypeRangeMap } from "@budibase/shared-core" export { OperatorOptions, SqlNumberTypeRangeMap } from "@budibase/shared-core"
export { Feature as Features } from "@budibase/types" export { Feature as Features } from "@budibase/types"
import { BpmCorrelationKey } from "@budibase/shared-core" import { BpmCorrelationKey } from "@budibase/shared-core"
import { FieldType, FieldTypeSubtypes } from "@budibase/types" import { FieldType, FieldSubtype } from "@budibase/types"
// Cookie names // Cookie names
export const Cookies = { export const Cookies = {
@ -132,10 +132,10 @@ export const TypeIconMap = {
[FieldType.BIGINT]: "TagBold", [FieldType.BIGINT]: "TagBold",
[FieldType.AUTO]: "MagicWand", [FieldType.AUTO]: "MagicWand",
[FieldType.BB_REFERENCE]: { [FieldType.BB_REFERENCE]: {
[FieldTypeSubtypes.BB_REFERENCE.USER]: "User", [FieldSubtype.USER]: "User",
[FieldTypeSubtypes.BB_REFERENCE.USERS]: "UserGroup", [FieldSubtype.USERS]: "UserGroup",
}, },
[FieldType.BB_REFERENCE_SINGLE]: { [FieldType.BB_REFERENCE_SINGLE]: {
[FieldTypeSubtypes.BB_REFERENCE.USER]: "User", [FieldSubtype.USER]: "User",
}, },
} }

View File

@ -13,7 +13,7 @@ import {
DeleteRow, DeleteRow,
FieldSchema, FieldSchema,
FieldType, FieldType,
FieldTypeSubtypes, FieldSubtype,
FormulaType, FormulaType,
INTERNAL_TABLE_SOURCE_ID, INTERNAL_TABLE_SOURCE_ID,
NumberFieldMetadata, NumberFieldMetadata,
@ -1015,12 +1015,12 @@ describe.each([
user: { user: {
name: "user", name: "user",
type: FieldType.BB_REFERENCE, type: FieldType.BB_REFERENCE,
subtype: FieldTypeSubtypes.BB_REFERENCE.USER, subtype: FieldSubtype.USER,
}, },
users: { users: {
name: "users", name: "users",
type: FieldType.BB_REFERENCE, type: FieldType.BB_REFERENCE,
subtype: FieldTypeSubtypes.BB_REFERENCE.USERS, subtype: FieldSubtype.USERS,
}, },
}), }),
() => config.createUser(), () => config.createUser(),

View File

@ -2,7 +2,7 @@ import { searchInputMapping } from "../utils"
import { db as dbCore } from "@budibase/backend-core" import { db as dbCore } from "@budibase/backend-core"
import { import {
FieldType, FieldType,
FieldTypeSubtypes, FieldSubtype,
INTERNAL_TABLE_SOURCE_ID, INTERNAL_TABLE_SOURCE_ID,
RowSearchParams, RowSearchParams,
Table, Table,
@ -20,7 +20,7 @@ const tableWithUserCol: Table = {
user: { user: {
name: "user", name: "user",
type: FieldType.BB_REFERENCE, type: FieldType.BB_REFERENCE,
subtype: FieldTypeSubtypes.BB_REFERENCE.USER, subtype: FieldSubtype.USER,
}, },
}, },
} }
@ -35,7 +35,7 @@ const tableWithUsersCol: Table = {
user: { user: {
name: "user", name: "user",
type: FieldType.BB_REFERENCE, type: FieldType.BB_REFERENCE,
subtype: FieldTypeSubtypes.BB_REFERENCE.USERS, subtype: FieldSubtype.USERS,
}, },
}, },
} }

View File

@ -2,7 +2,7 @@ import { inputProcessing } from ".."
import { generator, structures } from "@budibase/backend-core/tests" import { generator, structures } from "@budibase/backend-core/tests"
import { import {
FieldType, FieldType,
FieldTypeSubtypes, FieldSubtype,
INTERNAL_TABLE_SOURCE_ID, INTERNAL_TABLE_SOURCE_ID,
Table, Table,
TableSourceType, TableSourceType,
@ -39,7 +39,7 @@ describe("rowProcessor - inputProcessing", () => {
}, },
user: { user: {
type: FieldType.BB_REFERENCE, type: FieldType.BB_REFERENCE,
subtype: FieldTypeSubtypes.BB_REFERENCE.USER, subtype: FieldSubtype.USER,
name: "user", name: "user",
constraints: { constraints: {
presence: true, presence: true,
@ -94,7 +94,7 @@ describe("rowProcessor - inputProcessing", () => {
}, },
user: { user: {
type: FieldType.BB_REFERENCE, type: FieldType.BB_REFERENCE,
subtype: FieldTypeSubtypes.BB_REFERENCE.USER, subtype: FieldSubtype.USER,
name: "user", name: "user",
constraints: { constraints: {
presence: false, presence: false,
@ -136,7 +136,7 @@ describe("rowProcessor - inputProcessing", () => {
}, },
user: { user: {
type: FieldType.BB_REFERENCE, type: FieldType.BB_REFERENCE,
subtype: FieldTypeSubtypes.BB_REFERENCE.USER, subtype: FieldSubtype.USER,
name: "user", name: "user",
constraints: { constraints: {
presence: false, presence: false,

View File

@ -1,7 +1,6 @@
import { import {
FieldSubtype,
FieldType, FieldType,
FieldTypeSubtypes, FieldSubtype,
INTERNAL_TABLE_SOURCE_ID, INTERNAL_TABLE_SOURCE_ID,
RowAttachment, RowAttachment,
Table, Table,
@ -42,7 +41,7 @@ describe("rowProcessor - outputProcessing", () => {
}, },
user: { user: {
type: FieldType.BB_REFERENCE, type: FieldType.BB_REFERENCE,
subtype: FieldTypeSubtypes.BB_REFERENCE.USER, subtype: FieldSubtype.USER,
name: "user", name: "user",
constraints: { constraints: {
presence: false, presence: false,
@ -176,7 +175,7 @@ describe("rowProcessor - outputProcessing", () => {
}, },
user: { user: {
type: FieldType.BB_REFERENCE, type: FieldType.BB_REFERENCE,
subtype: FieldTypeSubtypes.BB_REFERENCE.USER, subtype: FieldSubtype.USER,
name: "user", name: "user",
constraints: { constraints: {
presence: false, presence: false,

View File

@ -131,13 +131,6 @@ export interface Row extends Document {
export enum FieldSubtype { export enum FieldSubtype {
USER = "user", USER = "user",
/** @deprecated this should not be used anymore */
USERS = "users", USERS = "users",
} }
// The 'as' are required for typescript not to type the outputs as generic FieldSubtype
export const FieldTypeSubtypes = {
BB_REFERENCE: {
USER: FieldSubtype.USER as FieldSubtype.USER,
USERS: FieldSubtype.USERS as FieldSubtype.USERS,
},
}