Skip to content

Commit f33cfa4

Browse files
committed
Hide export profiles where the provider is decorated with hidden attribute
1 parent 1015556 commit f33cfa4

1 file changed

Lines changed: 42 additions & 7 deletions

File tree

src/Presentation/SmartStore.Web/Administration/Controllers/ExportController.cs

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -488,13 +488,17 @@ public ActionResult List()
488488

489489
foreach (var profile in profiles)
490490
{
491-
var profileModel = new ExportProfileModel();
491+
var provider = providers.FirstOrDefault(x => x.Metadata.SystemName == profile.ProviderSystemName);
492+
if (provider != null)
493+
{
494+
var profileModel = new ExportProfileModel();
492495

493-
PrepareProfileModel(profileModel, profile, providers.FirstOrDefault(x => x.Metadata.SystemName == profile.ProviderSystemName), false);
496+
PrepareProfileModel(profileModel, profile, provider, false);
494497

495-
profileModel.TaskModel = profile.ScheduleTask.ToScheduleTaskModel(_services.Localization, _dateTimeHelper, Url);
498+
profileModel.TaskModel = profile.ScheduleTask.ToScheduleTaskModel(_services.Localization, _dateTimeHelper, Url);
496499

497-
model.Add(profileModel);
500+
model.Add(profileModel);
501+
}
498502
}
499503

500504
return View(model);
@@ -613,6 +617,8 @@ public ActionResult Edit(int id)
613617
return RedirectToAction("List");
614618

615619
var provider = _exportService.LoadProvider(profile.ProviderSystemName);
620+
if (provider.Metadata.IsHidden)
621+
return RedirectToAction("List");
616622

617623
var model = new ExportProfileModel();
618624

@@ -634,6 +640,8 @@ public ActionResult Edit(ExportProfileModel model, bool continueEditing)
634640
return RedirectToAction("List");
635641

636642
var provider = _exportService.LoadProvider(profile.ProviderSystemName);
643+
if (provider.Metadata.IsHidden)
644+
return RedirectToAction("List");
637645

638646
if (!ModelState.IsValid)
639647
{
@@ -754,6 +762,10 @@ public ActionResult DeleteConfirmed(int id)
754762
if (profile == null)
755763
return RedirectToAction("List");
756764

765+
var provider = _exportService.LoadProvider(profile.ProviderSystemName);
766+
if (provider.Metadata.IsHidden)
767+
return RedirectToAction("List");
768+
757769
try
758770
{
759771
_exportService.DeleteExportProfile(profile);
@@ -779,15 +791,17 @@ public ActionResult Preview(int id)
779791
if (profile == null)
780792
return RedirectToAction("List");
781793

794+
var provider = _exportService.LoadProvider(profile.ProviderSystemName);
795+
if (provider.Metadata.IsHidden)
796+
return RedirectToAction("List");
797+
782798
if (!profile.Enabled)
783799
{
784800
NotifyInfo(T("Admin.DataExchange.Export.EnableProfileForPreview"));
785801

786802
return RedirectToAction("Edit", new { id = profile.Id });
787803
}
788804

789-
var provider = _exportService.LoadProvider(profile.ProviderSystemName);
790-
791805
var request = new DataExportRequest(profile, provider);
792806
var totalRecords = _dataExporter.GetDataCount(request);
793807

@@ -814,7 +828,8 @@ public ActionResult PreviewList(GridCommand command, int id, int totalRecords)
814828

815829
if (_services.Permissions.Authorize(StandardPermissionProvider.ManageExports) &&
816830
(profile = _exportService.GetExportProfileById(id)) != null &&
817-
(provider = _exportService.LoadProvider(profile.ProviderSystemName)) != null)
831+
(provider = _exportService.LoadProvider(profile.ProviderSystemName)) != null &&
832+
!provider.Metadata.IsHidden)
818833
{
819834
var productModel = new List<ExportPreviewProductModel>();
820835
var orderModel = new List<ExportPreviewOrderModel>();
@@ -981,6 +996,10 @@ public ActionResult Execute(int id, string selectedIds)
981996
if (profile == null)
982997
return RedirectToAction("List");
983998

999+
var provider = _exportService.LoadProvider(profile.ProviderSystemName);
1000+
if (provider.Metadata.IsHidden)
1001+
return RedirectToAction("List");
1002+
9841003
var taskParams = new Dictionary<string, string>();
9851004
taskParams.Add("CurrentCustomerId", _services.WorkContext.CurrentCustomer.Id.ToString());
9861005

@@ -1090,6 +1109,8 @@ public ActionResult CreateDeployment(int id)
10901109
return RedirectToAction("List");
10911110

10921111
var provider = _exportService.LoadProvider(profile.ProviderSystemName);
1112+
if (provider.Metadata.IsHidden)
1113+
return RedirectToAction("List");
10931114

10941115
//var fileSystemName = ExportDeploymentType.FileSystem.GetLocalizedEnum(_services.Localization, _services.WorkContext);
10951116

@@ -1115,6 +1136,10 @@ public ActionResult CreateDeployment(ExportDeploymentModel model, bool continueE
11151136
if (profile == null)
11161137
return RedirectToAction("List");
11171138

1139+
var provider = _exportService.LoadProvider(profile.ProviderSystemName);
1140+
if (provider.Metadata.IsHidden)
1141+
return RedirectToAction("List");
1142+
11181143
if (ModelState.IsValid)
11191144
{
11201145
var deployment = new ExportDeployment();
@@ -1141,6 +1166,8 @@ public ActionResult EditDeployment(int id)
11411166
return RedirectToAction("List");
11421167

11431168
var provider = _exportService.LoadProvider(deployment.Profile.ProviderSystemName);
1169+
if (provider.Metadata.IsHidden)
1170+
return RedirectToAction("List");
11441171

11451172
var model = PrepareDeploymentModel(deployment, provider, true);
11461173

@@ -1158,6 +1185,10 @@ public ActionResult EditDeployment(ExportDeploymentModel model, bool continueEdi
11581185
if (deployment == null)
11591186
return RedirectToAction("List");
11601187

1188+
var provider = _exportService.LoadProvider(deployment.Profile.ProviderSystemName);
1189+
if (provider.Metadata.IsHidden)
1190+
return RedirectToAction("List");
1191+
11611192
if (ModelState.IsValid)
11621193
{
11631194
ModelToEntity(model, deployment);
@@ -1183,6 +1214,10 @@ public ActionResult DeleteDeployment(int id)
11831214
if (deployment == null)
11841215
return RedirectToAction("List");
11851216

1217+
var provider = _exportService.LoadProvider(deployment.Profile.ProviderSystemName);
1218+
if (provider.Metadata.IsHidden)
1219+
return RedirectToAction("List");
1220+
11861221
int profileId = deployment.ProfileId;
11871222

11881223
_exportService.DeleteExportDeployment(deployment);

0 commit comments

Comments
 (0)