mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-30 08:34:59 +00:00
feature<SubTree>: supports git subtree
feature
This commit is contained in:
parent
6b602e70c5
commit
130b5a66ab
22 changed files with 784 additions and 10 deletions
|
@ -110,6 +110,8 @@
|
|||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="24"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="24"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.Resources>
|
||||
|
@ -326,7 +328,7 @@
|
|||
Grid.Row="7"
|
||||
x:Name="tagList"
|
||||
RowHeight="24"
|
||||
Height="200"
|
||||
MaxHeight="200"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
Visibility="{Binding ElementName=tglTags, Path=IsChecked, Converter={StaticResource BoolToCollapsed}}"
|
||||
|
@ -386,7 +388,7 @@
|
|||
Grid.Row="9"
|
||||
x:Name="submoduleList"
|
||||
RowHeight="24"
|
||||
Height="100"
|
||||
MaxHeight="100"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
Visibility="{Binding ElementName=tglSubmodules, Path=IsChecked, Converter={StaticResource BoolToCollapsed}}"
|
||||
|
@ -411,6 +413,52 @@
|
|||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<!-- SUBTREES -->
|
||||
<ToggleButton
|
||||
Grid.Row="10"
|
||||
x:Name="tglSubTrees"
|
||||
Style="{StaticResource Style.ToggleButton.Expender}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" Margin="8,0,0,0" Text="{StaticResource Text.Dashboard.SubTrees}" FontWeight="DemiBold" Foreground="{StaticResource Brush.FG2}"/>
|
||||
<TextBlock Grid.Column="1" x:Name="txtSubTreeCount" FontWeight="DemiBold" Margin="4,0,0,0" Foreground="{StaticResource Brush.FG2}"/>
|
||||
<controls:IconButton Grid.Column="2" Click="OpenAddSubTree" Width="14" Height="14" Margin="0,0,4,0" Icon="{StaticResource Icon.TreeAddNode}" ToolTip="{StaticResource Text.Dashboard.SubTrees.Add}"/>
|
||||
</Grid>
|
||||
</ToggleButton>
|
||||
<DataGrid
|
||||
Grid.Row="11"
|
||||
x:Name="subTreeList"
|
||||
RowHeight="24"
|
||||
MaxHeight="100"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
Visibility="{Binding ElementName=tglSubTrees, Path=IsChecked, Converter={StaticResource BoolToCollapsed}}"
|
||||
SelectionMode="Single"
|
||||
SelectionUnit="FullRow"
|
||||
ContextMenuOpening="OnSubTreeContextMenuOpening">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn Width="*">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Path Grid.Column="0" Width="10" Height="10" Margin="16,0,8,0" Data="{StaticResource Icon.SubTree}"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Prefix}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
|
||||
<!-- Splitter -->
|
||||
|
|
|
@ -60,6 +60,7 @@ namespace SourceGit.Views.Widgets {
|
|||
UpdateStashes();
|
||||
UpdateTags();
|
||||
UpdateSubmodules();
|
||||
UpdateSubTrees();
|
||||
|
||||
var watcher = Models.Watcher.Get(repo.Path);
|
||||
watcher.Navigate += NavigateTo;
|
||||
|
@ -68,6 +69,7 @@ namespace SourceGit.Views.Widgets {
|
|||
watcher.StashChanged += UpdateStashes;
|
||||
watcher.TagChanged += UpdateTags;
|
||||
watcher.SubmoduleChanged += UpdateSubmodules;
|
||||
watcher.SubTreeChanged += UpdateSubTrees;
|
||||
|
||||
Unloaded += (o, e) => {
|
||||
localBranches.Clear();
|
||||
|
@ -257,6 +259,14 @@ namespace SourceGit.Views.Widgets {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void UpdateSubTrees() {
|
||||
Dispatcher.Invoke(() => {
|
||||
txtSubTreeCount.Text = $"({repo.SubTrees.Count})";
|
||||
subTreeList.ItemsSource = null;
|
||||
subTreeList.ItemsSource = repo.SubTrees;
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region TOOLBAR_COMMANDS
|
||||
|
@ -909,6 +919,55 @@ namespace SourceGit.Views.Widgets {
|
|||
}
|
||||
#endregion
|
||||
|
||||
#region SUBTREES
|
||||
private void OpenAddSubTree(object sender, RoutedEventArgs e) {
|
||||
new Popups.AddSubTree(repo).Show();
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnSubTreeContextMenuOpening(object sender, ContextMenuEventArgs e) {
|
||||
var subtree = subTreeList.SelectedItem as Models.SubTree;
|
||||
if (subtree == null) return;
|
||||
|
||||
var edit = new MenuItem();
|
||||
edit.Header = App.Text("SubTree.Edit");
|
||||
edit.Click += (o, ev) => {
|
||||
new Popups.EditSubTree(repo, subtree.Prefix).Show();
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var unlink = new MenuItem();
|
||||
unlink.Header = App.Text("SubTree.Unlink");
|
||||
unlink.Click += (o, ev) => {
|
||||
new Popups.UnlinkSubTree(repo, subtree.Prefix).Show();
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var pull = new MenuItem();
|
||||
pull.Header = App.Text("SubTree.Pull");
|
||||
pull.Click += (o, ev) => {
|
||||
new Popups.SubTreePull(repo.Path, subtree).Show();
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var push = new MenuItem();
|
||||
push.Header = App.Text("SubTree.Push");
|
||||
push.Click += (o, ev) => {
|
||||
new Popups.SubTreePush(repo.Path, subtree).Show();
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var menu = new ContextMenu();
|
||||
menu.Items.Add(edit);
|
||||
menu.Items.Add(unlink);
|
||||
menu.Items.Add(new Separator());
|
||||
menu.Items.Add(pull);
|
||||
menu.Items.Add(push);
|
||||
menu.IsOpen = true;
|
||||
e.Handled = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region FILTERS
|
||||
private void OnFilterChanged(object sender, RoutedEventArgs e) {
|
||||
var toggle = sender as ToggleButton;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue