Adding internal knowledge check to usage.

This commit is contained in:
mike12345567 2025-02-04 17:53:17 +00:00
parent cbc13ad567
commit 5c977713ed
5 changed files with 36 additions and 36 deletions

View File

@ -156,27 +156,17 @@
<ConfirmDialog
bind:this={confirmDeleteDialog}
okText={`Delete ${sourceType}`}
okText="Delete"
onOk={deleteSource}
onCancel={hideDeleteDialog}
title="Confirm Deletion"
title={`Are you sure you want to delete ${sourceType} ${source?.name}?`}
disabled={deleteSourceName !== source?.name}
>
<div class="content">
<p class="firstWarning">
Are you sure you wish to delete the {sourceType}
<span class="sourceNameLine">
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-no-static-element-interactions -->
<b on:click={autofillSourceName} class="sourceName">{source?.name}</b>
<span>?</span>
</span>
</p>
<p class="secondWarning">
<p class="dataWarning">
All {sourceType} data will be deleted{viewsMessage}.
</p>
<p class="thirdWarning">This action <b>cannot be undone</b>.</p>
<p class="undoneWarning">This action <b>cannot be undone</b>.</p>
{#if affectedScreens.length > 0}
<div class="affectedScreens">
@ -210,17 +200,6 @@
max-width: 320px;
}
.firstWarning {
margin: 0 0 12px;
max-width: 100%;
}
.sourceNameLine {
display: inline-flex;
max-width: 100%;
vertical-align: bottom;
}
.sourceName {
flex-grow: 1;
white-space: nowrap;
@ -229,12 +208,12 @@
cursor: pointer;
}
.secondWarning {
.dataWarning {
margin: 0;
max-width: 100%;
}
.thirdWarning {
.undoneWarning {
margin: 0 0 12px;
max-width: 100%;
}

View File

@ -1,27 +1,29 @@
import { generateScreenID, DocumentType } from "../../db/utils"
import { DocumentType, generateScreenID } from "../../db/utils"
import {
events,
context,
tenancy,
db as dbCore,
events,
roles,
tenancy,
} from "@budibase/backend-core"
import { updateAppPackage } from "./application"
import {
Plugin,
ScreenProps,
Screen,
UserCtx,
DeleteScreenResponse,
FetchScreenResponse,
Plugin,
SaveScreenRequest,
SaveScreenResponse,
DeleteScreenResponse,
UsageOfScreensResponse,
Screen,
ScreenProps,
ScreenUsage,
SourceType,
UsageOfScreensResponse,
UserCtx,
} from "@budibase/types"
import { builderSocket } from "../../websockets"
import sdk from "../../sdk"
import { sdk as sharedSdk } from "@budibase/shared-core"
import { isInternal } from "../../sdk/app/tables/utils"
export async function fetch(ctx: UserCtx<void, FetchScreenResponse>) {
const screens = await sdk.screens.fetch()
@ -151,8 +153,14 @@ export async function usage(ctx: UserCtx<void, UsageOfScreensResponse>) {
})
}
}
const isInternalTable =
sourceType === SourceType.TABLE &&
sdk.tables.isInternal({ tableId: sourceId })
const isInternalView =
sourceType === SourceType.VIEW && sdk.views.isInternal(sourceId)
ctx.body = {
sourceType,
internal: isInternalTable || isInternalView,
screens: response,
}
}

View File

@ -11,6 +11,10 @@ export function isExternal(opts: { table?: Table; tableId?: string }): boolean {
return false
}
export function isInternal(opts: { table?: Table; tableId?: string }): boolean {
return !isExternal(opts)
}
export function isTable(table: any): table is Table {
return table._id && docIds.isTableId(table._id)
}

View File

@ -81,6 +81,14 @@ export function isView(view: any): view is ViewV2 {
return view.id && docIds.isViewId(view.id) && view.version === 2
}
export function isInternal(viewId: string) {
if (!docIds.isViewId(viewId)) {
return false
}
const { tableId } = utils.extractViewInfoFromID(viewId)
return !isExternalTableID(tableId)
}
function guardDuplicateCalculationFields(view: Omit<ViewV2, "id" | "version">) {
const seen: Record<string, Record<CalculationType, boolean>> = {}
const calculationFields = helpers.views.calculationFields(view)

View File

@ -23,5 +23,6 @@ export interface ScreenUsage {
export interface UsageOfScreensResponse {
sourceType: SourceType
internal: boolean
screens: ScreenUsage[]
}