Redirect to dashboard instead of apps list on app delete (#3941)

close #3898
This commit is contained in:
Umar Bolatov
2022-07-11 23:18:08 -07:00
committed by GitHub
parent afb989d72e
commit a7b6f3fa19
3 changed files with 5 additions and 3 deletions

View File

@@ -32,6 +32,7 @@ namespace BTCPayServer.Tests
await user.GrantAccessAsync(); await user.GrantAccessAsync();
var user2 = tester.NewAccount(); var user2 = tester.NewAccount();
await user2.GrantAccessAsync(); await user2.GrantAccessAsync();
var stores = user.GetController<UIStoresController>();
var apps = user.GetController<UIAppsController>(); var apps = user.GetController<UIAppsController>();
var apps2 = user2.GetController<UIAppsController>(); var apps2 = user2.GetController<UIAppsController>();
var vm = Assert.IsType<CreateAppViewModel>(Assert.IsType<ViewResult>(apps.CreateApp(user.StoreId)).Model); var vm = Assert.IsType<CreateAppViewModel>(Assert.IsType<ViewResult>(apps.CreateApp(user.StoreId)).Model);
@@ -56,7 +57,7 @@ namespace BTCPayServer.Tests
Assert.IsType<NotFoundResult>(apps2.DeleteApp(appList.Apps[0].Id)); Assert.IsType<NotFoundResult>(apps2.DeleteApp(appList.Apps[0].Id));
Assert.IsType<ViewResult>(apps.DeleteApp(appList.Apps[0].Id)); Assert.IsType<ViewResult>(apps.DeleteApp(appList.Apps[0].Id));
redirectToAction = Assert.IsType<RedirectToActionResult>(apps.DeleteAppPost(appList.Apps[0].Id).Result); redirectToAction = Assert.IsType<RedirectToActionResult>(apps.DeleteAppPost(appList.Apps[0].Id).Result);
Assert.Equal(nameof(apps.ListApps), redirectToAction.ActionName); Assert.Equal(nameof(stores.Dashboard), redirectToAction.ActionName);
appList = await apps.ListApps(user.StoreId).AssertViewModelAsync<ListAppsViewModel>(); appList = await apps.ListApps(user.StoreId).AssertViewModelAsync<ListAppsViewModel>();
Assert.Empty(appList.Apps); Assert.Empty(appList.Apps);
} }

View File

@@ -1950,6 +1950,7 @@ namespace BTCPayServer.Tests
await user.GrantAccessAsync(); await user.GrantAccessAsync();
var user2 = tester.NewAccount(); var user2 = tester.NewAccount();
await user2.GrantAccessAsync(); await user2.GrantAccessAsync();
var stores = user.GetController<UIStoresController>();
var apps = user.GetController<UIAppsController>(); var apps = user.GetController<UIAppsController>();
var apps2 = user2.GetController<UIAppsController>(); var apps2 = user2.GetController<UIAppsController>();
var vm = Assert.IsType<CreateAppViewModel>(Assert.IsType<ViewResult>(apps.CreateApp(user.StoreId)).Model); var vm = Assert.IsType<CreateAppViewModel>(Assert.IsType<ViewResult>(apps.CreateApp(user.StoreId)).Model);
@@ -1974,7 +1975,7 @@ namespace BTCPayServer.Tests
Assert.IsType<NotFoundResult>(apps2.DeleteApp(appList.Apps[0].Id)); Assert.IsType<NotFoundResult>(apps2.DeleteApp(appList.Apps[0].Id));
Assert.IsType<ViewResult>(apps.DeleteApp(appList.Apps[0].Id)); Assert.IsType<ViewResult>(apps.DeleteApp(appList.Apps[0].Id));
redirectToAction = Assert.IsType<RedirectToActionResult>(apps.DeleteAppPost(appList.Apps[0].Id).Result); redirectToAction = Assert.IsType<RedirectToActionResult>(apps.DeleteAppPost(appList.Apps[0].Id).Result);
Assert.Equal(nameof(apps.ListApps), redirectToAction.ActionName); Assert.Equal(nameof(stores.Dashboard), redirectToAction.ActionName);
appList = Assert.IsType<ListAppsViewModel>(Assert.IsType<ViewResult>(apps.ListApps(user.StoreId).Result).Model); appList = Assert.IsType<ListAppsViewModel>(Assert.IsType<ViewResult>(apps.ListApps(user.StoreId).Result).Model);
Assert.Empty(appList.Apps); Assert.Empty(appList.Apps);
} }

View File

@@ -164,7 +164,7 @@ namespace BTCPayServer.Controllers
if (await _appService.DeleteApp(app)) if (await _appService.DeleteApp(app))
TempData[WellKnownTempData.SuccessMessage] = "App deleted successfully."; TempData[WellKnownTempData.SuccessMessage] = "App deleted successfully.";
return RedirectToAction(nameof(ListApps), new { storeId = app.StoreDataId }); return RedirectToAction(nameof(UIStoresController.Dashboard), "UIStores", new { storeId = app.StoreDataId });
} }
async Task<string> GetStoreDefaultCurrentIfEmpty(string storeId, string currency) async Task<string> GetStoreDefaultCurrentIfEmpty(string storeId, string currency)