Merge remote-tracking branch 'origin/develop' into feature/skippable-tours

This commit is contained in:
Dean 2023-07-17 16:14:56 +01:00
commit da677864c0
11 changed files with 98 additions and 10 deletions

View File

@ -1,5 +1,5 @@
{
"version": "2.8.10-alpha.2",
"version": "2.8.10-alpha.4",
"npmClient": "yarn",
"packages": [
"packages/*"

View File

@ -248,4 +248,36 @@ const automationActions = store => ({
}
await store.actions.save(newAutomation)
},
replace: async (automationId, automation) => {
if (!automation) {
store.update(state => {
// Remove the automation
state.automations = state.automations.filter(
x => x._id !== automationId
)
// Select a new automation if required
if (automationId === state.selectedAutomationId) {
store.actions.select(state.automations[0]?._id)
}
return state
})
} else {
const index = get(store).automations.findIndex(
x => x._id === automation._id
)
if (index === -1) {
// Automation addition
store.update(state => ({
...state,
automations: [...state.automations, automation],
}))
} else {
// Automation update
store.update(state => {
state.automations[index] = automation
return state
})
}
}
},
})

View File

@ -1,5 +1,10 @@
import { createWebsocket } from "@budibase/frontend-core"
import { userStore, store, deploymentStore } from "builderStore"
import {
userStore,
store,
deploymentStore,
automationStore,
} from "builderStore"
import { datasources, tables } from "stores/backend"
import { get } from "svelte/store"
import { auth } from "stores/portal"
@ -67,5 +72,10 @@ export const createBuilderWebsocket = appId => {
}
)
// Automations
socket.onOther(BuilderSocketEvent.AutomationChange, ({ id, automation }) => {
automationStore.actions.replace(id, automation)
})
return socket
}

View File

@ -1,6 +1,10 @@
<script>
import { onMount } from "svelte"
import { automationStore, selectedAutomation } from "builderStore"
import {
automationStore,
selectedAutomation,
userSelectedResourceMap,
} from "builderStore"
import NavItem from "components/common/NavItem.svelte"
import EditAutomationPopover from "./EditAutomationPopover.svelte"
import { notifications } from "@budibase/bbui"
@ -21,13 +25,13 @@
</script>
<div class="automations-list">
{#each $automationStore.automations.sort(aut => aut.name) as automation, idx}
{#each $automationStore.automations.sort(aut => aut.name) as automation}
<NavItem
border={idx > 0}
icon="ShareAndroid"
text={automation.name}
selected={automation._id === selectedAutomationId}
on:click={() => selectAutomation(automation._id)}
selectedBy={$userSelectedResourceMap[automation._id]}
>
<EditAutomationPopover {automation} />
</NavItem>
@ -40,6 +44,5 @@
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
margin: 0 calc(-1 * var(--spacing-xl));
}
</style>

View File

@ -11,8 +11,8 @@
<Panel title="Automations" borderRight>
<Layout paddingX="L" paddingY="XL" gap="S">
<Button cta on:click={modal.show}>Add automation</Button>
<AutomationList />
</Layout>
<AutomationList />
</Panel>
<Modal bind:this={modal}>

View File

@ -7,6 +7,8 @@
closeBrackets,
completionKeymap,
closeBracketsKeymap,
acceptCompletion,
completionStatus,
} from "@codemirror/autocomplete"
import {
EditorView,
@ -34,7 +36,8 @@
defaultKeymap,
historyKeymap,
history,
indentWithTab,
indentMore,
indentLess,
} from "@codemirror/commands"
import { Compartment } from "@codemirror/state"
import { javascript } from "@codemirror/lang-javascript"
@ -107,6 +110,22 @@
let isDark = !currentTheme.includes("light")
let themeConfig = new Compartment()
const indentWithTabCustom = {
key: "Tab",
run: view => {
if (completionStatus(view.state) == "active") {
acceptCompletion(view)
return true
}
indentMore(view)
return true
},
shift: view => {
indentLess(view)
return true
},
}
const buildKeymap = () => {
const baseMap = [
...closeBracketsKeymap,
@ -114,7 +133,7 @@
...historyKeymap,
...foldKeymap,
...completionKeymap,
indentWithTab,
indentWithTabCustom,
]
return baseMap
}

View File

@ -226,7 +226,7 @@
.top-nav {
flex: 0 0 60px;
background: var(--background);
padding: 0 var(--spacing-xl);
padding-left: var(--spacing-xl);
display: grid;
grid-template-columns: 1fr auto 1fr;
flex-direction: row;

View File

@ -8,6 +8,10 @@
import { onDestroy, onMount } from "svelte"
import { syncURLToState } from "helpers/urlStateSync"
import * as routify from "@roxi/routify"
import { store } from "builderStore"
$: automationId = $selectedAutomation?._id
$: store.actions.websocket.selectResource(automationId)
// Keep URL and state in sync for selected screen ID
const stopSyncing = syncURLToState({

View File

@ -24,6 +24,7 @@ import {
import { getActionDefinitions as actionDefs } from "../../automations/actions"
import sdk from "../../sdk"
import { db as dbCore } from "@budibase/backend-core"
import { builderSocket } from "../../websockets"
async function getActionDefinitions() {
return removeDeprecated(await actionDefs())
@ -107,6 +108,7 @@ export async function create(ctx: BBContext) {
...response,
},
}
builderSocket?.emitAutomationUpdate(ctx, automation)
}
export function getNewSteps(oldAutomation: Automation, automation: Automation) {
@ -187,6 +189,7 @@ export async function update(ctx: BBContext) {
_id: response.id,
},
}
builderSocket?.emitAutomationUpdate(ctx, automation)
}
export async function fetch(ctx: BBContext) {
@ -215,6 +218,7 @@ export async function destroy(ctx: BBContext) {
await cleanupAutomationMetadata(automationId)
ctx.body = await db.remove(automationId, ctx.params.rev)
await events.automation.deleted(oldAutomation)
builderSocket?.emitAutomationDeletion(ctx, automationId)
}
export async function logSearch(ctx: BBContext) {

View File

@ -10,6 +10,7 @@ import {
ContextUser,
Screen,
App,
Automation,
} from "@budibase/types"
import { gridSocket } from "./index"
import { clearLock, updateLock } from "../utilities/redis"
@ -156,4 +157,18 @@ export default class BuilderSocket extends BaseSocket {
user: ctx.user,
})
}
emitAutomationUpdate(ctx: any, automation: Automation) {
this.emitToRoom(ctx, ctx.appId, BuilderSocketEvent.AutomationChange, {
id: automation._id,
automation,
})
}
emitAutomationDeletion(ctx: any, id: string) {
this.emitToRoom(ctx, ctx.appId, BuilderSocketEvent.AutomationChange, {
id,
automation: null,
})
}
}

View File

@ -90,6 +90,7 @@ export enum BuilderSocketEvent {
AppMetadataChange = "AppMetadataChange",
SelectResource = "SelectResource",
AppPublishChange = "AppPublishChange",
AutomationChange = "AutomationChange",
}
export const SocketSessionTTL = 60