Return list instead of object
This commit is contained in:
parent
54f7db02ec
commit
c77c98f06c
|
@ -4,7 +4,7 @@
|
||||||
builderStore,
|
builderStore,
|
||||||
componentStore,
|
componentStore,
|
||||||
screenComponentErrorList,
|
screenComponentErrorList,
|
||||||
screenComponents,
|
screenComponentsList,
|
||||||
} from "@/stores/builder"
|
} from "@/stores/builder"
|
||||||
import { ActionButton, Icon, Link, Popover } from "@budibase/bbui"
|
import { ActionButton, Icon, Link, Popover } from "@budibase/bbui"
|
||||||
|
|
||||||
|
@ -12,7 +12,10 @@
|
||||||
let popover: any
|
let popover: any
|
||||||
|
|
||||||
function getErrorTitle(error: UIComponentError) {
|
function getErrorTitle(error: UIComponentError) {
|
||||||
const titleParts = [$screenComponents[error.componentId]._instanceName]
|
const titleParts = [
|
||||||
|
$screenComponentsList.find(c => c._id === error.componentId)!
|
||||||
|
._instanceName,
|
||||||
|
]
|
||||||
if (error.errorType === "setting") {
|
if (error.errorType === "setting") {
|
||||||
titleParts.push(error.label)
|
titleParts.push(error.label)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import {
|
||||||
tables,
|
tables,
|
||||||
componentTreeNodesStore,
|
componentTreeNodesStore,
|
||||||
builderStore,
|
builderStore,
|
||||||
screenComponents,
|
screenComponentsList,
|
||||||
} from "@/stores/builder"
|
} from "@/stores/builder"
|
||||||
import { buildFormSchema, getSchemaForDatasource } from "@/dataBinding"
|
import { buildFormSchema, getSchemaForDatasource } from "@/dataBinding"
|
||||||
import {
|
import {
|
||||||
|
@ -450,7 +450,7 @@ export class ComponentStore extends BudiStore<ComponentState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
const componentName = getSequentialName(
|
const componentName = getSequentialName(
|
||||||
Object.values(get(screenComponents)),
|
get(screenComponentsList),
|
||||||
`New ${definition.friendlyName || definition.name}`,
|
`New ${definition.friendlyName || definition.name}`,
|
||||||
{
|
{
|
||||||
getName: c => c._instanceName,
|
getName: c => c._instanceName,
|
||||||
|
|
|
@ -17,9 +17,8 @@ import { deploymentStore } from "./deployments.js"
|
||||||
import { contextMenuStore } from "./contextMenu.js"
|
import { contextMenuStore } from "./contextMenu.js"
|
||||||
import { snippets } from "./snippets"
|
import { snippets } from "./snippets"
|
||||||
import {
|
import {
|
||||||
screenComponents,
|
screenComponentsList,
|
||||||
screenComponentErrors,
|
screenComponentErrors,
|
||||||
findComponentsBySettingsType,
|
|
||||||
screenComponentErrorList,
|
screenComponentErrorList,
|
||||||
} from "./screenComponent"
|
} from "./screenComponent"
|
||||||
|
|
||||||
|
@ -73,9 +72,8 @@ export {
|
||||||
snippets,
|
snippets,
|
||||||
rowActions,
|
rowActions,
|
||||||
appPublished,
|
appPublished,
|
||||||
screenComponents,
|
screenComponentsList,
|
||||||
screenComponentErrors,
|
screenComponentErrors,
|
||||||
findComponentsBySettingsType,
|
|
||||||
screenComponentErrorList,
|
screenComponentErrorList,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,13 +23,10 @@ function reduceBy<TItem extends {}, TKey extends keyof TItem>(
|
||||||
key: TKey,
|
key: TKey,
|
||||||
list: TItem[]
|
list: TItem[]
|
||||||
): Record<string, TItem> {
|
): Record<string, TItem> {
|
||||||
return list.reduce(
|
return list.reduce<Record<string, TItem>>((result, item) => {
|
||||||
(result, item) => ({
|
result[item[key] as string] = item
|
||||||
...result,
|
return result
|
||||||
[item[key] as string]: item,
|
}, {})
|
||||||
}),
|
|
||||||
{}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const friendlyNameByType: Partial<Record<UIDatasourceType, string>> = {
|
const friendlyNameByType: Partial<Record<UIDatasourceType, string>> = {
|
||||||
|
@ -253,7 +250,7 @@ function getMissingAncestors(
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
export function findComponentsBySettingsType(
|
function findComponentsBySettingsType(
|
||||||
screen: Screen,
|
screen: Screen,
|
||||||
type: string | string[],
|
type: string | string[],
|
||||||
definitions: Record<string, ComponentDefinition>
|
definitions: Record<string, ComponentDefinition>
|
||||||
|
@ -303,18 +300,13 @@ export const screenComponentErrorList = derived(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
export const screenComponents = derived(
|
export const screenComponentsList = derived(
|
||||||
[selectedScreen],
|
[selectedScreen],
|
||||||
([$selectedScreen]): Record<string, Component> => {
|
([$selectedScreen]): Component[] => {
|
||||||
if (!$selectedScreen) {
|
if (!$selectedScreen) {
|
||||||
return {}
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
return findAllComponents($selectedScreen.props).reduce<
|
return findAllComponents($selectedScreen.props)
|
||||||
Record<string, Component>
|
|
||||||
>((obj, component) => {
|
|
||||||
obj[component._id] = component
|
|
||||||
return obj
|
|
||||||
}, {})
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue