From cc80f24b469bea004b315409f9fb3a5918ccc81a Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 23 Nov 2024 20:21:24 -0800 Subject: [PATCH] New: Ability to change root folder when editing series Closes #5544 --- .../src/Components/Form/FormInputButton.tsx | 5 +- .../src/Components/Form/FormInputGroup.tsx | 1 + frontend/src/Components/Form/PathInput.css | 4 + .../src/Components/Form/PathInput.css.d.ts | 1 + frontend/src/Components/Form/PathInput.tsx | 12 ++- .../Form/Select/RootFolderSelectInput.tsx | 9 +- frontend/src/Helpers/Props/icons.ts | 2 + .../Series/Edit/EditSeriesModalConnector.js | 40 ++++++++ .../Series/Edit/EditSeriesModalContent.tsx | 47 ++++++++++ .../Edit/RootFolder/RootFolderModal.tsx | 26 ++++++ .../RootFolder/RootFolderModalContent.tsx | 93 +++++++++++++++++++ src/NzbDrone.Core/Localization/Core/en.json | 2 + .../RootFolders/RootFolderService.cs | 4 +- .../Series/SeriesFolderController.cs | 31 +++++++ 14 files changed, 269 insertions(+), 8 deletions(-) create mode 100644 frontend/src/Series/Edit/EditSeriesModalConnector.js create mode 100644 frontend/src/Series/Edit/RootFolder/RootFolderModal.tsx create mode 100644 frontend/src/Series/Edit/RootFolder/RootFolderModalContent.tsx create mode 100644 src/Sonarr.Api.V3/Series/SeriesFolderController.cs diff --git a/frontend/src/Components/Form/FormInputButton.tsx b/frontend/src/Components/Form/FormInputButton.tsx index f61779122..e5149ab14 100644 --- a/frontend/src/Components/Form/FormInputButton.tsx +++ b/frontend/src/Components/Form/FormInputButton.tsx @@ -14,13 +14,14 @@ function FormInputButton({ className = styles.button, canSpin = false, isLastButton = true, + kind = kinds.PRIMARY, ...otherProps }: FormInputButtonProps) { if (canSpin) { return ( ); @@ -29,7 +30,7 @@ function FormInputButton({ return ( + + + + + ); +} + +export default RootFolderModalContent; diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index d70350e67..53321e959 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -2085,6 +2085,8 @@ "UpdateStartupTranslocationHealthCheckMessage": "Cannot install update because startup folder '{startupFolder}' is in an App Translocation folder.", "UpdateUiNotWritableHealthCheckMessage": "Cannot install update because UI folder '{uiFolder}' is not writable by the user '{userName}'.", "UpdaterLogFiles": "Updater Log Files", + "UpdatePath": "Update Path", + "UpdateSeriesPath": "Update Series Path", "Updates": "Updates", "UpgradeUntil": "Upgrade Until", "UpgradeUntilCustomFormatScore": "Upgrade Until Custom Format Score", diff --git a/src/NzbDrone.Core/RootFolders/RootFolderService.cs b/src/NzbDrone.Core/RootFolders/RootFolderService.cs index 09bbf7134..277290cae 100644 --- a/src/NzbDrone.Core/RootFolders/RootFolderService.cs +++ b/src/NzbDrone.Core/RootFolders/RootFolderService.cs @@ -219,10 +219,10 @@ private string GetBestRootFolderPathInternal(string path) { var osPath = new OsPath(path); - return osPath.Directory.ToString().TrimEnd(osPath.IsUnixPath ? '/' : '\\'); + return osPath.Directory.ToString().GetCleanPath(); } - return possibleRootFolder.Path; + return possibleRootFolder.Path.GetCleanPath(); } } } diff --git a/src/Sonarr.Api.V3/Series/SeriesFolderController.cs b/src/Sonarr.Api.V3/Series/SeriesFolderController.cs new file mode 100644 index 000000000..06b8b141f --- /dev/null +++ b/src/Sonarr.Api.V3/Series/SeriesFolderController.cs @@ -0,0 +1,31 @@ +using Microsoft.AspNetCore.Mvc; +using NzbDrone.Core.Organizer; +using NzbDrone.Core.Tv; +using Sonarr.Http; + +namespace Sonarr.Api.V3.Series; + +[V3ApiController("series")] +public class SeriesFolderController : Controller +{ + private readonly ISeriesService _seriesService; + private readonly IBuildFileNames _fileNameBuilder; + + public SeriesFolderController(ISeriesService seriesService, IBuildFileNames fileNameBuilder) + { + _seriesService = seriesService; + _fileNameBuilder = fileNameBuilder; + } + + [HttpGet("{id}/folder")] + public object GetFolder([FromRoute] int id) + { + var series = _seriesService.GetSeries(id); + var folder = _fileNameBuilder.GetSeriesFolder(series); + + return new + { + folder + }; + } +}