Lint
This commit is contained in:
parent
5e6047b4f0
commit
bf14c3045d
|
@ -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)
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
{#if $backendUiStore.selectedDatabase && $backendUiStore.selectedDatabase._id}
|
||||
<div class="title">
|
||||
<h1>Tables</h1>
|
||||
<i on:click={modal.show} class="ri-add-circle-fill" />
|
||||
<i data-cy="new-table" on:click={modal.show} class="ri-add-circle-fill" />
|
||||
</div>
|
||||
<div class="hierarchy-items-container">
|
||||
{#each $backendUiStore.tables as table, idx}
|
||||
|
|
|
@ -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
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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])
|
||||
|
|
Loading…
Reference in New Issue