Projects in OutlinePanel have a conflict indicator
This commit is contained in:
parent
d10b313d57
commit
e50daa3ba7
2 changed files with 28 additions and 1 deletions
|
@ -155,7 +155,8 @@ const BaseItem: React.FC<{
|
||||||
select?: VoidFn
|
select?: VoidFn
|
||||||
depth: number
|
depth: number
|
||||||
selectionStatus: SelectionStatus
|
selectionStatus: SelectionStatus
|
||||||
}> = ({label, children, depth, select, selectionStatus}) => {
|
labelDecoration?: React.ReactNode
|
||||||
|
}> = ({label, children, depth, select, selectionStatus, labelDecoration}) => {
|
||||||
const canContainChildren = children !== undefined
|
const canContainChildren = children !== undefined
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -177,6 +178,7 @@ const BaseItem: React.FC<{
|
||||||
</Head_IconContainer>
|
</Head_IconContainer>
|
||||||
|
|
||||||
<Head_Label>{label}</Head_Label>
|
<Head_Label>{label}</Head_Label>
|
||||||
|
{labelDecoration}
|
||||||
</Header>
|
</Header>
|
||||||
{canContainChildren && <ChildrenContainer>{children}</ChildrenContainer>}
|
{canContainChildren && <ChildrenContainer>{children}</ChildrenContainer>}
|
||||||
</Container>
|
</Container>
|
||||||
|
|
|
@ -5,21 +5,46 @@ import SheetsList from '@theatre/studio/panels/OutlinePanel/SheetsList/SheetsLis
|
||||||
import getStudio from '@theatre/studio/getStudio'
|
import getStudio from '@theatre/studio/getStudio'
|
||||||
import {usePrism} from '@theatre/dataverse-react'
|
import {usePrism} from '@theatre/dataverse-react'
|
||||||
import {getOutlineSelection} from '@theatre/studio/selectors'
|
import {getOutlineSelection} from '@theatre/studio/selectors'
|
||||||
|
import {val} from '@theatre/dataverse'
|
||||||
|
import styled from 'styled-components'
|
||||||
|
|
||||||
|
const ConflictNotice = styled.div`
|
||||||
|
color: #ff6363;
|
||||||
|
margin-left: 11px;
|
||||||
|
background: #ff00002b;
|
||||||
|
padding: 2px 8px;
|
||||||
|
border-radius: 2px;
|
||||||
|
font-size: 10px;
|
||||||
|
box-shadow: 0 2px 8px -4px black;
|
||||||
|
`
|
||||||
|
|
||||||
const ProjectListItem: React.FC<{
|
const ProjectListItem: React.FC<{
|
||||||
depth: number
|
depth: number
|
||||||
project: Project
|
project: Project
|
||||||
}> = ({depth, project}) => {
|
}> = ({depth, project}) => {
|
||||||
const selection = usePrism(() => getOutlineSelection(), [])
|
const selection = usePrism(() => getOutlineSelection(), [])
|
||||||
|
|
||||||
|
const hasConflict = usePrism(() => {
|
||||||
|
const projectId = project.address.projectId
|
||||||
|
const loadingState = val(
|
||||||
|
getStudio().atomP.ephemeral.coreByProject[projectId].loadingState,
|
||||||
|
)
|
||||||
|
return loadingState?.type === 'browserStateIsNotBasedOnDiskState'
|
||||||
|
}, [project])
|
||||||
|
|
||||||
const select = useCallback(() => {
|
const select = useCallback(() => {
|
||||||
getStudio().transaction(({stateEditors}) => {
|
getStudio().transaction(({stateEditors}) => {
|
||||||
stateEditors.studio.historic.panels.outline.selection.set([project])
|
stateEditors.studio.historic.panels.outline.selection.set([project])
|
||||||
})
|
})
|
||||||
}, [project])
|
}, [project])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseItem
|
<BaseItem
|
||||||
depth={depth}
|
depth={depth}
|
||||||
label={project.address.projectId}
|
label={project.address.projectId}
|
||||||
|
labelDecoration={
|
||||||
|
hasConflict ? <ConflictNotice>Has Conflicts</ConflictNotice> : null
|
||||||
|
}
|
||||||
children={<SheetsList project={project} depth={depth + 1} />}
|
children={<SheetsList project={project} depth={depth + 1} />}
|
||||||
selectionStatus={
|
selectionStatus={
|
||||||
selection.includes(project)
|
selection.includes(project)
|
||||||
|
|
Loading…
Reference in a new issue