new comonent name -
when on master unique across all screens
This commit is contained in:
parent
c2fd54a250
commit
877b9a7fd4
|
@ -2,25 +2,30 @@ import { walkProps } from "./storeUtils"
|
||||||
import { get_capitalised_name } from "../helpers"
|
import { get_capitalised_name } from "../helpers"
|
||||||
|
|
||||||
export default function(component, state) {
|
export default function(component, state) {
|
||||||
const screen =
|
|
||||||
state.currentFrontEndType === "screen" ? state.currentPreviewItem : null
|
|
||||||
const page = state.pages[state.currentPageName]
|
|
||||||
const capitalised = get_capitalised_name(component)
|
const capitalised = get_capitalised_name(component)
|
||||||
|
|
||||||
const matchingComponents = []
|
const matchingComponents = []
|
||||||
|
|
||||||
if (screen)
|
const findMatches = props => {
|
||||||
walkProps(screen.props, c => {
|
walkProps(props, c => {
|
||||||
if ((c._instanceName || "").startsWith(capitalised)) {
|
if ((c._instanceName || "").startsWith(capitalised)) {
|
||||||
matchingComponents.push(c._instanceName)
|
matchingComponents.push(c._instanceName)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
walkProps(page.props, c => {
|
// check page first
|
||||||
if ((c._instanceName || "").startsWith(capitalised)) {
|
findMatches(state.pages[state.currentPageName].props)
|
||||||
matchingComponents.push(c._instanceName)
|
|
||||||
|
// if viewing screen, check current screen for duplicate
|
||||||
|
if (state.currentFrontEndType === "screen") {
|
||||||
|
findMatches(state.currentPreviewItem.props)
|
||||||
|
} else {
|
||||||
|
// viewing master page - need to find against all screens
|
||||||
|
for (let screen of state.screens) {
|
||||||
|
findMatches(screen.props)
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
let index = 1
|
let index = 1
|
||||||
let name
|
let name
|
||||||
|
|
Loading…
Reference in New Issue