Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 961c997

Browse files
Restoring functionality to work with trees
Adding functionality to check/uncheck all Restoring intergations with ChangesView
1 parent e2b2a19 commit 961c997

File tree

2 files changed

+42
-34
lines changed

2 files changed

+42
-34
lines changed

src/GitHub.Api/UI/TreeBase.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,24 @@ public void Load(IEnumerable<TData> treeDatas)
102102
}
103103
}
104104

105+
public void CheckAll(bool isChecked)
106+
{
107+
var nodeCheckState = isChecked ? CheckState.Checked : CheckState.Empty;
108+
foreach (var node in Nodes)
109+
{
110+
var wasChecked = node.CheckState == CheckState.Checked;
111+
node.CheckState = nodeCheckState;
112+
if (isChecked && !wasChecked)
113+
{
114+
AddCheckedNode(node);
115+
}
116+
else if (!isChecked && wasChecked)
117+
{
118+
RemoveCheckedNode(node);
119+
}
120+
}
121+
}
122+
105123
protected abstract IEnumerable<string> GetCollapsedFolders();
106124

107125
protected void AddNode(string path, string label, int level, bool isFolder, bool isActive, bool isHidden,

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/ChangesView.cs

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public override void OnGUI()
5757
{
5858
GUILayout.BeginHorizontal();
5959
{
60-
EditorGUI.BeginDisabledGroup(false);
60+
EditorGUI.BeginDisabledGroup(gitStatusEntries == null || !gitStatusEntries.Any());
6161
{
6262
if (GUILayout.Button(SelectAllButton, EditorStyles.miniButtonLeft))
6363
{
@@ -258,48 +258,38 @@ private void OnCommitDetailsAreaGUI()
258258

259259
private void SelectAll()
260260
{
261-
// for (var index = 0; index < tree.CommitTargets.Count; ++index)
262-
// {
263-
// tree.CommitTargets[index].All = true;
264-
// }
261+
this.treeChanges.CheckAll(true);
265262
}
266263

267264
private void SelectNone()
268265
{
269-
// for (var index = 0; index < tree.CommitTargets.Count; ++index)
270-
// {
271-
// tree.CommitTargets[index].All = false;
272-
// }
266+
this.treeChanges.CheckAll(false);
273267
}
274268

275269
private void Commit()
276270
{
277271
// Do not allow new commits before we have received one successful update
278-
// isBusy = true;
279-
//
280-
// var files = Enumerable.Range(0, tree.Entries.Count)
281-
// .Where(i => tree.CommitTargets[i].All)
282-
// .Select(i => tree.Entries[i].Path)
283-
// .ToList();
284-
//
285-
// ITask addTask;
286-
//
287-
// if (files.Count == tree.Entries.Count)
288-
// {
289-
// addTask = Repository.CommitAllFiles(commitMessage, commitBody);
290-
// }
291-
// else
292-
// {
293-
// addTask = Repository.CommitFiles(files, commitMessage, commitBody);
294-
// }
295-
//
296-
// addTask
297-
// .FinallyInUI((b, exception) =>
298-
// {
299-
// commitMessage = "";
300-
// commitBody = "";
301-
// isBusy = false;
302-
// }).Start();
272+
isBusy = true;
273+
274+
var files = treeChanges.GetCheckedFiles().ToList();
275+
ITask addTask;
276+
277+
if (files.Count == gitStatusEntries.Count)
278+
{
279+
addTask = Repository.CommitAllFiles(commitMessage, commitBody);
280+
}
281+
else
282+
{
283+
addTask = Repository.CommitFiles(files, commitMessage, commitBody);
284+
}
285+
286+
addTask
287+
.FinallyInUI((b, exception) =>
288+
{
289+
commitMessage = "";
290+
commitBody = "";
291+
isBusy = false;
292+
}).Start();
303293
}
304294

305295
public override bool IsBusy

0 commit comments

Comments
 (0)