1
0
Fork 0
mirror of synced 2024-07-07 15:25:52 +12:00

Merge pull request #13000 from Budibase/cheeks-fixes

Various fixes
This commit is contained in:
Andrew Kingston 2024-02-13 15:55:34 +00:00 committed by GitHub
commit 0d8a01a33c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 12 deletions

View file

@ -11,6 +11,7 @@
$: editing = app.sessions?.length $: editing = app.sessions?.length
$: isBuilder = sdk.users.isBuilder($auth.user, app?.devId) $: isBuilder = sdk.users.isBuilder($auth.user, app?.devId)
$: unclickable = !isBuilder && !app.deployed
const handleDefaultClick = () => { const handleDefaultClick = () => {
if (!isBuilder) { if (!isBuilder) {
@ -31,11 +32,17 @@
} }
const goToApp = () => { const goToApp = () => {
window.open(`/app/${app.name}`, "_blank") if (app.deployed && app.url) {
window.open(`/app${app.url}`, "_blank")
}
} }
</script> </script>
<div class="app-row" on:click={lockedAction || handleDefaultClick}> <div
class="app-row"
on:click={lockedAction || handleDefaultClick}
class:unclickable
>
<div class="title"> <div class="title">
<div class="app-icon"> <div class="app-icon">
<Icon size="L" name={app.icon?.name || "Apps"} color={app.icon?.color} /> <Icon size="L" name={app.icon?.name || "Apps"} color={app.icon?.color} />
@ -74,7 +81,7 @@
Edit Edit
</Button> </Button>
</div> </div>
{:else} {:else if app.deployed}
<!-- this can happen if an app builder has app user access to an app --> <!-- this can happen if an app builder has app user access to an app -->
<div class="app-row-actions"> <div class="app-row-actions">
<Button size="S" secondary>View</Button> <Button size="S" secondary>View</Button>
@ -94,7 +101,7 @@
transition: border 130ms ease-out; transition: border 130ms ease-out;
border: 1px solid transparent; border: 1px solid transparent;
} }
.app-row:hover { .app-row:not(.unclickable):hover {
cursor: pointer; cursor: pointer;
border-color: var(--spectrum-global-color-gray-300); border-color: var(--spectrum-global-color-gray-300);
} }

View file

@ -113,6 +113,9 @@
// List of context keys which we use inside bindings // List of context keys which we use inside bindings
let knownContextKeyMap = {} let knownContextKeyMap = {}
// Cleanup function to stop observing context changes when unmounting
let unobserve
// Set up initial state for each new component instance // Set up initial state for each new component instance
$: initialise(instance) $: initialise(instance)
@ -311,6 +314,11 @@
// Force an initial enrichment of the new settings // Force an initial enrichment of the new settings
enrichComponentSettings(get(context), settingsDefinitionMap) enrichComponentSettings(get(context), settingsDefinitionMap)
// Start observing changes in context now that we are initialised
if (!unobserve) {
unobserve = context.actions.observeChanges(handleContextChange)
}
} }
// Extracts a map of all context keys which are required by action settings // Extracts a map of all context keys which are required by action settings
@ -567,8 +575,8 @@
} }
} }
// Register an unregister component instance
onMount(() => { onMount(() => {
// Register this component instance for external access
if ($appStore.isDevApp) { if ($appStore.isDevApp) {
if (!componentStore.actions.isComponentRegistered(id)) { if (!componentStore.actions.isComponentRegistered(id)) {
componentStore.actions.registerInstance(id, { componentStore.actions.registerInstance(id, {
@ -581,16 +589,17 @@
state: store, state: store,
}) })
} }
return () => { }
if (componentStore.actions.isComponentRegistered(id)) { return () => {
componentStore.actions.unregisterInstance(id) // Unregister component
} if (componentStore.actions.isComponentRegistered(id)) {
componentStore.actions.unregisterInstance(id)
} }
// Stop observing context changes
unobserve?.()
} }
}) })
// Observe changes to context
onMount(() => context.actions.observeChanges(handleContextChange))
</script> </script>
{#if constructor && initialSettings && (visible || inSelectedPath) && !builderHidden} {#if constructor && initialSettings && (visible || inSelectedPath) && !builderHidden}