Add error button

This commit is contained in:
Adria Navarro 2025-02-03 10:32:56 +01:00
parent 7c2375b078
commit 9b6c8c74f3
4 changed files with 27 additions and 1 deletions

View File

@ -1,8 +1,13 @@
<script> <script>
import DevicePreviewSelect from "./DevicePreviewSelect.svelte" import DevicePreviewSelect from "./DevicePreviewSelect.svelte"
import AppPreview from "./AppPreview.svelte" import AppPreview from "./AppPreview.svelte"
import { screenStore, appStore } from "@/stores/builder" import {
screenStore,
appStore,
screenComponentErrorList,
} from "@/stores/builder"
import UndoRedoControl from "@/components/common/UndoRedoControl.svelte" import UndoRedoControl from "@/components/common/UndoRedoControl.svelte"
import { ActionButton } from "@budibase/bbui"
</script> </script>
<div class="app-panel"> <div class="app-panel">
@ -15,6 +20,10 @@
{#if $appStore.clientFeatures.devicePreview} {#if $appStore.clientFeatures.devicePreview}
<DevicePreviewSelect /> <DevicePreviewSelect />
{/if} {/if}
<ActionButton selected quiet on:click={() => {}}
>Errors ({$screenComponentErrorList.length})</ActionButton
>
</div> </div>
</div> </div>
<div class="content"> <div class="content">

View File

@ -20,6 +20,7 @@ import {
screenComponents, screenComponents,
screenComponentErrors, screenComponentErrors,
findComponentsBySettingsType, findComponentsBySettingsType,
screenComponentErrorList,
} from "./screenComponent" } from "./screenComponent"
// Backend // Backend
@ -75,6 +76,7 @@ export {
screenComponents, screenComponents,
screenComponentErrors, screenComponentErrors,
findComponentsBySettingsType, findComponentsBySettingsType,
screenComponentErrorList,
} }
export const reset = () => { export const reset = () => {

View File

@ -115,6 +115,7 @@ function getInvalidDatasources(
const friendlyTypeName = friendlyNameByType[type] ?? type const friendlyTypeName = friendlyNameByType[type] ?? type
result[component._id!] = [ result[component._id!] = [
{ {
componentId: component._id!,
key: setting.key, key: setting.key,
message: `The ${friendlyTypeName} named "${label}" could not be found`, message: `The ${friendlyTypeName} named "${label}" could not be found`,
errorType: "setting", errorType: "setting",
@ -174,6 +175,7 @@ function getMissingRequiredSettings(
if (missingRequiredSettings?.length) { if (missingRequiredSettings?.length) {
result[component._id!] = missingRequiredSettings.map((s: any) => ({ result[component._id!] = missingRequiredSettings.map((s: any) => ({
componentId: component._id!,
key: s.key, key: s.key,
message: `Add the <mark>${s.label}</mark> setting to start using your component`, message: `Add the <mark>${s.label}</mark> setting to start using your component`,
errorType: "setting", errorType: "setting",
@ -214,6 +216,7 @@ function getMissingAncestors(
result[component._id!] = missingAncestors.map(ancestor => { result[component._id!] = missingAncestors.map(ancestor => {
const ancestorDefinition = definitions[`${BudibasePrefix}${ancestor}`] const ancestorDefinition = definitions[`${BudibasePrefix}${ancestor}`]
return { return {
componentId: component._id!,
message: `${pluralise(definition.name)} need to be inside a message: `${pluralise(definition.name)} need to be inside a
<mark>${ancestorDefinition.name}</mark>`, <mark>${ancestorDefinition.name}</mark>`,
errorType: "ancestor-setting", errorType: "ancestor-setting",
@ -270,6 +273,17 @@ export function findComponentsBySettingsType(
return result return result
} }
export const screenComponentErrorList = derived(
[screenComponentErrors],
([$screenComponentErrors]): UIComponentError[] => {
if (!featureFlag.isEnabled("CHECK_COMPONENT_SETTINGS_ERRORS")) {
return []
}
return Object.values($screenComponentErrors).flatMap(errors => errors)
}
)
export const screenComponents = derived( export const screenComponents = derived(
[selectedScreen], [selectedScreen],
([$selectedScreen]) => { ([$selectedScreen]) => {

View File

@ -1,4 +1,5 @@
interface BaseUIComponentError { interface BaseUIComponentError {
componentId: string
message: string message: string
} }