Skip to content

Commit 95241aa

Browse files
committed
Disable the commands in flat view
1 parent a9ec232 commit 95241aa

File tree

3 files changed

+38
-16
lines changed

3 files changed

+38
-16
lines changed

pkg/gui/controllers/commits_files_controller.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,18 @@ func (self *CommitFilesController) GetKeybindings(opts types.KeybindingsOpts) []
110110
Tooltip: self.c.Tr.ToggleTreeViewTooltip,
111111
},
112112
{
113-
Key: opts.GetKey(opts.Config.Files.CollapseAll),
114-
Handler: self.collapseAll,
115-
Description: self.c.Tr.CollapseAll,
116-
Tooltip: self.c.Tr.CollapseAllTooltip,
113+
Key: opts.GetKey(opts.Config.Files.CollapseAll),
114+
Handler: self.collapseAll,
115+
Description: self.c.Tr.CollapseAll,
116+
Tooltip: self.c.Tr.CollapseAllTooltip,
117+
GetDisabledReason: self.require(self.isInTreeMode),
117118
},
118119
{
119-
Key: opts.GetKey(opts.Config.Files.ExpandAll),
120-
Handler: self.expandAll,
121-
Description: self.c.Tr.ExpandAll,
122-
Tooltip: self.c.Tr.ExpandAllTooltip,
120+
Key: opts.GetKey(opts.Config.Files.ExpandAll),
121+
Handler: self.expandAll,
122+
Description: self.c.Tr.ExpandAll,
123+
Tooltip: self.c.Tr.ExpandAllTooltip,
124+
GetDisabledReason: self.require(self.isInTreeMode),
123125
},
124126
}
125127

@@ -460,3 +462,11 @@ func isDescendentOfSelectedCommitFileNodes(node *filetree.CommitFileNode, select
460462
}
461463
return false
462464
}
465+
466+
func (self *CommitFilesController) isInTreeMode() *types.DisabledReason {
467+
if !self.context().CommitFileTreeViewModel.InTreeMode() {
468+
return &types.DisabledReason{Text: self.c.Tr.DisabledInFlatView}
469+
}
470+
471+
return nil
472+
}

pkg/gui/controllers/files_controller.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,16 +187,18 @@ func (self *FilesController) GetKeybindings(opts types.KeybindingsOpts) []*types
187187
Tooltip: self.c.Tr.FetchTooltip,
188188
},
189189
{
190-
Key: opts.GetKey(opts.Config.Files.CollapseAll),
191-
Handler: self.collapseAll,
192-
Description: self.c.Tr.CollapseAll,
193-
Tooltip: self.c.Tr.CollapseAllTooltip,
190+
Key: opts.GetKey(opts.Config.Files.CollapseAll),
191+
Handler: self.collapseAll,
192+
Description: self.c.Tr.CollapseAll,
193+
Tooltip: self.c.Tr.CollapseAllTooltip,
194+
GetDisabledReason: self.require(self.isInTreeMode),
194195
},
195196
{
196-
Key: opts.GetKey(opts.Config.Files.ExpandAll),
197-
Handler: self.expandAll,
198-
Description: self.c.Tr.ExpandAll,
199-
Tooltip: self.c.Tr.ExpandAllTooltip,
197+
Key: opts.GetKey(opts.Config.Files.ExpandAll),
198+
Handler: self.expandAll,
199+
Description: self.c.Tr.ExpandAll,
200+
Tooltip: self.c.Tr.ExpandAllTooltip,
201+
GetDisabledReason: self.require(self.isInTreeMode),
200202
},
201203
}
202204
}
@@ -1221,3 +1223,11 @@ func (self *FilesController) formattedPaths(nodes []*filetree.FileNode) string {
12211223
return node.GetPath()
12221224
}))
12231225
}
1226+
1227+
func (self *FilesController) isInTreeMode() *types.DisabledReason {
1228+
if !self.context().FileTreeViewModel.InTreeMode() {
1229+
return &types.DisabledReason{Text: self.c.Tr.DisabledInFlatView}
1230+
}
1231+
1232+
return nil
1233+
}

pkg/i18n/english.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ type TranslationSet struct {
260260
CollapseAllTooltip string
261261
ExpandAll string
262262
ExpandAllTooltip string
263+
DisabledInFlatView string
263264
FileEnter string
264265
FileEnterTooltip string
265266
FileStagingRequirements string
@@ -1266,6 +1267,7 @@ func EnglishTranslationSet() *TranslationSet {
12661267
CollapseAllTooltip: "Collapse all entries in the files tree",
12671268
ExpandAll: "Expand all files",
12681269
ExpandAllTooltip: "Expand all entries in the file tree",
1270+
DisabledInFlatView: "Not available in flat view",
12691271
FileEnter: `Stage lines / Collapse directory`,
12701272
FileEnterTooltip: "If the selected item is a file, focus the staging view so you can stage individual hunks/lines. If the selected item is a directory, collapse/expand it.",
12711273
FileStagingRequirements: `Can only stage individual lines for tracked files`,

0 commit comments

Comments
 (0)