diff --git a/starsky/starsky.feature.desktop/Interfaces/IOpenEditorDesktopService.cs b/starsky/starsky.feature.desktop/Interfaces/IOpenEditorDesktopService.cs
index 94590660be..d0a85763e5 100644
--- a/starsky/starsky.feature.desktop/Interfaces/IOpenEditorDesktopService.cs
+++ b/starsky/starsky.feature.desktop/Interfaces/IOpenEditorDesktopService.cs
@@ -4,6 +4,18 @@ namespace starsky.feature.desktop.Interfaces;
public interface IOpenEditorDesktopService
{
+ ///
+ /// Is supported and enabled in the feature toggle
+ ///
+ /// Should you use it?
+ bool IsEnabled();
+
+ ///
+ /// Open a file in the default editor or specific editor which is set in the app settings
+ ///
+ /// dot comma split list with subPaths
+ /// should pick raw/jpeg file even its not specified
+ /// files done and list of results
Task<(bool?, string, List)> OpenAsync(string f,
bool collections);
}
diff --git a/starsky/starsky.feature.desktop/Service/OpenEditorDesktopService.cs b/starsky/starsky.feature.desktop/Service/OpenEditorDesktopService.cs
index 9579cd2b1a..7846050eb6 100644
--- a/starsky/starsky.feature.desktop/Service/OpenEditorDesktopService.cs
+++ b/starsky/starsky.feature.desktop/Service/OpenEditorDesktopService.cs
@@ -27,6 +27,12 @@ public OpenEditorDesktopService(AppSettings appSettings,
_openEditorPreflight = openEditorPreflight;
}
+ public bool IsEnabled()
+ {
+ return _appSettings.UseLocalDesktop == true &&
+ _openApplicationNativeService.DetectToUseOpenApplication();
+ }
+
public async Task<(bool?, string, List)> OpenAsync(string f,
bool collections)
{
diff --git a/starsky/starsky.feature.trash/Interfaces/IMoveToTrashService.cs b/starsky/starsky.feature.trash/Interfaces/IMoveToTrashService.cs
index 469dcaf294..d4b04a32b0 100644
--- a/starsky/starsky.feature.trash/Interfaces/IMoveToTrashService.cs
+++ b/starsky/starsky.feature.trash/Interfaces/IMoveToTrashService.cs
@@ -14,13 +14,6 @@ public interface IMoveToTrashService
Task> MoveToTrashAsync(List inputFilePaths,
bool collections);
- ///
- /// Is it supported to use the system trash
- /// But it does NOT check if the feature toggle is enabled
- ///
- /// true if supported
- bool DetectToUseSystemTrash();
-
///
/// Is supported and enabled in the feature toggle
///
diff --git a/starsky/starsky.feature.trash/Services/MoveToTrashService.cs b/starsky/starsky.feature.trash/Services/MoveToTrashService.cs
index 1f09bfc099..025ce4c603 100644
--- a/starsky/starsky.feature.trash/Services/MoveToTrashService.cs
+++ b/starsky/starsky.feature.trash/Services/MoveToTrashService.cs
@@ -10,6 +10,7 @@
using starsky.foundation.worker.Interfaces;
[assembly: InternalsVisibleTo("starskytest")]
+
namespace starsky.feature.trash.Services;
[Service(typeof(IMoveToTrashService), InjectionLifetime = InjectionLifetime.Scoped)]
@@ -46,17 +47,7 @@ ITrashConnectionService connectionService
public bool IsEnabled()
{
return _appSettings.UseSystemTrash == true &&
- _systemTrashService.DetectToUseSystemTrash();
- }
-
- ///
- /// Is it supported to use the system trash
- /// But it does NOT check if the feature toggle is enabled
- ///
- /// true if supported
- public bool DetectToUseSystemTrash()
- {
- return _systemTrashService.DetectToUseSystemTrash();
+ _systemTrashService.DetectToUseSystemTrash();
}
///
@@ -74,11 +65,13 @@ public async Task> MoveToTrashAsync(
await _metaPreflight.PreflightAsync(inputModel, inputFilePaths,
false, collections, 0);
- (fileIndexResultsList, changedFileIndexItemName) = await AppendChildItemsToTrashList(fileIndexResultsList, changedFileIndexItemName);
+ ( fileIndexResultsList, changedFileIndexItemName ) =
+ await AppendChildItemsToTrashList(fileIndexResultsList, changedFileIndexItemName);
var moveToTrashList =
fileIndexResultsList.Where(p =>
- p.Status is FileIndexItem.ExifStatus.Ok or FileIndexItem.ExifStatus.Deleted).ToList();
+ p.Status is FileIndexItem.ExifStatus.Ok or FileIndexItem.ExifStatus.Deleted)
+ .ToList();
var isSystemTrashEnabled = IsEnabled();
@@ -92,9 +85,8 @@ await _queue.QueueBackgroundWorkItemAsync(async _ =>
return;
}
- await MetaTrashInQueue(changedFileIndexItemName!,
+ await MetaTrashInQueue(changedFileIndexItemName,
fileIndexResultsList, inputModel, collections);
-
}, "trash");
return TrashConnectionService.StatusUpdate(moveToTrashList, isSystemTrashEnabled);
@@ -112,8 +104,9 @@ await _metaUpdateService.UpdateAsync(changedFileIndexItemName,
///
///
///
- internal async Task<(List, Dictionary>?)> AppendChildItemsToTrashList(List moveToTrash,
- Dictionary> changedFileIndexItemName)
+ internal async Task<(List, Dictionary>)>
+ AppendChildItemsToTrashList(List moveToTrash,
+ Dictionary> changedFileIndexItemName)
{
var parentSubPaths = moveToTrash
.Where(p => !string.IsNullOrEmpty(p.FilePath) && p.IsDirectory == true)
@@ -122,7 +115,7 @@ await _metaUpdateService.UpdateAsync(changedFileIndexItemName,
if ( parentSubPaths.Count == 0 )
{
- return (moveToTrash, changedFileIndexItemName);
+ return ( moveToTrash, changedFileIndexItemName );
}
var childItems = ( await _query.GetAllObjectsAsync(parentSubPaths) )
@@ -139,7 +132,7 @@ await _metaUpdateService.UpdateAsync(changedFileIndexItemName,
changedFileIndexItemName.TryAdd(childItem.FilePath!, new List { "tags" });
}
- return (moveToTrash, changedFileIndexItemName);
+ return ( moveToTrash, changedFileIndexItemName );
}
private async Task SystemTrashInQueue(List moveToTrash)
diff --git a/starsky/starsky.project.web/ViewModels/EnvFeaturesViewModel.cs b/starsky/starsky.project.web/ViewModels/EnvFeaturesViewModel.cs
index 60a8942cf1..34f731c7fd 100644
--- a/starsky/starsky.project.web/ViewModels/EnvFeaturesViewModel.cs
+++ b/starsky/starsky.project.web/ViewModels/EnvFeaturesViewModel.cs
@@ -11,4 +11,9 @@ public class EnvFeaturesViewModel
/// Enable or disable some features on the frontend
///
public bool UseLocalDesktop { get; set; }
+
+ ///
+ /// Is supported and enabled in the feature toggle
+ ///
+ public bool OpenEditorEnabled { get; set; }
}
diff --git a/starsky/starsky/Controllers/AppSettingsFeaturesController.cs b/starsky/starsky/Controllers/AppSettingsFeaturesController.cs
index 1ca956296d..a41dcee8c6 100644
--- a/starsky/starsky/Controllers/AppSettingsFeaturesController.cs
+++ b/starsky/starsky/Controllers/AppSettingsFeaturesController.cs
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
+using starsky.feature.desktop.Interfaces;
using starsky.feature.trash.Interfaces;
using starsky.foundation.platform.Models;
using starsky.project.web.ViewModels;
@@ -10,11 +11,14 @@ public class AppSettingsFeaturesController : Controller
{
private readonly IMoveToTrashService _moveToTrashService;
private readonly AppSettings _appSettings;
+ private readonly IOpenEditorDesktopService _openEditorDesktopService;
public AppSettingsFeaturesController(IMoveToTrashService moveToTrashService,
+ IOpenEditorDesktopService openEditorDesktopService,
AppSettings appSettings)
{
_moveToTrashService = moveToTrashService;
+ _openEditorDesktopService = openEditorDesktopService;
_appSettings = appSettings;
}
@@ -38,6 +42,7 @@ public IActionResult FeaturesView()
{
SystemTrashEnabled = _moveToTrashService.IsEnabled(),
UseLocalDesktop = _appSettings.UseLocalDesktop == true,
+ OpenEditorEnabled = _openEditorDesktopService.IsEnabled()
};
return Json(shortAppSettings);
diff --git a/starsky/starsky/Controllers/TrashController.cs b/starsky/starsky/Controllers/TrashController.cs
index 555674fc3d..d4d7bc2bbc 100644
--- a/starsky/starsky/Controllers/TrashController.cs
+++ b/starsky/starsky/Controllers/TrashController.cs
@@ -20,21 +20,7 @@ public TrashController(IMoveToTrashService moveToTrashService)
}
///
- /// Is the system trash supported
- ///
- /// bool with json (IActionResult Result)
- /// the item including the updated content
- /// User unauthorized
- [ProducesResponseType(typeof(bool), 200)]
- [HttpGet("/api/trash/detect-to-use-system-trash")]
- [Produces("application/json")]
- public IActionResult DetectToUseSystemTrash()
- {
- return Json(_moveToTrashService.DetectToUseSystemTrash());
- }
-
- ///
- /// (beta) Move a file to the trash
+ /// Move a file to the trash
///
/// subPath filepath to file, split by dot comma (;)
/// stack collections
@@ -56,7 +42,8 @@ public async Task TrashMoveAsync(string f, bool collections = fal
return BadRequest("No input files");
}
- var fileIndexResultsList = await _moveToTrashService.MoveToTrashAsync(inputFilePaths.ToList(), collections);
+ var fileIndexResultsList =
+ await _moveToTrashService.MoveToTrashAsync(inputFilePaths.ToList(), collections);
return Json(fileIndexResultsList);
}
diff --git a/starsky/starsky/clientapp/src/shared/url-query.ts b/starsky/starsky/clientapp/src/shared/url-query.ts
index d227f7dfbc..d6a84d0e2a 100644
--- a/starsky/starsky/clientapp/src/shared/url-query.ts
+++ b/starsky/starsky/clientapp/src/shared/url-query.ts
@@ -325,7 +325,7 @@ export class UrlQuery {
};
public UrlApiFeaturesAppSettings = (): string => {
- return this.prefix + "/api/env/features";
+ return this.prefix + "/api/env/features?v=0.6.0-beta.2";
};
/**
diff --git a/starsky/starskytest/Controllers/AppSettingsFeaturesControllerTest.cs b/starsky/starskytest/Controllers/AppSettingsFeaturesControllerTest.cs
index e305c2a9e3..1bdaf0c382 100644
--- a/starsky/starskytest/Controllers/AppSettingsFeaturesControllerTest.cs
+++ b/starsky/starskytest/Controllers/AppSettingsFeaturesControllerTest.cs
@@ -18,7 +18,7 @@ public void FeaturesViewTest()
// Arrange
var fakeIMoveToTrashService = new FakeIMoveToTrashService(new List());
var appSettingsFeaturesController = new AppSettingsFeaturesController(
- fakeIMoveToTrashService, new AppSettings());
+ fakeIMoveToTrashService, new FakeIOpenEditorDesktopService(), new AppSettings());
// Act
var result = appSettingsFeaturesController.FeaturesView() as JsonResult;
@@ -35,7 +35,8 @@ public void FeaturesViewTest_Disabled()
// Arrange
var fakeIMoveToTrashService = new FakeIMoveToTrashService(new List(), false);
var appSettingsFeaturesController = new AppSettingsFeaturesController(
- fakeIMoveToTrashService, new AppSettings { UseLocalDesktop = false });
+ fakeIMoveToTrashService, new FakeIOpenEditorDesktopService(),
+ new AppSettings { UseLocalDesktop = false });
// Act
var result = appSettingsFeaturesController.FeaturesView() as JsonResult;
@@ -53,7 +54,8 @@ public void FeaturesViewTest_Enabled()
// Arrange
var fakeIMoveToTrashService = new FakeIMoveToTrashService(new List());
var appSettingsFeaturesController = new AppSettingsFeaturesController(
- fakeIMoveToTrashService, new AppSettings { UseLocalDesktop = true });
+ fakeIMoveToTrashService, new FakeIOpenEditorDesktopService(),
+ new AppSettings { UseLocalDesktop = true });
// Act
var result = appSettingsFeaturesController.FeaturesView() as JsonResult;
diff --git a/starsky/starskytest/Controllers/TrashControllerTest.cs b/starsky/starskytest/Controllers/TrashControllerTest.cs
index f19ea3f9cf..b0f18a4790 100644
--- a/starsky/starskytest/Controllers/TrashControllerTest.cs
+++ b/starsky/starskytest/Controllers/TrashControllerTest.cs
@@ -17,9 +17,9 @@ public async Task TrashControllerTest_BadInput()
var controller = new TrashController(
new FakeIMoveToTrashService(new List()));
var result = await controller.TrashMoveAsync(null!, true) as BadRequestObjectResult;
- Assert.AreEqual(400,result?.StatusCode);
+ Assert.AreEqual(400, result?.StatusCode);
}
-
+
[TestMethod]
public async Task TrashControllerTest_NotFound()
{
@@ -27,35 +27,21 @@ public async Task TrashControllerTest_NotFound()
new FakeIMoveToTrashService(new List()));
var result = await controller.TrashMoveAsync("/test.jpg", true) as JsonResult;
var resultValue = result?.Value as List;
-
+
Assert.AreEqual(1, resultValue?.Count);
}
-
+
[TestMethod]
public async Task TrashControllerTest_Ok()
{
var controller = new TrashController(
- new FakeIMoveToTrashService(new List{new FileIndexItem("/test.jpg")
+ new FakeIMoveToTrashService(new List
{
- Status = FileIndexItem.ExifStatus.Ok
- }}));
+ new FileIndexItem("/test.jpg") { Status = FileIndexItem.ExifStatus.Ok }
+ }));
var result = await controller.TrashMoveAsync("/test.jpg", true) as JsonResult;
var resultValue = result?.Value as List;
-
+
Assert.AreEqual(1, resultValue?.Count);
}
-
- [TestMethod]
- public void DetectToUseSystemTrash_Ok()
- {
- var controller = new TrashController(
- new FakeIMoveToTrashService(new List()));
-
- var result = controller.DetectToUseSystemTrash() as JsonResult;
-
- var tryParseResult = bool.TryParse(result?.Value?.ToString(), out var resultValue);
-
- Assert.AreEqual(true, tryParseResult);
- Assert.AreEqual(true, resultValue);
- }
}
diff --git a/starsky/starskytest/FakeMocks/FakeIOpenEditorDesktopService.cs b/starsky/starskytest/FakeMocks/FakeIOpenEditorDesktopService.cs
new file mode 100644
index 0000000000..850dd7e153
--- /dev/null
+++ b/starsky/starskytest/FakeMocks/FakeIOpenEditorDesktopService.cs
@@ -0,0 +1,43 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using starsky.feature.desktop.Interfaces;
+using starsky.feature.desktop.Models;
+using starsky.foundation.database.Models;
+using starsky.foundation.platform.Helpers;
+
+namespace starskytest.FakeMocks;
+
+public class FakeIOpenEditorDesktopService : IOpenEditorDesktopService
+{
+ private readonly bool _isEnabled;
+
+ public FakeIOpenEditorDesktopService(bool isEnabled = true)
+ {
+ _isEnabled = isEnabled;
+ }
+
+ public bool IsEnabled()
+ {
+ return _isEnabled;
+ }
+
+ public async Task<(bool?, string, List)> OpenAsync(string f,
+ bool collections)
+ {
+ await Task.Yield();
+
+ var list = new List
+ {
+ new PathImageFormatExistsAppPathModel
+ {
+ AppPath = "test",
+ Status = FileIndexItem.ExifStatus.Ok,
+ ImageFormat = ExtensionRolesHelper.ImageFormat.jpg,
+ SubPath = "/test.jpg",
+ FullFilePath = "/test.jpg"
+ }
+ };
+
+ return ( _isEnabled, "Opened", list );
+ }
+}
diff --git a/starsky/starskytest/starsky.feature.desktop/Service/OpenEditorDesktopServiceTest.cs b/starsky/starskytest/starsky.feature.desktop/Service/OpenEditorDesktopServiceTest.cs
index 1c44104412..f9ce24cb34 100644
--- a/starsky/starskytest/starsky.feature.desktop/Service/OpenEditorDesktopServiceTest.cs
+++ b/starsky/starskytest/starsky.feature.desktop/Service/OpenEditorDesktopServiceTest.cs
@@ -16,8 +16,8 @@ public class OpenEditorDesktopServiceTest
[TestMethod]
public async Task OpenAsync_stringInput_HappyFlow()
{
- var fakeService =
- new FakeIOpenApplicationNativeService(new List { "/test.jpg" }, "test");
+ var fakeService = new FakeIOpenApplicationNativeService(
+ new List { "/test.jpg" }, "test");
var appSettings = new AppSettings
{
@@ -153,15 +153,14 @@ public async Task OpenAsync_ListInput_UseLocalDesktop_Null()
[TestMethod]
public async Task OpenAsync_ListInput_UnSupportedPlatform()
{
- var fakeService =
- new FakeIOpenApplicationNativeService(new List(), string.Empty, false);
+ var fakeService = new FakeIOpenApplicationNativeService(new List(),
+ string.Empty, false);
var appSettings = new AppSettings { UseLocalDesktop = true };
var preflight = new FakeIOpenEditorPreflight(new List());
- var service =
- new OpenEditorDesktopService(appSettings, fakeService, preflight);
+ var service = new OpenEditorDesktopService(appSettings, fakeService, preflight);
var (success, status, list) =
( await service.OpenAsync(new List { "/test.jpg" }, true) );
diff --git a/starsky/starskytest/starsky.feature.trash/Services/MoveToTrashServiceTest.cs b/starsky/starskytest/starsky.feature.trash/Services/MoveToTrashServiceTest.cs
index 19c7fac3bd..b0373989e7 100644
--- a/starsky/starskytest/starsky.feature.trash/Services/MoveToTrashServiceTest.cs
+++ b/starsky/starskytest/starsky.feature.trash/Services/MoveToTrashServiceTest.cs
@@ -313,20 +313,6 @@ public async Task InMetaTrash_WithDbContext_Directory()
Assert.AreEqual(TrashKeyword.TrashKeywordString, result[1].Tags);
}
- [TestMethod]
- public void DetectToUseSystemTrash_False()
- {
- var trashService = new FakeITrashService() { IsSupported = false };
- var moveToTrashService = new MoveToTrashService(new AppSettings(), new FakeIQuery(),
- new FakeMetaPreflight(), new FakeIUpdateBackgroundTaskQueue(),
- trashService, new FakeIMetaUpdateService(),
- new FakeITrashConnectionService());
-
- var result = moveToTrashService.DetectToUseSystemTrash();
-
- Assert.AreEqual(false, result);
- }
-
[TestMethod]
public async Task AppendChildItemsToTrashList_NoAny()
{