mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #14703 from overleaf/jdt-collapse-history-folders
collapse folders with no changes in history view GitOrigin-RevId: 120845bfb3d645ab9ebb287b00516b5a0f6666c0
This commit is contained in:
parent
a2bb8a3ecd
commit
9759a29d75
1 changed files with 19 additions and 1 deletions
|
@ -13,6 +13,22 @@ type HistoryFileTreeFolderProps = {
|
||||||
docs: HistoryDoc[]
|
docs: HistoryDoc[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hasChanges(fileTree: HistoryFileTree): boolean {
|
||||||
|
const hasSameLevelChanges = fileTree.docs?.some(
|
||||||
|
(doc: HistoryDoc) => (doc as any).operation !== undefined
|
||||||
|
)
|
||||||
|
if (hasSameLevelChanges) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
const hasNestedChanges = fileTree.folders?.some(folder => {
|
||||||
|
return hasChanges(folder)
|
||||||
|
})
|
||||||
|
if (hasNestedChanges) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
function HistoryFileTreeFolder({
|
function HistoryFileTreeFolder({
|
||||||
name,
|
name,
|
||||||
folders,
|
folders,
|
||||||
|
@ -20,7 +36,9 @@ function HistoryFileTreeFolder({
|
||||||
}: HistoryFileTreeFolderProps) {
|
}: HistoryFileTreeFolderProps) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
const [expanded, setExpanded] = useState(true)
|
const [expanded, setExpanded] = useState(() => {
|
||||||
|
return hasChanges({ name, folders, docs })
|
||||||
|
})
|
||||||
|
|
||||||
const icons = (
|
const icons = (
|
||||||
<>
|
<>
|
||||||
|
|
Loading…
Reference in a new issue