Disable Git panel button to open commit editor in certain cases (#26000)
Also: - Internally renames a bit of code to make it easy to identify between when we are disabling the buttons that open and close the modal editor (in Git Panel and Project Diff) vs when we are disabling the commit buttons (in Git Panel and Git commit editor modal). - Deletes some unused code. Release Notes: - Unified disabling / enabling the button to open the Git commit editor modal in the Git panel with the Project Diff commit button. - Unified disabling / enabling the commit buttons, for the same cases, between the Git panel and Git commit editor modal.
This commit is contained in:
parent
1f7fa80166
commit
8c4da9fba0
4 changed files with 19 additions and 33 deletions
|
@ -257,14 +257,14 @@ impl ProjectDiff {
|
|||
}
|
||||
}
|
||||
}
|
||||
let mut commit = false;
|
||||
let mut can_open_commit_editor = false;
|
||||
let mut stage_all = false;
|
||||
let mut unstage_all = false;
|
||||
self.workspace
|
||||
.read_with(cx, |workspace, cx| {
|
||||
if let Some(git_panel) = workspace.panel::<GitPanel>(cx) {
|
||||
let git_panel = git_panel.read(cx);
|
||||
commit = git_panel.can_commit();
|
||||
can_open_commit_editor = git_panel.can_open_commit_editor();
|
||||
stage_all = git_panel.can_stage_all();
|
||||
unstage_all = git_panel.can_unstage_all();
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ impl ProjectDiff {
|
|||
unstage: has_staged_hunks,
|
||||
prev_next,
|
||||
selection,
|
||||
commit,
|
||||
can_open_commit_editor,
|
||||
stage_all,
|
||||
unstage_all,
|
||||
};
|
||||
|
@ -773,7 +773,7 @@ struct ButtonStates {
|
|||
selection: bool,
|
||||
stage_all: bool,
|
||||
unstage_all: bool,
|
||||
commit: bool,
|
||||
can_open_commit_editor: bool,
|
||||
}
|
||||
|
||||
impl Render for ProjectDiffToolbar {
|
||||
|
@ -949,7 +949,7 @@ impl Render for ProjectDiffToolbar {
|
|||
)
|
||||
.child(
|
||||
Button::new("commit", "Commit")
|
||||
.disabled(!button_states.commit)
|
||||
.disabled(!button_states.can_open_commit_editor)
|
||||
.tooltip(Tooltip::for_action_title_in(
|
||||
"Commit",
|
||||
&ShowCommitEditor,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue