Fixing an issue with deleting DS+ - also making sure if no screens/children found it correctly displays the pre-empt error.
This commit is contained in:
parent
aaee61c1c2
commit
73fd7d2e5d
|
@ -8,6 +8,10 @@ import {
|
|||
import { getProdAppID } from "./conversions"
|
||||
import { DatabaseQueryOpts, VirtualDocumentType } from "@budibase/types"
|
||||
|
||||
const EXTERNAL_TABLE_ID_REGEX = new RegExp(
|
||||
`^${DocumentType.DATASOURCE_PLUS}_(.+)__(.+)$`
|
||||
)
|
||||
|
||||
/**
|
||||
* If creating DB allDocs/query params with only a single top level ID this can be used, this
|
||||
* is usually the case as most of our docs are top level e.g. tables, automations, users and so on.
|
||||
|
@ -64,6 +68,11 @@ export function getQueryIndex(viewName: ViewName) {
|
|||
return `database/${viewName}`
|
||||
}
|
||||
|
||||
export const isExternalTableId = (id: string): boolean => {
|
||||
const matches = id.match(EXTERNAL_TABLE_ID_REGEX)
|
||||
return !!id && matches !== null
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given ID is that of a table.
|
||||
*/
|
||||
|
@ -72,7 +81,7 @@ export const isTableId = (id: string): boolean => {
|
|||
return (
|
||||
!!id &&
|
||||
(id.startsWith(`${DocumentType.TABLE}${SEPARATOR}`) ||
|
||||
id.startsWith(`${DocumentType.DATASOURCE_PLUS}${SEPARATOR}`))
|
||||
isExternalTableId(id))
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -151,6 +151,8 @@
|
|||
const screenCount = affectedScreens.length
|
||||
let message = `Removing ${source?.name} `
|
||||
let initialLength = message.length
|
||||
const hasChanged = () => message.length !== initialLength
|
||||
|
||||
if (sourceType === SourceType.TABLE) {
|
||||
const views = "views" in source ? Object.values(source?.views ?? []) : []
|
||||
message += `will delete its data${
|
||||
|
@ -169,10 +171,10 @@
|
|||
initialLength !== message.length
|
||||
? ", and break connected screens:"
|
||||
: "will break connected screens:"
|
||||
} else {
|
||||
} else if (hasChanged()) {
|
||||
message += "."
|
||||
}
|
||||
return message.length !== initialLength ? message : ""
|
||||
return hasChanged() ? message : ""
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in New Issue