Don't show selected components unless the components tab is active and automatically route to components whenever selecting on in the preview

This commit is contained in:
Andrew Kingston 2022-04-27 08:47:06 +01:00
parent ee0dd6853a
commit c22ffb9f52
3 changed files with 15 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import {
mainLayout,
selectedComponent,
selectedAccessRole,
store,
} from "builderStore"
import {
datasources,

View File

@ -39,7 +39,11 @@
{#if $store.clientFeatures.devicePreview}
<DevicePreviewSelect />
{/if}
<Button cta icon="Add" on:click={() => $goto(newComponentUrl)}>
<Button
cta
icon="Add"
on:click={() => $goto(`./components/${$selectedScreen._id}/new`)}
>
Component
</Button>
</div>

View File

@ -13,6 +13,7 @@
} from "@budibase/bbui"
import ErrorSVG from "@budibase/frontend-core/assets/error.svg?raw"
import { findComponent, findComponentPath } from "builderStore/componentUtils"
import { isActive, goto } from "@roxi/routify"
let iframe
let layout
@ -41,7 +42,10 @@
screen = $selectedScreen
layout = $store.layouts.find(layout => layout._id === screen?.layoutId)
}
$: selectedComponentId = $store.selectedComponentId ?? ""
// Don't show selected components unless on the components tab
$: selectedComponentId = $isActive("./components")
? $store.selectedComponentId
: ""
$: previewData = {
appId: $store.appId,
layout,
@ -140,10 +144,10 @@
try {
if (type === "select-component" && data.id) {
store.update(state => {
state.selectedComponentId = data.id
return state
})
$store.selectedComponentId = data.id
if (!$isActive("./components")) {
$goto("./components")
}
} else if (type === "update-prop") {
await store.actions.components.updateProp(data.prop, data.value)
} else if (type === "delete-component" && data.id) {