feat: fix repository enter issue.
This commit is contained in:
parent
14a4ccd6f6
commit
11d690d22b
@ -185,7 +185,9 @@ public class RepositoryService : BaseService<RepositoryService>
|
|||||||
var isFolderExists = Directory.Exists(PathUtility.GetWorkspacePath(repo.OwnerName, repo.Name));
|
var isFolderExists = Directory.Exists(PathUtility.GetWorkspacePath(repo.OwnerName, repo.Name));
|
||||||
var isDbFileExists = File.Exists(PathUtility.GetWorkspaceDbPath(repo.OwnerName, repo.Name));
|
var isDbFileExists = File.Exists(PathUtility.GetWorkspaceDbPath(repo.OwnerName, repo.Name));
|
||||||
|
|
||||||
return isFolderExists && isDbFileExists;
|
repo.IsDownloaded = isFolderExists && isDbFileExists;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async ValueTask<bool> UpdateMembersFromServerAsync(RepositoryModel repo)
|
public async ValueTask<bool> UpdateMembersFromServerAsync(RepositoryModel repo)
|
||||||
@ -282,10 +284,6 @@ public class RepositoryService : BaseService<RepositoryService>
|
|||||||
// Create basic structures.
|
// Create basic structures.
|
||||||
if (!TryCreateRepositoryBaseStorageStructure(repo)) return false;
|
if (!TryCreateRepositoryBaseStorageStructure(repo)) return false;
|
||||||
|
|
||||||
if (!await UpdateCommitsFromServerAsync(repo)) return false;
|
|
||||||
var peekCommit = repo.Commits.MaxBy(sl => sl.CommittedOn);
|
|
||||||
if (peekCommit == null) return false; // Should not use this function!
|
|
||||||
|
|
||||||
repo.IsDownloaded = true;
|
repo.IsDownloaded = true;
|
||||||
_openedRepos.Add(repo);
|
_openedRepos.Add(repo);
|
||||||
return true;
|
return true;
|
||||||
@ -351,7 +349,7 @@ public class RepositoryService : BaseService<RepositoryService>
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var rsp = await api.Gateway.PeekCommit(repo.Name, repo.OwnerName);
|
var rsp = await api.Gateway.PeekCommit(repo.OwnerName, repo.Name);
|
||||||
var emptyRepo = repo.Commits.Count == 0;
|
var emptyRepo = repo.Commits.Count == 0;
|
||||||
|
|
||||||
// If they both empty
|
// If they both empty
|
||||||
@ -378,7 +376,7 @@ public class RepositoryService : BaseService<RepositoryService>
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var rsp = await api.Gateway.ListCommit(repo.Name, repo.OwnerName);
|
var rsp = await api.Gateway.ListCommit(repo.OwnerName, repo.Name);
|
||||||
|
|
||||||
// Update existed
|
// Update existed
|
||||||
var dict = rsp.Result.ToDictionary(m => m.Id);
|
var dict = rsp.Result.ToDictionary(m => m.Id);
|
||||||
|
|||||||
@ -30,6 +30,8 @@ public partial class HomeViewModel : ViewModelBase, IRoutableViewModel
|
|||||||
HostScreen = hostScreen;
|
HostScreen = hostScreen;
|
||||||
Api.C.ServerUrl.SubscribeOn(AvaloniaScheduler.Instance)
|
Api.C.ServerUrl.SubscribeOn(AvaloniaScheduler.Instance)
|
||||||
.Subscribe(v => ServerFriendlyName = v ?? "Unknown Server");
|
.Subscribe(v => ServerFriendlyName = v ?? "Unknown Server");
|
||||||
|
|
||||||
|
RefreshRepositoriesCommand.Execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
[ReactiveCommand]
|
[ReactiveCommand]
|
||||||
@ -46,7 +48,7 @@ public partial class HomeViewModel : ViewModelBase, IRoutableViewModel
|
|||||||
var opt = new OverlayDialogOptions
|
var opt = new OverlayDialogOptions
|
||||||
{
|
{
|
||||||
FullScreen = false,
|
FullScreen = false,
|
||||||
Buttons = DialogButton.OK,
|
Buttons = DialogButton.OKCancel,
|
||||||
CanResize = false,
|
CanResize = false,
|
||||||
CanDragMove = false,
|
CanDragMove = false,
|
||||||
IsCloseButtonVisible = true,
|
IsCloseButtonVisible = true,
|
||||||
@ -87,9 +89,27 @@ public partial class HomeViewModel : ViewModelBase, IRoutableViewModel
|
|||||||
private async Task DeleteRepositoryAsync()
|
private async Task DeleteRepositoryAsync()
|
||||||
{
|
{
|
||||||
if (_selectedRepository == null) return;
|
if (_selectedRepository == null) return;
|
||||||
if (await RepositoryService.C.DeleteFromDiskAsync(_selectedRepository))
|
var opt = new OverlayDialogOptions
|
||||||
{
|
{
|
||||||
await RepositoryService.C.UpdateDownloadedStatusFromDiskAsync(_selectedRepository);
|
FullScreen = false,
|
||||||
|
Buttons = DialogButton.YesNo,
|
||||||
|
CanResize = false,
|
||||||
|
CanDragMove = false,
|
||||||
|
IsCloseButtonVisible = true,
|
||||||
|
CanLightDismiss = true,
|
||||||
|
Mode = DialogMode.Question
|
||||||
|
};
|
||||||
|
|
||||||
|
var vm = new SimpleMessageDialogViewModel(
|
||||||
|
$"Do you really want to delete a CLONE of repository {_selectedRepository.StandaloneName} ?");
|
||||||
|
|
||||||
|
var mr = await OverlayDialog
|
||||||
|
.ShowModal<SimpleMessageDialogView, SimpleMessageDialogViewModel>(vm, AppDefaultValues.HostId, opt);
|
||||||
|
|
||||||
|
if (mr == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
if (await RepositoryService.C.DeleteFromDiskAsync(_selectedRepository))
|
||||||
|
await RepositoryService.C.UpdateDownloadedStatusFromDiskAsync(_selectedRepository);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -81,7 +81,7 @@
|
|||||||
<PathIcon MaxHeight="14" MaxWidth="14" Data="{StaticResource SemiIconUser}"/>
|
<PathIcon MaxHeight="14" MaxWidth="14" Data="{StaticResource SemiIconUser}"/>
|
||||||
<Label Content="{Binding SelectedRepository.OwnerName, FallbackValue='Owner'}"/>
|
<Label Content="{Binding SelectedRepository.OwnerName, FallbackValue='Owner'}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<ScrollViewer IsVisible="{Binding SelectedRepository}">
|
<ScrollViewer IsVisible="{Binding SelectedRepository, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||||
<StackPanel Orientation="Vertical" Spacing="8">
|
<StackPanel Orientation="Vertical" Spacing="8">
|
||||||
<Label Content="{Binding SelectedRepository.Description, FallbackValue='Description as below.'}"/>
|
<Label Content="{Binding SelectedRepository.Description, FallbackValue='Description as below.'}"/>
|
||||||
<u:Divider Content="Recent Activities"/>
|
<u:Divider Content="Recent Activities"/>
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:vm="using:Flawless.Client.ViewModels"
|
||||||
|
x:DataType="vm:RepositoryViewModel"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Flawless.Client.Views.RepositoryPage.RepoCommitPageView">
|
x:Class="Flawless.Client.Views.RepositoryPage.RepoCommitPageView">
|
||||||
<Grid ColumnDefinitions="2*, *">
|
<Grid ColumnDefinitions="2*, *">
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:u="https://irihi.tech/ursa"
|
xmlns:u="https://irihi.tech/ursa"
|
||||||
|
xmlns:vm="using:Flawless.Client.ViewModels"
|
||||||
|
x:DataType="vm:RepositoryViewModel"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Flawless.Client.Views.RepositoryPage.RepoDashboardPageView">
|
x:Class="Flawless.Client.Views.RepositoryPage.RepoDashboardPageView">
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:vm="using:Flawless.Client.ViewModels"
|
||||||
|
x:DataType="vm:RepositoryViewModel"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Flawless.Client.Views.RepositoryPage.RepoFileTreePageView">
|
x:Class="Flawless.Client.Views.RepositoryPage.RepoFileTreePageView">
|
||||||
<Grid ColumnDefinitions="2*, *">
|
<Grid ColumnDefinitions="2*, *">
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:vm="using:Flawless.Client.ViewModels"
|
||||||
|
x:DataType="vm:RepositoryViewModel"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Flawless.Client.Views.RepositoryPage.RepoIssuePageView">
|
x:Class="Flawless.Client.Views.RepositoryPage.RepoIssuePageView">
|
||||||
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
|
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:vm="using:Flawless.Client.ViewModels"
|
||||||
|
x:DataType="vm:RepositoryViewModel"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Flawless.Client.Views.RepositoryPage.RepoSettingPageView">
|
x:Class="Flawless.Client.Views.RepositoryPage.RepoSettingPageView">
|
||||||
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
|
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:vm="using:Flawless.Client.ViewModels"
|
||||||
|
x:DataType="vm:RepositoryViewModel"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Flawless.Client.Views.RepositoryPage.RepoWorkspacePageView">
|
x:Class="Flawless.Client.Views.RepositoryPage.RepoWorkspacePageView">
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
|
|||||||
@ -5,8 +5,8 @@
|
|||||||
xmlns:u="https://irihi.tech/ursa"
|
xmlns:u="https://irihi.tech/ursa"
|
||||||
xmlns:semi="https://irihi.tech/semi"
|
xmlns:semi="https://irihi.tech/semi"
|
||||||
xmlns:vm="using:Flawless.Client.ViewModels"
|
xmlns:vm="using:Flawless.Client.ViewModels"
|
||||||
xmlns:page="using:Flawless.Client.Views.RepositoryPage"
|
|
||||||
x:DataType="vm:RepositoryViewModel"
|
x:DataType="vm:RepositoryViewModel"
|
||||||
|
xmlns:page="using:Flawless.Client.Views.RepositoryPage"
|
||||||
mc:Ignorable="d" d:DesignWidth="1280" d:DesignHeight="768"
|
mc:Ignorable="d" d:DesignWidth="1280" d:DesignHeight="768"
|
||||||
x:Class="Flawless.Client.Views.RepositoryView">
|
x:Class="Flawless.Client.Views.RepositoryView">
|
||||||
|
|
||||||
@ -14,7 +14,7 @@
|
|||||||
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" VerticalAlignment="Center" Spacing="20">
|
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" VerticalAlignment="Center" Spacing="20">
|
||||||
<u:IconButton Height="4" Icon="{StaticResource SemiIconArrowLeft}"
|
<u:IconButton Height="4" Icon="{StaticResource SemiIconArrowLeft}"
|
||||||
Command="{Binding GoBackCommand}" Content="All Repositories"/>
|
Command="{Binding GoBackCommand}" Content="All Repositories"/>
|
||||||
<Label FontWeight="400" FontSize="28" Content="Name of Repository"/>
|
<Label FontWeight="400" FontSize="28" Content="{Binding Repository.StandaloneName}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<TabControl TabStripPlacement="Top" Margin="0 20">
|
<TabControl TabStripPlacement="Top" Margin="0 20">
|
||||||
<TabItem>
|
<TabItem>
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
using Flawless.Client.ViewModels;
|
||||||
|
using Ursa.ReactiveUIExtension;
|
||||||
|
|
||||||
namespace Flawless.Client.Views;
|
namespace Flawless.Client.Views;
|
||||||
|
|
||||||
public partial class RepositoryView : UserControl
|
public partial class RepositoryView : ReactiveUrsaView<RepositoryViewModel>
|
||||||
{
|
{
|
||||||
public RepositoryView()
|
public RepositoryView()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -21,8 +21,7 @@ namespace Flawless.Server.Controllers;
|
|||||||
public class RepositoryInnieController(
|
public class RepositoryInnieController(
|
||||||
UserManager<AppUser> userManager,
|
UserManager<AppUser> userManager,
|
||||||
AppDbContext dbContext,
|
AppDbContext dbContext,
|
||||||
PathTransformer transformer,
|
PathTransformer transformer) : ControllerBase
|
||||||
JsonSerializerOptions serializerOpt) : ControllerBase
|
|
||||||
{
|
{
|
||||||
|
|
||||||
public class FormCommitRequest : CommitRequest
|
public class FormCommitRequest : CommitRequest
|
||||||
@ -212,8 +211,9 @@ public class RepositoryInnieController(
|
|||||||
string userName, string repositoryName, AppUser user, RepositoryRole role)
|
string userName, string repositoryName, AppUser user, RepositoryRole role)
|
||||||
{
|
{
|
||||||
var rp = await dbContext.Repositories
|
var rp = await dbContext.Repositories
|
||||||
.Include(r => r.Owner)
|
|
||||||
.Include(r => r.Members)
|
.Include(r => r.Members)
|
||||||
|
.ThenInclude(m => m.User)
|
||||||
|
.Include(r => r.Owner)
|
||||||
.FirstOrDefaultAsync(r => r.Owner.UserName == userName && r.Name == repositoryName);
|
.FirstOrDefaultAsync(r => r.Owner.UserName == userName && r.Name == repositoryName);
|
||||||
|
|
||||||
if (rp == null) return NotFound(new FailedResponse($"Could not find repository {userName}:{repositoryName}"));
|
if (rp == null) return NotFound(new FailedResponse($"Could not find repository {userName}:{repositoryName}"));
|
||||||
@ -508,7 +508,7 @@ public class RepositoryInnieController(
|
|||||||
};
|
};
|
||||||
|
|
||||||
await using (var manifestStream = System.IO.File.Create(manifestPath))
|
await using (var manifestStream = System.IO.File.Create(manifestPath))
|
||||||
await JsonSerializer.SerializeAsync(manifestStream, manifest, serializerOpt);
|
await JsonSerializer.SerializeAsync(manifestStream, manifest);
|
||||||
|
|
||||||
// Create commit info
|
// Create commit info
|
||||||
var commit = new RepositoryCommit
|
var commit = new RepositoryCommit
|
||||||
|
|||||||
@ -39,9 +39,10 @@ public class RepositoryOutieController(AppDbContext dbContext, UserManager<AppUs
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("repo_create")]
|
[HttpPost("repo_create")]
|
||||||
public async Task<ActionResult<RepositoryInfoResponse>> CreateRepositoryAsync([FromQuery] string repositoryName,[FromQuery] string description)
|
public async Task<ActionResult<RepositoryInfoResponse>> CreateRepositoryAsync([FromQuery] string repositoryName, [FromQuery] string description)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(repositoryName) || repositoryName.Length <= 3)
|
repositoryName = repositoryName.Trim().Replace(' ', '_');
|
||||||
|
if (repositoryName.Length <= 3)
|
||||||
return BadRequest(new FailedResponse("Repository name is empty or too short!"));
|
return BadRequest(new FailedResponse("Repository name is empty or too short!"));
|
||||||
|
|
||||||
var u = (await userManager.GetUserAsync(HttpContext.User))!;
|
var u = (await userManager.GetUserAsync(HttpContext.User))!;
|
||||||
@ -61,7 +62,7 @@ public class RepositoryOutieController(AppDbContext dbContext, UserManager<AppUs
|
|||||||
{
|
{
|
||||||
RepositoryName = repositoryName,
|
RepositoryName = repositoryName,
|
||||||
OwnerUsername = u.UserName!,
|
OwnerUsername = u.UserName!,
|
||||||
Description = string.Empty,
|
Description = description,
|
||||||
IsArchived = false,
|
IsArchived = false,
|
||||||
Role = RepositoryRole.Owner
|
Role = RepositoryRole.Owner
|
||||||
});
|
});
|
||||||
|
|||||||
@ -37,11 +37,7 @@ public static class Program
|
|||||||
// Api related
|
// Api related
|
||||||
builder.Services.AddSingleton<PathTransformer>();
|
builder.Services.AddSingleton<PathTransformer>();
|
||||||
builder.Services.AddOpenApi();
|
builder.Services.AddOpenApi();
|
||||||
builder.Services.AddControllers()
|
builder.Services.AddControllers();
|
||||||
.AddJsonOptions(opt =>
|
|
||||||
{
|
|
||||||
opt.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
|
|
||||||
});
|
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
builder.Services.AddSwaggerGen(opt =>
|
builder.Services.AddSwaggerGen(opt =>
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user