feat: fix repository enter issue.
This commit is contained in:
parent
14a4ccd6f6
commit
11d690d22b
@ -184,8 +184,10 @@ public class RepositoryService : BaseService<RepositoryService>
|
||||
{
|
||||
var isFolderExists = Directory.Exists(PathUtility.GetWorkspacePath(repo.OwnerName, repo.Name));
|
||||
var isDbFileExists = File.Exists(PathUtility.GetWorkspaceDbPath(repo.OwnerName, repo.Name));
|
||||
|
||||
repo.IsDownloaded = isFolderExists && isDbFileExists;
|
||||
|
||||
return isFolderExists && isDbFileExists;
|
||||
return true;
|
||||
}
|
||||
|
||||
public async ValueTask<bool> UpdateMembersFromServerAsync(RepositoryModel repo)
|
||||
@ -282,10 +284,6 @@ public class RepositoryService : BaseService<RepositoryService>
|
||||
// Create basic structures.
|
||||
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;
|
||||
_openedRepos.Add(repo);
|
||||
return true;
|
||||
@ -351,7 +349,7 @@ public class RepositoryService : BaseService<RepositoryService>
|
||||
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;
|
||||
|
||||
// If they both empty
|
||||
@ -378,7 +376,7 @@ public class RepositoryService : BaseService<RepositoryService>
|
||||
return false;
|
||||
}
|
||||
|
||||
var rsp = await api.Gateway.ListCommit(repo.Name, repo.OwnerName);
|
||||
var rsp = await api.Gateway.ListCommit(repo.OwnerName, repo.Name);
|
||||
|
||||
// Update existed
|
||||
var dict = rsp.Result.ToDictionary(m => m.Id);
|
||||
|
||||
@ -30,6 +30,8 @@ public partial class HomeViewModel : ViewModelBase, IRoutableViewModel
|
||||
HostScreen = hostScreen;
|
||||
Api.C.ServerUrl.SubscribeOn(AvaloniaScheduler.Instance)
|
||||
.Subscribe(v => ServerFriendlyName = v ?? "Unknown Server");
|
||||
|
||||
RefreshRepositoriesCommand.Execute();
|
||||
}
|
||||
|
||||
[ReactiveCommand]
|
||||
@ -46,7 +48,7 @@ public partial class HomeViewModel : ViewModelBase, IRoutableViewModel
|
||||
var opt = new OverlayDialogOptions
|
||||
{
|
||||
FullScreen = false,
|
||||
Buttons = DialogButton.OK,
|
||||
Buttons = DialogButton.OKCancel,
|
||||
CanResize = false,
|
||||
CanDragMove = false,
|
||||
IsCloseButtonVisible = true,
|
||||
@ -87,9 +89,27 @@ public partial class HomeViewModel : ViewModelBase, IRoutableViewModel
|
||||
private async Task DeleteRepositoryAsync()
|
||||
{
|
||||
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}"/>
|
||||
<Label Content="{Binding SelectedRepository.OwnerName, FallbackValue='Owner'}"/>
|
||||
</StackPanel>
|
||||
<ScrollViewer IsVisible="{Binding SelectedRepository}">
|
||||
<ScrollViewer IsVisible="{Binding SelectedRepository, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||
<StackPanel Orientation="Vertical" Spacing="8">
|
||||
<Label Content="{Binding SelectedRepository.Description, FallbackValue='Description as below.'}"/>
|
||||
<u:Divider Content="Recent Activities"/>
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
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:vm="using:Flawless.Client.ViewModels"
|
||||
x:DataType="vm:RepositoryViewModel"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Flawless.Client.Views.RepositoryPage.RepoCommitPageView">
|
||||
<Grid ColumnDefinitions="2*, *">
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
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"
|
||||
x:Class="Flawless.Client.Views.RepositoryPage.RepoDashboardPageView">
|
||||
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
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:vm="using:Flawless.Client.ViewModels"
|
||||
x:DataType="vm:RepositoryViewModel"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Flawless.Client.Views.RepositoryPage.RepoFileTreePageView">
|
||||
<Grid ColumnDefinitions="2*, *">
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
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:vm="using:Flawless.Client.ViewModels"
|
||||
x:DataType="vm:RepositoryViewModel"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Flawless.Client.Views.RepositoryPage.RepoIssuePageView">
|
||||
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
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:vm="using:Flawless.Client.ViewModels"
|
||||
x:DataType="vm:RepositoryViewModel"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Flawless.Client.Views.RepositoryPage.RepoSettingPageView">
|
||||
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
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:vm="using:Flawless.Client.ViewModels"
|
||||
x:DataType="vm:RepositoryViewModel"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Flawless.Client.Views.RepositoryPage.RepoWorkspacePageView">
|
||||
<DockPanel>
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
xmlns:u="https://irihi.tech/ursa"
|
||||
xmlns:semi="https://irihi.tech/semi"
|
||||
xmlns:vm="using:Flawless.Client.ViewModels"
|
||||
xmlns:page="using:Flawless.Client.Views.RepositoryPage"
|
||||
x:DataType="vm:RepositoryViewModel"
|
||||
xmlns:page="using:Flawless.Client.Views.RepositoryPage"
|
||||
mc:Ignorable="d" d:DesignWidth="1280" d:DesignHeight="768"
|
||||
x:Class="Flawless.Client.Views.RepositoryView">
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" VerticalAlignment="Center" Spacing="20">
|
||||
<u:IconButton Height="4" Icon="{StaticResource SemiIconArrowLeft}"
|
||||
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>
|
||||
<TabControl TabStripPlacement="Top" Margin="0 20">
|
||||
<TabItem>
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Flawless.Client.ViewModels;
|
||||
using Ursa.ReactiveUIExtension;
|
||||
|
||||
namespace Flawless.Client.Views;
|
||||
|
||||
public partial class RepositoryView : UserControl
|
||||
public partial class RepositoryView : ReactiveUrsaView<RepositoryViewModel>
|
||||
{
|
||||
public RepositoryView()
|
||||
{
|
||||
|
||||
@ -21,8 +21,7 @@ namespace Flawless.Server.Controllers;
|
||||
public class RepositoryInnieController(
|
||||
UserManager<AppUser> userManager,
|
||||
AppDbContext dbContext,
|
||||
PathTransformer transformer,
|
||||
JsonSerializerOptions serializerOpt) : ControllerBase
|
||||
PathTransformer transformer) : ControllerBase
|
||||
{
|
||||
|
||||
public class FormCommitRequest : CommitRequest
|
||||
@ -212,8 +211,9 @@ public class RepositoryInnieController(
|
||||
string userName, string repositoryName, AppUser user, RepositoryRole role)
|
||||
{
|
||||
var rp = await dbContext.Repositories
|
||||
.Include(r => r.Owner)
|
||||
.Include(r => r.Members)
|
||||
.ThenInclude(m => m.User)
|
||||
.Include(r => r.Owner)
|
||||
.FirstOrDefaultAsync(r => r.Owner.UserName == userName && r.Name == 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 JsonSerializer.SerializeAsync(manifestStream, manifest, serializerOpt);
|
||||
await JsonSerializer.SerializeAsync(manifestStream, manifest);
|
||||
|
||||
// Create commit info
|
||||
var commit = new RepositoryCommit
|
||||
|
||||
@ -39,9 +39,10 @@ public class RepositoryOutieController(AppDbContext dbContext, UserManager<AppUs
|
||||
}
|
||||
|
||||
[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!"));
|
||||
|
||||
var u = (await userManager.GetUserAsync(HttpContext.User))!;
|
||||
@ -61,7 +62,7 @@ public class RepositoryOutieController(AppDbContext dbContext, UserManager<AppUs
|
||||
{
|
||||
RepositoryName = repositoryName,
|
||||
OwnerUsername = u.UserName!,
|
||||
Description = string.Empty,
|
||||
Description = description,
|
||||
IsArchived = false,
|
||||
Role = RepositoryRole.Owner
|
||||
});
|
||||
|
||||
@ -37,11 +37,7 @@ public static class Program
|
||||
// Api related
|
||||
builder.Services.AddSingleton<PathTransformer>();
|
||||
builder.Services.AddOpenApi();
|
||||
builder.Services.AddControllers()
|
||||
.AddJsonOptions(opt =>
|
||||
{
|
||||
opt.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
|
||||
});
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen(opt =>
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user