Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class BranchesView : Subview
[SerializeField] private string newBranchName;
[SerializeField] private Vector2 scroll;
[SerializeField] private bool disableDelete;
[SerializeField] private bool disableCreate;

[SerializeField] private CacheUpdateEvent lastLocalAndRemoteBranchListChangedEvent;
[NonSerialized] private bool localAndRemoteBranchListHasUpdate;
Expand Down Expand Up @@ -102,6 +103,7 @@ private void MaybeUpdateData()
}

disableDelete = treeLocals.SelectedNode == null || treeLocals.SelectedNode.IsFolder || treeLocals.SelectedNode.IsActive;
disableCreate = treeLocals.SelectedNode == null || treeLocals.SelectedNode.IsFolder || treeLocals.SelectedNode.Level == 0;
}

public override void OnGUI()
Expand Down Expand Up @@ -134,6 +136,16 @@ private void Render()
OnTreeGUI(new Rect(0f, 0f, Position.width, Position.height - rect.height + Styles.CommitAreaPadding));
}
GUILayout.EndScrollView();

if (Event.current.type == EventType.Repaint)
{
// Effectuating mode switch
if (mode != targetMode)
{
mode = targetMode;
Redraw();
}
}
}

private void BuildTree()
Expand Down Expand Up @@ -186,10 +198,14 @@ private void OnButtonBarGUI()

// Create button
GUILayout.FlexibleSpace();
if (GUILayout.Button(CreateBranchButton, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
EditorGUI.BeginDisabledGroup(disableCreate);
{
targetMode = BranchesMode.Create;
if (GUILayout.Button(CreateBranchButton, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
{
targetMode = BranchesMode.Create;
}
}
EditorGUI.EndDisabledGroup();
}
// Branch name + cancel + create
else if (mode == BranchesMode.Create)
Expand Down