|
8 | 8 | import { AI_SERVICE } from '$lib/ai/service'; |
9 | 9 | import { projectAiGenEnabled } from '$lib/config/config'; |
10 | 10 | import { conflictEntryHint } from '$lib/conflictEntryPresence'; |
| 11 | + import { |
| 12 | + getLockedCommitIds, |
| 13 | + getLockedStackIds, |
| 14 | + isFileLocked |
| 15 | + } from '$lib/dependencies/dependencies'; |
| 16 | + import { DEPENDENCY_SERVICE } from '$lib/dependencies/dependencyService.svelte'; |
11 | 17 | import { editPatch } from '$lib/editMode/editPatchUtils'; |
12 | 18 | import { abbreviateFolders, changesToFileTree } from '$lib/files/filetreeV3'; |
13 | 19 | import { type TreeChange, isExecutableStatus } from '$lib/hunks/change'; |
|
35 | 41 | conflictEntries?: ConflictEntriesObj; |
36 | 42 | draggableFiles?: boolean; |
37 | 43 | ancestorMostConflictedCommitId?: string; |
38 | | - hideLastFileBorder?: boolean; |
39 | 44 | onselect?: (change: TreeChange) => void; |
40 | 45 | allowUnselect?: boolean; |
| 46 | + showLockedIndicator?: boolean; |
41 | 47 | }; |
42 | 48 |
|
43 | 49 | const { |
|
50 | 56 | conflictEntries, |
51 | 57 | draggableFiles, |
52 | 58 | ancestorMostConflictedCommitId, |
53 | | - hideLastFileBorder = true, |
54 | 59 | onselect, |
55 | | - allowUnselect = true |
| 60 | + allowUnselect = true, |
| 61 | + showLockedIndicator = false |
56 | 62 | }: Props = $props(); |
57 | 63 |
|
58 | 64 | const focusManager = inject(FOCUS_MANAGER); |
59 | 65 | const idSelection = inject(FILE_SELECTION_MANAGER); |
60 | 66 | const aiService = inject(AI_SERVICE); |
61 | 67 | const actionService = inject(ACTION_SERVICE); |
62 | 68 | const modeService = injectOptional(MODE_SERVICE, undefined); |
| 69 | + const dependencyService = inject(DEPENDENCY_SERVICE); |
63 | 70 |
|
64 | 71 | const [autoCommit] = actionService.autoCommit; |
65 | 72 | const [branchChanges] = actionService.branchChanges; |
|
68 | 75 | let editPatchModal: EditPatchConfirmModal | undefined = $state(); |
69 | 76 | let selectedFilePath = $state(''); |
70 | 77 |
|
| 78 | + const filePaths = $derived(changes.map((change) => change.path)); |
| 79 | + const fileDependenciesQuery = $derived( |
| 80 | + showLockedIndicator ? dependencyService.filesDependencies(projectId, filePaths) : null |
| 81 | + ); |
| 82 | + const fileDependencies = $derived(fileDependenciesQuery?.result.data || []); |
| 83 | +
|
71 | 84 | function showEditPatchConfirmation(filePath: string) { |
72 | 85 | selectedFilePath = filePath; |
73 | 86 | editPatchModal?.show(); |
|
240 | 253 | {#snippet fileTemplate(change: TreeChange, idx: number, depth: number = 0)} |
241 | 254 | {@const isExecutable = isExecutableStatus(change.status)} |
242 | 255 | {@const selected = idSelection.has(change.path, selectionId)} |
| 256 | + {@const locked = showLockedIndicator && isFileLocked(change.path, fileDependencies)} |
| 257 | + {@const lockedCommitIds = showLockedIndicator |
| 258 | + ? getLockedCommitIds(change.path, fileDependencies) |
| 259 | + : []} |
| 260 | + {@const lockedStackIds = showLockedIndicator |
| 261 | + ? getLockedStackIds(change.path, fileDependencies) |
| 262 | + : []} |
243 | 263 | <FileListItemWrapper |
244 | 264 | {selectionId} |
245 | 265 | {change} |
|
249 | 269 | {listMode} |
250 | 270 | {depth} |
251 | 271 | {active} |
252 | | - hideBorder={hideLastFileBorder && idx === visibleFiles.length - 1} |
| 272 | + {locked} |
| 273 | + {lockedCommitIds} |
| 274 | + {lockedStackIds} |
| 275 | + hideBorder={idx === visibleFiles.length - 1} |
253 | 276 | draggable={draggableFiles} |
254 | 277 | executable={isExecutable} |
255 | 278 | showCheckbox={showCheckboxes} |
|
0 commit comments