update more names from record to model
This commit is contained in:
parent
d7a4458488
commit
2ac1bcdcba
File diff suppressed because one or more lines are too long
|
@ -59,7 +59,7 @@ window["##BUDIBASE_APPDEFINITION##"] = {
|
|||
getShardName: "",
|
||||
getSortKey: "record.id",
|
||||
aggregateGroups: [],
|
||||
allowedRecordNodeIds: [2],
|
||||
allowedModelNodeIds: [2],
|
||||
nodeId: 5,
|
||||
},
|
||||
],
|
||||
|
@ -79,7 +79,7 @@ window["##BUDIBASE_APPDEFINITION##"] = {
|
|||
getShardName: "",
|
||||
getSortKey: "record.id",
|
||||
aggregateGroups: [],
|
||||
allowedRecordNodeIds: [1],
|
||||
allowedModelNodeIds: [1],
|
||||
nodeId: 4,
|
||||
},
|
||||
{
|
||||
|
@ -91,7 +91,7 @@ window["##BUDIBASE_APPDEFINITION##"] = {
|
|||
getShardName: "",
|
||||
getSortKey: "record.id",
|
||||
aggregateGroups: [],
|
||||
allowedRecordNodeIds: [2],
|
||||
allowedModelNodeIds: [2],
|
||||
nodeId: 6,
|
||||
},
|
||||
],
|
||||
|
|
|
@ -9,7 +9,7 @@ import {
|
|||
templateApi,
|
||||
isIndex,
|
||||
canDeleteIndex,
|
||||
canDeleteRecord,
|
||||
canDeleteModel,
|
||||
} from "components/common/core"
|
||||
|
||||
export const getBackendUiStore = () => {
|
||||
|
@ -217,7 +217,7 @@ export const deleteCurrentNode = store => () => {
|
|||
const isRecord = hierarchyFunctions.isRecord(nodeToDelete)
|
||||
|
||||
const check = isRecord
|
||||
? canDeleteRecord(nodeToDelete)
|
||||
? canDeleteModel(nodeToDelete)
|
||||
: canDeleteIndex(nodeToDelete)
|
||||
|
||||
if (!check.canDelete) {
|
||||
|
|
|
@ -10,7 +10,7 @@ import { generateSchema } from "../../../../core/src/indexing/indexSchemaCreator
|
|||
import { generate } from "shortid"
|
||||
|
||||
export { canDeleteIndex } from "../../../../core/src/templateApi/canDeleteIndex"
|
||||
export { canDeleteRecord } from "../../../../core/src/templateApi/canDeleteRecord"
|
||||
export { canDeleteModel } from "../../../../core/src/templateApi/canDeleteModel"
|
||||
export { userWithFullAccess } from "../../../../core/src/index"
|
||||
export { joinKey } from "../../../../core/src/common"
|
||||
export { getExactNodeForKey } from "../../../../core/src/templateApi/hierarchy"
|
||||
|
|
|
@ -9,10 +9,10 @@ import {
|
|||
import { $ } from "../common"
|
||||
import { map, filter, includes } from "lodash/fp"
|
||||
|
||||
export const canDeleteRecord = recordNode => {
|
||||
const flatHierarchy = $(recordNode, [findRoot, getFlattenedHierarchy])
|
||||
export const canDeleteModel = modelNode => {
|
||||
const flatHierarchy = $(modelNode, [findRoot, getFlattenedHierarchy])
|
||||
|
||||
const ancestors = $(flatHierarchy, [filter(isAncestor(recordNode))])
|
||||
const ancestors = $(flatHierarchy, [filter(isAncestor(modelNode))])
|
||||
|
||||
const belongsToAncestor = i => ancestors.includes(i.parent())
|
||||
|
||||
|
@ -26,7 +26,7 @@ export const canDeleteRecord = recordNode => {
|
|||
),
|
||||
map(
|
||||
i =>
|
||||
`index "${i.name}" indexes this record. Please remove the record from the index, or delete the index`
|
||||
`index "${i.name}" indexes this model. Please remove the model from the index, or delete the index`
|
||||
),
|
||||
])
|
||||
|
||||
|
@ -39,7 +39,7 @@ export const canDeleteRecord = recordNode => {
|
|||
return errorsThisNode
|
||||
}
|
||||
|
||||
const errors = errorsForNode(recordNode)
|
||||
const errors = errorsForNode(modelNode)
|
||||
|
||||
return { errors, canDelete: errors.length === 0 }
|
||||
}
|
|
@ -5,7 +5,7 @@ import {
|
|||
basicAppHierarchyCreator_WithFields_AndIndexes,
|
||||
} from "./specHelpers"
|
||||
import { canDeleteIndex } from "../src/templateApi/canDeleteIndex"
|
||||
import { canDeleteRecord } from "../src/templateApi/canDeleteRecord"
|
||||
import { canDeleteModel } from "../src/templateApi/canDeleteModel"
|
||||
|
||||
describe("canDeleteIndex", () => {
|
||||
it("should return no errors if deltion is valid", async () => {
|
||||
|
@ -49,14 +49,14 @@ describe("canDeleteIndex", () => {
|
|||
})
|
||||
|
||||
|
||||
describe("canDeleteRecord", () => {
|
||||
describe("canDeleteModel", () => {
|
||||
it("should return no errors when deletion is valid", async () => {
|
||||
const { appHierarchy } = await setupApphierarchy(
|
||||
basicAppHierarchyCreator_WithFields
|
||||
)
|
||||
|
||||
appHierarchy.root.indexes = appHierarchy.root.indexes.filter(i => !i.allowedModelNodeIds.includes(appHierarchy.customerRecord.nodeId))
|
||||
const result = canDeleteRecord(appHierarchy.customerRecord)
|
||||
const result = canDeleteModel(appHierarchy.customerRecord)
|
||||
|
||||
expect(result.canDelete).toBe(true)
|
||||
expect(result.errors).toEqual([])
|
||||
|
@ -67,7 +67,7 @@ describe("canDeleteRecord", () => {
|
|||
basicAppHierarchyCreator_WithFields
|
||||
)
|
||||
|
||||
const result = canDeleteRecord(appHierarchy.customerRecord)
|
||||
const result = canDeleteModel(appHierarchy.customerRecord)
|
||||
|
||||
expect(result.canDelete).toBe(false)
|
||||
expect(result.errors.some(e => e.includes("customer_index"))).toBe(true)
|
||||
|
@ -78,7 +78,7 @@ describe("canDeleteRecord", () => {
|
|||
basicAppHierarchyCreator_WithFields_AndIndexes
|
||||
)
|
||||
|
||||
const result = canDeleteRecord(appHierarchy.customerRecord)
|
||||
const result = canDeleteModel(appHierarchy.customerRecord)
|
||||
|
||||
expect(result.canDelete).toBe(false)
|
||||
expect(result.errors.some(e => e.includes("Outstanding Invoices"))).toBe(true)
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -59,7 +59,7 @@ window["##BUDIBASE_APPDEFINITION##"] = {
|
|||
getShardName: "",
|
||||
getSortKey: "record.id",
|
||||
aggregateGroups: [],
|
||||
allowedRecordNodeIds: [2],
|
||||
allowedModelNodeIds: [2],
|
||||
nodeId: 5,
|
||||
},
|
||||
],
|
||||
|
@ -79,7 +79,7 @@ window["##BUDIBASE_APPDEFINITION##"] = {
|
|||
getShardName: "",
|
||||
getSortKey: "record.id",
|
||||
aggregateGroups: [],
|
||||
allowedRecordNodeIds: [1],
|
||||
allowedModelNodeIds: [1],
|
||||
nodeId: 4,
|
||||
},
|
||||
{
|
||||
|
@ -91,7 +91,7 @@ window["##BUDIBASE_APPDEFINITION##"] = {
|
|||
getShardName: "",
|
||||
getSortKey: "record.id",
|
||||
aggregateGroups: [],
|
||||
allowedRecordNodeIds: [2],
|
||||
allowedModelNodeIds: [2],
|
||||
nodeId: 6,
|
||||
},
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue