mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
feature: add context menu item to move repository node (#437)
This commit is contained in:
parent
837e3889b7
commit
dffd9d7676
7 changed files with 196 additions and 0 deletions
|
@ -354,6 +354,8 @@
|
||||||
<x:String x:Key="Text.Merge.Into" xml:space="preserve">Into:</x:String>
|
<x:String x:Key="Text.Merge.Into" xml:space="preserve">Into:</x:String>
|
||||||
<x:String x:Key="Text.Merge.Mode" xml:space="preserve">Merge Option:</x:String>
|
<x:String x:Key="Text.Merge.Mode" xml:space="preserve">Merge Option:</x:String>
|
||||||
<x:String x:Key="Text.Merge.Source" xml:space="preserve">Source Branch:</x:String>
|
<x:String x:Key="Text.Merge.Source" xml:space="preserve">Source Branch:</x:String>
|
||||||
|
<x:String x:Key="Text.MoveRepositoryNode" xml:space="preserve">Move Repository Node</x:String>
|
||||||
|
<x:String x:Key="Text.MoveRepositoryNode.Target" xml:space="preserve">Select parent node for:</x:String>
|
||||||
<x:String x:Key="Text.Name" xml:space="preserve">Name:</x:String>
|
<x:String x:Key="Text.Name" xml:space="preserve">Name:</x:String>
|
||||||
<x:String x:Key="Text.NotConfigured" xml:space="preserve">Git has NOT been configured. Please to go [Preference] and configure it first.</x:String>
|
<x:String x:Key="Text.NotConfigured" xml:space="preserve">Git has NOT been configured. Please to go [Preference] and configure it first.</x:String>
|
||||||
<x:String x:Key="Text.Notice" xml:space="preserve">NOTICE</x:String>
|
<x:String x:Key="Text.Notice" xml:space="preserve">NOTICE</x:String>
|
||||||
|
@ -588,6 +590,7 @@
|
||||||
<x:String x:Key="Text.Welcome.Delete" xml:space="preserve">Delete</x:String>
|
<x:String x:Key="Text.Welcome.Delete" xml:space="preserve">Delete</x:String>
|
||||||
<x:String x:Key="Text.Welcome.DragDropTip" xml:space="preserve">DRAG & DROP FOLDER SUPPORTED. CUSTOM GROUPING SUPPORTED.</x:String>
|
<x:String x:Key="Text.Welcome.DragDropTip" xml:space="preserve">DRAG & DROP FOLDER SUPPORTED. CUSTOM GROUPING SUPPORTED.</x:String>
|
||||||
<x:String x:Key="Text.Welcome.Edit" xml:space="preserve">Edit</x:String>
|
<x:String x:Key="Text.Welcome.Edit" xml:space="preserve">Edit</x:String>
|
||||||
|
<x:String x:Key="Text.Welcome.Move" xml:space="preserve">Move to Another Group</x:String>
|
||||||
<x:String x:Key="Text.Welcome.OpenAllInNode" xml:space="preserve">Open All Repositories</x:String>
|
<x:String x:Key="Text.Welcome.OpenAllInNode" xml:space="preserve">Open All Repositories</x:String>
|
||||||
<x:String x:Key="Text.Welcome.OpenOrInit" xml:space="preserve">Open Repository</x:String>
|
<x:String x:Key="Text.Welcome.OpenOrInit" xml:space="preserve">Open Repository</x:String>
|
||||||
<x:String x:Key="Text.Welcome.OpenTerminal" xml:space="preserve">Open Terminal</x:String>
|
<x:String x:Key="Text.Welcome.OpenTerminal" xml:space="preserve">Open Terminal</x:String>
|
||||||
|
|
|
@ -357,6 +357,8 @@
|
||||||
<x:String x:Key="Text.Merge.Into" xml:space="preserve">目标分支 :</x:String>
|
<x:String x:Key="Text.Merge.Into" xml:space="preserve">目标分支 :</x:String>
|
||||||
<x:String x:Key="Text.Merge.Mode" xml:space="preserve">合并方式 :</x:String>
|
<x:String x:Key="Text.Merge.Mode" xml:space="preserve">合并方式 :</x:String>
|
||||||
<x:String x:Key="Text.Merge.Source" xml:space="preserve">合并分支 :</x:String>
|
<x:String x:Key="Text.Merge.Source" xml:space="preserve">合并分支 :</x:String>
|
||||||
|
<x:String x:Key="Text.MoveRepositoryNode" xml:space="preserve">调整仓库分组</x:String>
|
||||||
|
<x:String x:Key="Text.MoveRepositoryNode.Target" xml:space="preserve">请选择目标分组:</x:String>
|
||||||
<x:String x:Key="Text.Name" xml:space="preserve">名称 :</x:String>
|
<x:String x:Key="Text.Name" xml:space="preserve">名称 :</x:String>
|
||||||
<x:String x:Key="Text.NotConfigured" xml:space="preserve">GIT尚未配置。请打开【偏好设置】配置GIT路径。</x:String>
|
<x:String x:Key="Text.NotConfigured" xml:space="preserve">GIT尚未配置。请打开【偏好设置】配置GIT路径。</x:String>
|
||||||
<x:String x:Key="Text.Notice" xml:space="preserve">系统提示</x:String>
|
<x:String x:Key="Text.Notice" xml:space="preserve">系统提示</x:String>
|
||||||
|
@ -590,6 +592,7 @@
|
||||||
<x:String x:Key="Text.Welcome.Delete" xml:space="preserve">删除</x:String>
|
<x:String x:Key="Text.Welcome.Delete" xml:space="preserve">删除</x:String>
|
||||||
<x:String x:Key="Text.Welcome.DragDropTip" xml:space="preserve">支持拖放目录添加。支持自定义分组。</x:String>
|
<x:String x:Key="Text.Welcome.DragDropTip" xml:space="preserve">支持拖放目录添加。支持自定义分组。</x:String>
|
||||||
<x:String x:Key="Text.Welcome.Edit" xml:space="preserve">编辑</x:String>
|
<x:String x:Key="Text.Welcome.Edit" xml:space="preserve">编辑</x:String>
|
||||||
|
<x:String x:Key="Text.Welcome.Move" xml:space="preserve">调整分组</x:String>
|
||||||
<x:String x:Key="Text.Welcome.OpenAllInNode" xml:space="preserve">打开所有包含仓库</x:String>
|
<x:String x:Key="Text.Welcome.OpenAllInNode" xml:space="preserve">打开所有包含仓库</x:String>
|
||||||
<x:String x:Key="Text.Welcome.OpenOrInit" xml:space="preserve">打开本地仓库</x:String>
|
<x:String x:Key="Text.Welcome.OpenOrInit" xml:space="preserve">打开本地仓库</x:String>
|
||||||
<x:String x:Key="Text.Welcome.OpenTerminal" xml:space="preserve">打开终端</x:String>
|
<x:String x:Key="Text.Welcome.OpenTerminal" xml:space="preserve">打开终端</x:String>
|
||||||
|
|
|
@ -357,6 +357,8 @@
|
||||||
<x:String x:Key="Text.Merge.Into" xml:space="preserve">目標分支:</x:String>
|
<x:String x:Key="Text.Merge.Into" xml:space="preserve">目標分支:</x:String>
|
||||||
<x:String x:Key="Text.Merge.Mode" xml:space="preserve">合併方式:</x:String>
|
<x:String x:Key="Text.Merge.Mode" xml:space="preserve">合併方式:</x:String>
|
||||||
<x:String x:Key="Text.Merge.Source" xml:space="preserve">合併分支:</x:String>
|
<x:String x:Key="Text.Merge.Source" xml:space="preserve">合併分支:</x:String>
|
||||||
|
<x:String x:Key="Text.MoveRepositoryNode" xml:space="preserve">調整存放庫分組</x:String>
|
||||||
|
<x:String x:Key="Text.MoveRepositoryNode.Target" xml:space="preserve">請選擇目標分組:</x:String>
|
||||||
<x:String x:Key="Text.Name" xml:space="preserve">名稱:</x:String>
|
<x:String x:Key="Text.Name" xml:space="preserve">名稱:</x:String>
|
||||||
<x:String x:Key="Text.NotConfigured" xml:space="preserve">尚未設定 Git。請開啟 [偏好設定] 以設定 Git 路徑。</x:String>
|
<x:String x:Key="Text.NotConfigured" xml:space="preserve">尚未設定 Git。請開啟 [偏好設定] 以設定 Git 路徑。</x:String>
|
||||||
<x:String x:Key="Text.Notice" xml:space="preserve">系統提示</x:String>
|
<x:String x:Key="Text.Notice" xml:space="preserve">系統提示</x:String>
|
||||||
|
@ -591,6 +593,7 @@
|
||||||
<x:String x:Key="Text.Welcome.Delete" xml:space="preserve">刪除</x:String>
|
<x:String x:Key="Text.Welcome.Delete" xml:space="preserve">刪除</x:String>
|
||||||
<x:String x:Key="Text.Welcome.DragDropTip" xml:space="preserve">支援拖放以新增目錄與自訂群組。</x:String>
|
<x:String x:Key="Text.Welcome.DragDropTip" xml:space="preserve">支援拖放以新增目錄與自訂群組。</x:String>
|
||||||
<x:String x:Key="Text.Welcome.Edit" xml:space="preserve">編輯</x:String>
|
<x:String x:Key="Text.Welcome.Edit" xml:space="preserve">編輯</x:String>
|
||||||
|
<x:String x:Key="Text.Welcome.Move" xml:space="preserve">調整存放庫分組</x:String>
|
||||||
<x:String x:Key="Text.Welcome.OpenAllInNode" xml:space="preserve">開啟所有包含存放庫</x:String>
|
<x:String x:Key="Text.Welcome.OpenAllInNode" xml:space="preserve">開啟所有包含存放庫</x:String>
|
||||||
<x:String x:Key="Text.Welcome.OpenOrInit" xml:space="preserve">開啟本機存放庫</x:String>
|
<x:String x:Key="Text.Welcome.OpenOrInit" xml:space="preserve">開啟本機存放庫</x:String>
|
||||||
<x:String x:Key="Text.Welcome.OpenTerminal" xml:space="preserve">開啟終端機</x:String>
|
<x:String x:Key="Text.Welcome.OpenTerminal" xml:space="preserve">開啟終端機</x:String>
|
||||||
|
|
72
src/ViewModels/MoveRepositoryNode.cs
Normal file
72
src/ViewModels/MoveRepositoryNode.cs
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SourceGit.ViewModels
|
||||||
|
{
|
||||||
|
public class MoveRepositoryNode : Popup
|
||||||
|
{
|
||||||
|
public RepositoryNode Target
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
} = null;
|
||||||
|
|
||||||
|
public List<RepositoryNode> Rows
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
} = [];
|
||||||
|
|
||||||
|
public RepositoryNode Selected
|
||||||
|
{
|
||||||
|
get => _selected;
|
||||||
|
set => SetProperty(ref _selected, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MoveRepositoryNode(RepositoryNode target)
|
||||||
|
{
|
||||||
|
Target = target;
|
||||||
|
Rows.Add(new RepositoryNode() {
|
||||||
|
Name = "ROOT",
|
||||||
|
Depth = 0,
|
||||||
|
Id = Guid.NewGuid().ToString()
|
||||||
|
});
|
||||||
|
MakeRows(Preference.Instance.RepositoryNodes, 1);
|
||||||
|
|
||||||
|
View = new Views.MoveRepositoryNode() { DataContext = this };
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Task<bool> Sure()
|
||||||
|
{
|
||||||
|
if (_selected != null)
|
||||||
|
{
|
||||||
|
var node = Preference.Instance.FindNode(_selected.Id);
|
||||||
|
Preference.Instance.MoveNode(Target, node, true);
|
||||||
|
Welcome.Instance.Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MakeRows(List<RepositoryNode> collection, int depth)
|
||||||
|
{
|
||||||
|
foreach (var node in collection)
|
||||||
|
{
|
||||||
|
if (node.IsRepository || node.Id == Target.Id)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var dump = new RepositoryNode()
|
||||||
|
{
|
||||||
|
Name = node.Name,
|
||||||
|
Depth = depth,
|
||||||
|
Id = node.Id
|
||||||
|
};
|
||||||
|
Rows.Add(dump);
|
||||||
|
MakeRows(node.SubNodes, depth + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private RepositoryNode _selected = null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -172,6 +172,18 @@ namespace SourceGit.ViewModels
|
||||||
};
|
};
|
||||||
menu.Items.Add(edit);
|
menu.Items.Add(edit);
|
||||||
|
|
||||||
|
var move = new MenuItem();
|
||||||
|
move.Header = App.Text("Welcome.Move");
|
||||||
|
move.Icon = App.CreateMenuIcon("Icons.Move");
|
||||||
|
move.Click += (_, e) =>
|
||||||
|
{
|
||||||
|
if (PopupHost.CanCreatePopup())
|
||||||
|
PopupHost.ShowPopup(new MoveRepositoryNode(node));
|
||||||
|
|
||||||
|
e.Handled = true;
|
||||||
|
};
|
||||||
|
menu.Items.Add(move);
|
||||||
|
|
||||||
if (node.IsRepository)
|
if (node.IsRepository)
|
||||||
{
|
{
|
||||||
var explore = new MenuItem();
|
var explore = new MenuItem();
|
||||||
|
|
89
src/Views/MoveRepositoryNode.axaml
Normal file
89
src/Views/MoveRepositoryNode.axaml
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:v="using:SourceGit.Views"
|
||||||
|
xmlns:vm="using:SourceGit.ViewModels"
|
||||||
|
xmlns:c="using:SourceGit.Converters"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="SourceGit.Views.MoveRepositoryNode"
|
||||||
|
x:DataType="vm:MoveRepositoryNode">
|
||||||
|
<StackPanel Orientation="Vertical" Margin="8,0,0,0">
|
||||||
|
<TextBlock FontSize="18"
|
||||||
|
Classes="bold"
|
||||||
|
Text="{DynamicResource Text.MoveRepositoryNode}"/>
|
||||||
|
|
||||||
|
<StackPanel Height="28" Margin="4,16,4,0" Orientation="Horizontal">
|
||||||
|
<TextBlock VerticalAlignment="Center" Margin="0,0,8,0" Text="{DynamicResource Text.MoveRepositoryNode.Target}"/>
|
||||||
|
<TextBlock VerticalAlignment="Center" Text="{Binding Target.Name, Mode=OneTime}"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<ListBox x:Name="TreeContainer"
|
||||||
|
Margin="4,0"
|
||||||
|
Padding="4"
|
||||||
|
MinHeight="28"
|
||||||
|
MaxHeight="100"
|
||||||
|
Focusable="True"
|
||||||
|
BorderThickness="1"
|
||||||
|
BorderBrush="{DynamicResource Brush.Border2}"
|
||||||
|
CornerRadius="4"
|
||||||
|
Background="{DynamicResource Brush.Contents}"
|
||||||
|
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||||
|
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||||
|
ItemsSource="{Binding Rows}"
|
||||||
|
SelectionMode="Single"
|
||||||
|
SelectedItem="{Binding Selected, Mode=TwoWay}">
|
||||||
|
<ListBox.Styles>
|
||||||
|
<Style Selector="ListBox">
|
||||||
|
<Setter Property="FocusAdorner">
|
||||||
|
<FocusAdornerTemplate>
|
||||||
|
<Border Background="Transparent" BorderThickness="0"/>
|
||||||
|
</FocusAdornerTemplate>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="ListBoxItem" x:DataType="vm:RepositoryNode">
|
||||||
|
<Setter Property="Margin" Value="0"/>
|
||||||
|
<Setter Property="Padding" Value="0"/>
|
||||||
|
<Setter Property="Height" Value="30"/>
|
||||||
|
<Setter Property="CornerRadius" Value="4"/>
|
||||||
|
<Setter Property="FocusAdorner">
|
||||||
|
<FocusAdornerTemplate>
|
||||||
|
<Border Background="Transparent" BorderThickness="0"/>
|
||||||
|
</FocusAdornerTemplate>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</ListBox.Styles>
|
||||||
|
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate DataType="vm:RepositoryNode">
|
||||||
|
<Grid Background="Transparent"
|
||||||
|
Height="30"
|
||||||
|
ColumnDefinitions="16,18,Auto,*"
|
||||||
|
Margin="{Binding Depth, Converter={x:Static c:IntConverters.ToTreeMargin}}"
|
||||||
|
ClipToBounds="True">
|
||||||
|
<ToggleButton Grid.Column="0"
|
||||||
|
Classes="tree_expander"
|
||||||
|
Focusable="False"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
IsChecked="True"
|
||||||
|
IsHitTestVisible="False"/>
|
||||||
|
|
||||||
|
<ToggleButton Grid.Column="1"
|
||||||
|
Classes="folder"
|
||||||
|
Focusable="False"
|
||||||
|
Width="14" Height="14"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Foreground="{DynamicResource Brush.FG1}"
|
||||||
|
IsChecked="True"/>
|
||||||
|
|
||||||
|
<TextBlock Grid.Column="2"
|
||||||
|
Classes="primary"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="{Binding Name}"/>
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
</StackPanel>
|
||||||
|
</UserControl>
|
14
src/Views/MoveRepositoryNode.axaml.cs
Normal file
14
src/Views/MoveRepositoryNode.axaml.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
using Avalonia.Controls;
|
||||||
|
|
||||||
|
namespace SourceGit.Views
|
||||||
|
{
|
||||||
|
public partial class MoveRepositoryNode : UserControl
|
||||||
|
{
|
||||||
|
public MoveRepositoryNode()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue