diff --git a/packages/builder/src/builderStore/store/automation/index.js b/packages/builder/src/builderStore/store/automation/index.js index 2c1636b359..e1db07053e 100644 --- a/packages/builder/src/builderStore/store/automation/index.js +++ b/packages/builder/src/builderStore/store/automation/index.js @@ -3,14 +3,14 @@ import api from "../../api" import Automation from "./Automation" import { cloneDeep } from "lodash/fp" -const automationActions = (store) => ({ +const automationActions = store => ({ fetch: async () => { const responses = await Promise.all([ api.get(`/api/automations`), api.get(`/api/automations/definitions/list`), ]) - const jsonResponses = await Promise.all(responses.map((x) => x.json())) - store.update((state) => { + const jsonResponses = await Promise.all(responses.map(x => x.json())) + store.update(state => { state.automations = jsonResponses[0] state.blockDefinitions = { TRIGGER: jsonResponses[1].trigger, @@ -31,7 +31,7 @@ const automationActions = (store) => ({ const CREATE_AUTOMATION_URL = `/api/automations` const response = await api.post(CREATE_AUTOMATION_URL, automation) const json = await response.json() - store.update((state) => { + store.update(state => { state.automations = [...state.automations, json.automation] store.actions.select(json.automation) return state @@ -41,9 +41,9 @@ const automationActions = (store) => ({ const UPDATE_AUTOMATION_URL = `/api/automations` const response = await api.put(UPDATE_AUTOMATION_URL, automation) const json = await response.json() - store.update((state) => { + store.update(state => { const existingIdx = state.automations.findIndex( - (existing) => existing._id === automation._id + existing => existing._id === automation._id ) state.automations.splice(existingIdx, 1, json.automation) state.automations = state.automations @@ -56,9 +56,9 @@ const automationActions = (store) => ({ const DELETE_AUTOMATION_URL = `/api/automations/${_id}/${_rev}` await api.delete(DELETE_AUTOMATION_URL) - store.update((state) => { + store.update(state => { const existingIdx = state.automations.findIndex( - (existing) => existing._id === _id + existing => existing._id === _id ) state.automations.splice(existingIdx, 1) state.automations = state.automations @@ -72,24 +72,24 @@ const automationActions = (store) => ({ const TRIGGER_AUTOMATION_URL = `/api/automations/${_id}/trigger` return await api.post(TRIGGER_AUTOMATION_URL) }, - select: (automation) => { - store.update((state) => { + select: automation => { + store.update(state => { state.selectedAutomation = new Automation(cloneDeep(automation)) state.selectedBlock = null return state }) }, - addBlockToAutomation: (block) => { - store.update((state) => { + addBlockToAutomation: block => { + store.update(state => { const newBlock = state.selectedAutomation.addBlock(cloneDeep(block)) state.selectedBlock = newBlock return state }) }, - deleteAutomationBlock: (block) => { - store.update((state) => { + deleteAutomationBlock: block => { + store.update(state => { const idx = state.selectedAutomation.automation.definition.steps.findIndex( - (x) => x.id === block.id + x => x.id === block.id ) state.selectedAutomation.deleteBlock(block.id) diff --git a/packages/builder/src/components/backend/TableNavigator/TableNavigator.svelte b/packages/builder/src/components/backend/TableNavigator/TableNavigator.svelte index 0b73074e10..5a57fe6a4a 100644 --- a/packages/builder/src/components/backend/TableNavigator/TableNavigator.svelte +++ b/packages/builder/src/components/backend/TableNavigator/TableNavigator.svelte @@ -36,7 +36,7 @@ {#if $backendUiStore.selectedDatabase && $backendUiStore.selectedDatabase._id}

Tables

- +
{#each $backendUiStore.tables as table, idx} diff --git a/packages/builder/src/components/userInterface/pagesParsing/searchComponents.js b/packages/builder/src/components/userInterface/pagesParsing/searchComponents.js index a24dec7d8a..9979d4dcc6 100644 --- a/packages/builder/src/components/userInterface/pagesParsing/searchComponents.js +++ b/packages/builder/src/components/userInterface/pagesParsing/searchComponents.js @@ -1,21 +1,21 @@ import { isUndefined, filter, some, includes } from "lodash/fp" import { pipe } from "../../../helpers" -const normalString = (s) => (s || "").trim().toLowerCase() +const normalString = s => (s || "").trim().toLowerCase() -export const isRootComponent = (c) => +export const isRootComponent = c => isComponent(c) && isUndefined(c.props._component) -export const isComponent = (c) => { - const hasProp = (n) => !isUndefined(c[n]) +export const isComponent = c => { + const hasProp = n => !isUndefined(c[n]) return hasProp("name") && hasProp("props") } export const searchAllComponents = (components, phrase) => { const hasPhrase = (...vals) => - pipe(vals, [some((v) => includes(normalString(phrase))(normalString(v)))]) + pipe(vals, [some(v => includes(normalString(phrase))(normalString(v)))]) - const componentMatches = (c) => { + const componentMatches = c => { if (hasPhrase(c._instanceName, ...(c.tags || []))) return true if (isRootComponent(c)) return false @@ -29,7 +29,7 @@ export const searchAllComponents = (components, phrase) => { } export const getExactComponent = (components, name, isScreen = false) => { - return components.find((c) => + return components.find(c => isScreen ? c.props._instanceName === name : c._instanceName === name ) } diff --git a/packages/builder/src/components/userInterface/pagesParsing/splitRootComponentName.js b/packages/builder/src/components/userInterface/pagesParsing/splitRootComponentName.js index c7a355405b..1776ddf230 100644 --- a/packages/builder/src/components/userInterface/pagesParsing/splitRootComponentName.js +++ b/packages/builder/src/components/userInterface/pagesParsing/splitRootComponentName.js @@ -1,7 +1,7 @@ import { split, last } from "lodash/fp" import { pipe } from "../../../helpers" -export const splitName = (fullname) => { +export const splitName = fullname => { const componentName = pipe(fullname, [split("/"), last]) const libName = fullname.substring( diff --git a/packages/builder/src/helpers.js b/packages/builder/src/helpers.js index 8de210c159..89c7a0a6aa 100644 --- a/packages/builder/src/helpers.js +++ b/packages/builder/src/helpers.js @@ -1,6 +1,6 @@ import { last, flow } from "lodash/fp" -export const buildStyle = (styles) => { +export const buildStyle = styles => { let str = "" for (let s in styles) { if (styles[s]) { @@ -11,15 +11,14 @@ export const buildStyle = (styles) => { return str } -export const convertCamel = (str) => { - return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`) +export const convertCamel = str => { + return str.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`) } export const pipe = (arg, funcs) => flow(funcs)(arg) -export const capitalise = (s) => - s.substring(0, 1).toUpperCase() + s.substring(1) +export const capitalise = s => s.substring(0, 1).toUpperCase() + s.substring(1) -export const get_name = (s) => (!s ? "" : last(s.split("/"))) +export const get_name = s => (!s ? "" : last(s.split("/"))) -export const get_capitalised_name = (name) => pipe(name, [get_name, capitalise]) +export const get_capitalised_name = name => pipe(name, [get_name, capitalise])