Format with prettier

This commit is contained in:
Andrew Kingston 2020-10-27 15:28:13 +00:00
parent a93757a8d9
commit add4162000
35 changed files with 131 additions and 106 deletions

View File

@ -31,7 +31,9 @@ Cypress.Commands.add("createApp", name => {
.then($body => {
if ($body.find("input[name=apiKey]").length) {
// input was found, do something else here
cy.get("input[name=apiKey]").type(name).should("have.value", name)
cy.get("input[name=apiKey]")
.type(name)
.should("have.value", name)
cy.contains("Next").click()
}
})
@ -42,8 +44,12 @@ Cypress.Commands.add("createApp", name => {
cy.contains("Next").click()
cy.get("input[name=username]").click().type("test")
cy.get("input[name=password]").click().type("test")
cy.get("input[name=username]")
.click()
.type("test")
cy.get("input[name=password]")
.click()
.type("test")
cy.contains("Submit").click()
cy.get("[data-cy=new-table]", {
timeout: 20000,
@ -61,8 +67,12 @@ Cypress.Commands.add("createTable", tableName => {
// Enter table name
cy.get("[data-cy=new-table]").click()
cy.get(".modal").within(() => {
cy.get("input").first().type(tableName)
cy.get(".buttons").contains("Create").click()
cy.get("input")
.first()
.type(tableName)
cy.get(".buttons")
.contains("Create")
.click()
})
cy.contains(tableName).should("be.visible")
})
@ -74,7 +84,9 @@ Cypress.Commands.add("addColumn", (tableName, columnName, type) => {
// Configure column
cy.get(".menu-container").within(() => {
cy.get("input").first().type(columnName)
cy.get("input")
.first()
.type(columnName)
// Unset table display column
cy.contains("display column").click()
cy.get("select").select(type)
@ -87,11 +99,15 @@ Cypress.Commands.add("addRow", values => {
cy.get(".modal").within(() => {
for (let i = 0; i < values.length; i++) {
cy.get("input").eq(i).type(values[i])
cy.get("input")
.eq(i)
.type(values[i])
}
// Save
cy.get(".buttons").contains("Create").click()
cy.get(".buttons")
.contains("Create")
.click()
})
})
@ -100,12 +116,20 @@ Cypress.Commands.add("createUser", (username, password, accessLevel) => {
cy.get(".toprightnav > .settings").click()
cy.contains("Users").click()
cy.get("[name=Name]").first().type(username)
cy.get("[name=Password]").first().type(password)
cy.get("select").first().select(accessLevel)
cy.get("[name=Name]")
.first()
.type(username)
cy.get("[name=Password]")
.first()
.type(password)
cy.get("select")
.first()
.select(accessLevel)
// Save
cy.get(".inputs").contains("Create").click()
cy.get(".inputs")
.contains("Create")
.click()
})
Cypress.Commands.add("addHeadlineComponent", text => {
@ -131,9 +155,13 @@ Cypress.Commands.add("navigateToFrontend", () => {
Cypress.Commands.add("createScreen", (screenName, route) => {
cy.get("[data-cy=new-screen]").click()
cy.get(".modal").within(() => {
cy.get("input").eq(0).type(screenName)
cy.get("input")
.eq(0)
.type(screenName)
if (route) {
cy.get("input").eq(1).type(route)
cy.get("input")
.eq(1)
.type(route)
}
cy.contains("Create Screen").click()
})

View File

@ -9,7 +9,7 @@
$: automationCount = $automationStore.automations?.length ?? 0
function onSelect(block) {
automationStore.update((state) => {
automationStore.update(state => {
state.selectedBlock = block
return state
})

View File

@ -33,7 +33,7 @@
let popover
$: selectedTab = selectedIndex == null ? null : tabs[selectedIndex].value
$: anchor = selectedIndex === -1 ? null : anchors[selectedIndex]
$: blocks = sortBy((entry) => entry[1].name)(
$: blocks = sortBy(entry => entry[1].name)(
Object.entries($automationStore.blockDefinitions[selectedTab] ?? {})
)

View File

@ -9,7 +9,7 @@
$: selected = $automationStore.selectedBlock?.id === block.id
$: steps =
$automationStore.selectedAutomation?.automation?.definition?.steps ?? []
$: blockIdx = steps.findIndex((step) => step.id === block.id)
$: blockIdx = steps.findIndex(step => step.id === block.id)
$: allowDeleteTrigger = !steps.length
function deleteStep() {

View File

@ -22,7 +22,7 @@
if (automation.trigger) {
allSteps = [automation.trigger, ...allSteps]
}
const blockIdx = allSteps.findIndex((step) => step.id === block.id)
const blockIdx = allSteps.findIndex(step => step.id === block.id)
// Extract all outputs from all previous steps as available bindings
let bindings = []

View File

@ -6,9 +6,7 @@
export let value
export let bindings
$: table = $backendUiStore.tables.find(
(table) => table._id === value?.tableId
)
$: table = $backendUiStore.tables.find(table => table._id === value?.tableId)
$: schemaFields = Object.entries(table?.schema ?? {})
// Ensure any nullish tableId values get set to empty string so

View File

@ -22,12 +22,12 @@
$backendUiStore.selectedTable.primaryDisplay == null ||
$backendUiStore.selectedTable.primaryDisplay === field.name
$: tableOptions = $backendUiStore.tables.filter(
(table) => table._id !== $backendUiStore.draftTable._id
table => table._id !== $backendUiStore.draftTable._id
)
$: required = !!field?.constraints?.presence || primaryDisplay
async function saveColumn() {
backendUiStore.update((state) => {
backendUiStore.update(state => {
backendUiStore.actions.tables.saveField({
originalName,
field,

View File

@ -69,16 +69,15 @@
const fileArray = Array.from(evt.target.files)
if (fileArray.some(file => file.size >= FILE_SIZE_LIMIT)) {
notifier.danger(
`Files cannot exceed ${
FILE_SIZE_LIMIT / BYTES_IN_MB
}MB. Please try again with smaller files.`
`Files cannot exceed ${FILE_SIZE_LIMIT /
BYTES_IN_MB}MB. Please try again with smaller files.`
)
return
}
// Read CSV as plain text to upload alongside schema
let reader = new FileReader()
reader.addEventListener("load", function (e) {
reader.addEventListener("load", function(e) {
csvString = e.target.result
files = fileArray
validateCSV()

View File

@ -23,7 +23,7 @@
function checkValid(evt) {
const tableName = evt.target.value
if ($backendUiStore.models?.some((model) => model.name === tableName)) {
if ($backendUiStore.models?.some(model => model.name === tableName)) {
error = `Table with name ${tableName} already exists. Please choose another name.`
return
}
@ -49,8 +49,8 @@
// Create auto screens
const screens = screenTemplates($store, [table])
.filter((template) => defaultScreens.includes(template.id))
.map((template) => template.create())
.filter(template => defaultScreens.includes(template.id))
.map(template => template.create())
for (let screen of screens) {
// Record the table that created this screen so we can link it later
screen.autoTableId = table._id
@ -67,7 +67,7 @@
}
// Create autolink to newly created list page
const listPage = screens.find((screen) =>
const listPage = screens.find(screen =>
screen.props._instanceName.endsWith("List")
)
await store.createLink(listPage.route, table.name)

View File

@ -9,9 +9,8 @@
function handleFileTooLarge(fileSizeLimit) {
notifier.danger(
`Files cannot exceed ${
fileSizeLimit / BYTES_IN_MB
}MB. Please try again with smaller files.`
`Files cannot exceed ${fileSizeLimit /
BYTES_IN_MB}MB. Please try again with smaller files.`
)
}

View File

@ -22,7 +22,7 @@
let isApiKeyValid
let lastApiKey
let fetchApiKeyPromise
const validateApiKey = async (apiKey) => {
const validateApiKey = async apiKey => {
if (!apiKey) return false
// make sure we only fetch once, unless API Key is changed
@ -121,7 +121,9 @@
const fullSchema = Object.assign({}, ...validationSchemas)
// Check full form schema
const formIsValid = await object().shape(fullSchema).isValid(values)
const formIsValid = await object()
.shape(fullSchema)
.isValid(values)
fullFormIsValid = formIsValid
}
}

View File

@ -16,7 +16,7 @@
return props
}
const getComponentTypeName = (component) => {
const getComponentTypeName = component => {
let [componentName] = component._component.match(/[a-z]*$/)
return componentName || "element"
}
@ -144,7 +144,7 @@
}
$: stylesheetLinks = pipe($store.pages.stylesheets, [
map((s) => `<link rel="stylesheet" href="${s}"/>`),
map(s => `<link rel="stylesheet" href="${s}"/>`),
join("\n"),
])

View File

@ -1,7 +1,7 @@
<script>
export let categories = []
export let selectedCategory = {}
export let onClick = (category) => {}
export let onClick = category => {}
</script>
<div class="tabs">

View File

@ -18,27 +18,27 @@
!component || !getComponentDefinition($store, component._component).children
$: noPaste = !$store.componentToPaste
const lastPartOfName = (c) => (c ? last(c._component.split("/")) : "")
const lastPartOfName = c => (c ? last(c._component.split("/")) : "")
const hideDropdown = () => {
dropdown.hide()
}
const selectComponent = (component) => {
const selectComponent = component => {
store.selectComponent(component)
const path = store.getPathToComponent(component)
$goto(`./:page/:screen/${path}`)
}
const moveUpComponent = () => {
store.update((s) => {
store.update(s => {
const parent = getParent(s.currentPreviewItem.props, component)
if (parent) {
const currentIndex = parent._children.indexOf(component)
if (currentIndex === 0) return s
const newChildren = parent._children.filter((c) => c !== component)
const newChildren = parent._children.filter(c => c !== component)
newChildren.splice(currentIndex - 1, 0, component)
parent._children = newChildren
}
@ -50,14 +50,14 @@
}
const moveDownComponent = () => {
store.update((s) => {
store.update(s => {
const parent = getParent(s.currentPreviewItem.props, component)
if (parent) {
const currentIndex = parent._children.indexOf(component)
if (currentIndex === parent._children.length - 1) return s
const newChildren = parent._children.filter((c) => c !== component)
const newChildren = parent._children.filter(c => c !== component)
newChildren.splice(currentIndex + 1, 0, component)
parent._children = newChildren
}
@ -74,11 +74,11 @@
}
const deleteComponent = () => {
store.update((state) => {
store.update(state => {
const parent = getParent(state.currentPreviewItem.props, component)
if (parent) {
parent._children = parent._children.filter((c) => c !== component)
parent._children = parent._children.filter(c => c !== component)
selectComponent(parent)
}
@ -92,7 +92,7 @@
store.storeComponentForCopy(component, cut)
}
const pasteComponent = (mode) => {
const pasteComponent = mode => {
// lives in store - also used by drag drop
store.pasteComponent(component, mode)
}

View File

@ -20,7 +20,7 @@
$: componentPropDefinition =
flattenedPanel.find(
//use for getting controls for each component property
(c) => c._component === componentInstance._component
c => c._component === componentInstance._component
) || {}
$: panelDefinition =
@ -48,8 +48,8 @@
function flattenComponents(props) {
const components = []
props.forEach((comp) =>
walkProps(comp, (c) => {
props.forEach(comp =>
walkProps(comp, c => {
if ("_component" in c) {
components.push(c)
}
@ -64,7 +64,7 @@
</script>
<CategoryTab
onClick={(category) => (selectedCategory = category)}
onClick={category => (selectedCategory = category)}
{categories}
{selectedCategory} />

View File

@ -24,7 +24,7 @@
}
}
const onComponentChosen = (component) => {
const onComponentChosen = component => {
store.addChildComponent(component._component, component.presetProps)
const path = store.getPathToComponent($store.currentComponentInfo)
$goto(`./:page/:screen/${path}`)

View File

@ -23,7 +23,7 @@
let confirmDeleteDialog
let componentToDelete = ""
const normalizedName = (name) =>
const normalizedName = name =>
pipe(name, [
trimCharsStart("./"),
trimCharsStart("~/"),
@ -31,7 +31,7 @@
trimChars(" "),
])
const changeScreen = (screen) => {
const changeScreen = screen => {
store.setCurrentScreen(screen.props._instanceName)
$goto(`./:page/${screen.props._instanceName}`)
}

View File

@ -33,12 +33,12 @@
let dropUnderComponent
let componentToDrop
const capitalise = (s) => s.substring(0, 1).toUpperCase() + s.substring(1)
const get_name = (s) => (!s ? "" : last(s.split("/")))
const get_capitalised_name = (name) => pipe(name, [get_name, capitalise])
const isScreenslot = (name) => name === "##builtin/screenslot"
const capitalise = s => s.substring(0, 1).toUpperCase() + s.substring(1)
const get_name = s => (!s ? "" : last(s.split("/")))
const get_capitalised_name = name => pipe(name, [get_name, capitalise])
const isScreenslot = name => name === "##builtin/screenslot"
const selectComponent = (component) => {
const selectComponent = component => {
// Set current component
store.selectComponent(component)
@ -49,21 +49,21 @@
$goto(`./:page/:screen/${path}`)
}
const dragstart = (component) => (e) => {
const dragstart = component => e => {
e.dataTransfer.dropEffect = "move"
dragDropStore.update((s) => {
dragDropStore.update(s => {
s.componentToDrop = component
return s
})
}
const dragover = (component, index) => (e) => {
const dragover = (component, index) => e => {
const canHaveChildrenButIsEmpty =
getComponentDefinition($store, component._component).children &&
component._children.length === 0
e.dataTransfer.dropEffect = "copy"
dragDropStore.update((s) => {
dragDropStore.update(s => {
const isBottomHalf = e.offsetY > e.currentTarget.offsetHeight / 2
s.targetComponent = component
// only allow dropping inside when container type
@ -102,7 +102,7 @@
$dragDropStore.dropPosition
)
}
dragDropStore.update((s) => {
dragDropStore.update(s => {
s.dropPosition = ""
s.targetComponent = null
s.componentToDrop = null
@ -111,7 +111,7 @@
}
const dragend = () => {
dragDropStore.update((s) => {
dragDropStore.update(s => {
s.dropPosition = ""
s.targetComponent = null
s.componentToDrop = null

View File

@ -12,7 +12,7 @@
let propGroup = null
let currentGroup
const getProperties = (name) => panelDefinition[name]
const getProperties = name => panelDefinition[name]
function onChange(category) {
selectedCategory = category

View File

@ -15,11 +15,11 @@
return [
...$store.screens
.filter(
(screen) =>
screen =>
screen.props._component.endsWith("/rowdetail") ||
screen.route.endsWith(":id")
)
.map((screen) => ({
.map(screen => ({
name: screen.props._instanceName,
url: screen.route,
sort: screen.props._component,

View File

@ -18,19 +18,19 @@
$: actions = event || []
$: selectedActionComponent =
selectedAction &&
actionTypes.find((t) => t.name === selectedAction[EVENT_TYPE_MEMBER_NAME])
actionTypes.find(t => t.name === selectedAction[EVENT_TYPE_MEMBER_NAME])
.component
const updateEventHandler = (updatedHandler, index) => {
actions[index] = updatedHandler
}
const deleteAction = (index) => {
const deleteAction = index => {
actions.splice(index, 1)
actions = actions
}
const addAction = (actionType) => () => {
const addAction = actionType => () => {
const newAction = {
parameters: {},
[EVENT_TYPE_MEMBER_NAME]: actionType.name,
@ -41,7 +41,7 @@
addActionDropdown.hide()
}
const selectAction = (action) => () => {
const selectAction = action => () => {
selectedAction = action
}

View File

@ -6,7 +6,7 @@
let isOpen = false
const capitalize = (s) => {
const capitalize = s => {
if (typeof s !== "string") return ""
return s.charAt(0).toUpperCase() + s.slice(1)
}
@ -17,7 +17,7 @@
{#if parameter.name === 'automation'}
<Select on:change bind:value={parameter.value}>
<option value="" />
{#each $automationStore.automations.filter((wf) => wf.live) as automation}
{#each $automationStore.automations.filter(wf => wf.live) as automation}
<option value={automation._id}>{automation.name}</option>
{/each}
</Select>

View File

@ -3,7 +3,7 @@
export let value = ""
export let text = ""
export let icon = ""
export let onClick = (value) => {}
export let onClick = value => {}
export let selected = false
$: useIcon = !!icon

View File

@ -50,7 +50,7 @@
function findIconByTerm(term) {
const r = new RegExp(`\^${term}`, "i")
return icons.filter((i) => r.test(i.label))
return icons.filter(i => r.test(i.label))
}
async function switchLetter(letter) {
@ -65,7 +65,7 @@
async function findIconOnPage() {
loading = true
const iconIdx = filteredIcons.findIndex((i) => i.value === value)
const iconIdx = filteredIcons.findIndex(i => i.value === value)
if (iconIdx !== -1) {
currentPage = Math.ceil(iconIdx / maxIconsPerPage)
}

View File

@ -6,7 +6,7 @@
export let options = []
export let value = ""
export let styleBindingProperty
export let onChange = (value) => {}
export let onChange = value => {}
let open = null
let rotate = ""
@ -23,7 +23,7 @@
let scrollTop = 0
let containerEl = null
const handleStyleBind = (value) =>
const handleStyleBind = value =>
!!styleBindingProperty ? { style: `${styleBindingProperty}: ${value}` } : {}
onMount(() => {
@ -95,10 +95,10 @@
width: `${width}px`,
})
$: isOptionsObject = options.every((o) => typeof o === "object")
$: isOptionsObject = options.every(o => typeof o === "object")
$: selectedOption = isOptionsObject
? options.find((o) => o.value === value)
? options.find(o => o.value === value)
: {}
$: if (open && selectMenu) {

View File

@ -13,7 +13,7 @@
const dragDropStore = writable({})
const lastPartOfName = (c) =>
const lastPartOfName = c =>
c && last(c.name ? c.name.split("/") : c._component.split("/"))
$: _layout = {

View File

@ -21,7 +21,7 @@
if (!$store.currentPageName)
store.setCurrentPage($params.page ? $params.page : "main")
const changePage = (id) => {
const changePage = id => {
store.setCurrentPage(id)
$goto(`./${id}/page-layout`)
}

View File

@ -78,7 +78,7 @@
}
//Incase the component has a different value key name
const handlevalueKey = (value) =>
const handlevalueKey = value =>
props.valueKey ? { [props.valueKey]: safeValue() } : { value: safeValue() }
</script>
@ -89,8 +89,8 @@
this={control}
{componentInstance}
{...handlevalueKey(value)}
on:change={(val) => handleChange(key, val)}
onChange={(val) => handleChange(key, val)}
on:change={val => handleChange(key, val)}
onChange={val => handleChange(key, val)}
{...props}
name={key} />
</div>
@ -109,7 +109,7 @@
<BindingDropdown
{...handlevalueKey(value)}
close={dropdown.hide}
on:update={(e) => (temporaryBindableValue = e.detail)}
on:update={e => (temporaryBindableValue = e.detail)}
{bindableProperties} />
</DropdownMenu>
{/if}

View File

@ -14,7 +14,7 @@
const deleteScreen = () => {
store.deleteScreens(screen, $store.currentPageName)
// update the page if required
store.update((state) => {
store.update(state => {
if (state.currentPreviewItem.name === screen.name) {
store.setCurrentPage($store.currentPageName)
$goto(`./:page/page-layout`)

View File

@ -18,8 +18,8 @@
const getUrls = () => {
const urls = [
...$store.screens
.filter((screen) => !screen.props._component.endsWith("/rowdetail"))
.map((screen) => ({
.filter(screen => !screen.props._component.endsWith("/rowdetail"))
.map(screen => ({
name: screen.props._instanceName,
url: screen.route,
sort: screen.props._component,
@ -33,12 +33,12 @@
tables: $backendUiStore.tables,
})
const detailScreens = $store.screens.filter((screen) =>
const detailScreens = $store.screens.filter(screen =>
screen.props._component.endsWith("/rowdetail")
)
for (let detailScreen of detailScreens) {
const idBinding = bindableProperties.find((p) => {
const idBinding = bindableProperties.find(p => {
if (
p.type === "context" &&
p.runtimeBinding.endsWith("._id") &&

View File

@ -18,7 +18,7 @@
let pageScreenProps = ["title", "favicon", "description", "route"]
let duplicateName = false
const propExistsOnComponentDef = (prop) =>
const propExistsOnComponentDef = prop =>
pageScreenProps.includes(prop) || prop in componentDefinition.props
function handleChange(key, data) {
@ -47,10 +47,10 @@
$: isPage = screenOrPageInstance && screenOrPageInstance.favicon
$: screenOrPageDefinition = isPage ? pageDefinition : screenDefinition
const isDuplicateName = (name) => {
const isDuplicateName = name => {
let duplicate = false
const lookForDuplicate = (rootPops) => {
const lookForDuplicate = rootPops => {
walkProps(rootPops, (inst, cancel) => {
if (inst._instanceName === name && inst._id !== componentInstance._id) {
duplicate = true

View File

@ -14,7 +14,7 @@
dropdownRight.hide()
}
$: tables = $backendUiStore.tables.map((m) => ({
$: tables = $backendUiStore.tables.map(m => ({
label: m.name,
name: `all_${m._id}`,
tableId: m._id,
@ -39,8 +39,8 @@
})
$: links = bindableProperties
.filter((x) => x.fieldSchema.type === "link")
.map((property) => ({
.filter(x => x.fieldSchema.type === "link")
.map(property => ({
label: property.readableBinding,
fieldName: property.fieldSchema.name,
name: `all_${property.fieldSchema.tableId}`,

View File

@ -30,10 +30,10 @@
// e.g. if one of your screens is selected on front end, then
// you browse to backend, when you click frontend, you will be
// brought back to the same screen
const topItemNavigate = (path) => () => {
const activeTopNav = $layout.children.find((c) => $isActive(c.path))
const topItemNavigate = path => () => {
const activeTopNav = $layout.children.find(c => $isActive(c.path))
if (!activeTopNav) return
store.update((state) => {
store.update(state => {
if (!state.previousTopNavPath) state.previousTopNavPath = {}
state.previousTopNavPath[
activeTopNav.path

View File

@ -27,7 +27,7 @@
settingsView.show()
}
const lastPartOfName = (c) => (c ? last(c.split("/")) : "")
const lastPartOfName = c => (c ? last(c.split("/")) : "")
</script>
<!-- routify:options index=1 -->

View File

@ -8,9 +8,8 @@
function handleFileTooLarge(fileSizeLimit) {
alert(
`Files cannot exceed ${
fileSizeLimit / BYTES_IN_MB
}MB. Please try again with smaller files.`
`Files cannot exceed ${fileSizeLimit /
BYTES_IN_MB}MB. Please try again with smaller files.`
)
}