diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/IRepository.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/IRepository.cs index 052c23edd5..34730f3e45 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/IRepository.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/IRepository.cs @@ -8,6 +8,8 @@ namespace Umbraco.Core.Configuration.UmbracoSettings Guid Id { get; } string RepositoryUrl { get; } string WebServiceUrl { get; } - bool HasCustomWebServiceUrl { get; } + bool HasCustomWebServiceUrl { get; } + string RestApiUrl { get; } + bool HasCustomRestApiUrl { get; } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/RepositoryConfigExtensions.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/RepositoryConfigExtensions.cs new file mode 100644 index 0000000000..e2c4283dc6 --- /dev/null +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/RepositoryConfigExtensions.cs @@ -0,0 +1,19 @@ +using System; +using System.Linq; + +namespace Umbraco.Core.Configuration.UmbracoSettings +{ + public static class RepositoryConfigExtensions + { + //Our package repo + private static readonly Guid RepoGuid = new Guid("65194810-1f85-11dd-bd0b-0800200c9a66"); + + public static IRepository GetDefault(this IRepositoriesSection repos) + { + var found = repos.Repositories.FirstOrDefault(x => x.Id == RepoGuid); + if (found == null) + throw new InvalidOperationException("No default package repository found with id " + RepoGuid); + return found; + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/RepositoryElement.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/RepositoryElement.cs index cf73a8f62c..69465f62da 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/RepositoryElement.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/RepositoryElement.cs @@ -41,5 +41,21 @@ namespace Umbraco.Core.Configuration.UmbracoSettings return (string) prop.DefaultValue != (string) this[prop]; } } + + [ConfigurationProperty("restapiurl", DefaultValue = "https://our.umbraco.org/webapi/packages/v1")] + public string RestApiUrl + { + get { return (string)base["restapiurl"]; } + set { base["restapiurl"] = value; } + } + + public bool HasCustomRestApiUrl + { + get + { + var prop = Properties["restapiurl"]; + return (string)prop.DefaultValue != (string)this[prop]; + } + } } } \ No newline at end of file diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index ac530aa12b..434a45f4c9 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -292,6 +292,7 @@ + diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/ourpackagerrepository.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/ourpackagerrepository.resource.js index 37a8a9b2de..f803d7edce 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/ourpackagerrepository.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/ourpackagerrepository.resource.js @@ -5,8 +5,7 @@ **/ function ourPackageRepositoryResource($q, $http, umbDataFormatter, umbRequestHelper) { - //var baseurl = "http://localhost:24292/webapi/packages/v1"; - var baseurl = "https://our.umbraco.org/webapi/packages/v1"; + var baseurl = Umbraco.Sys.ServerVariables.umbracoUrls.packagesRestApiBaseUrl; return { diff --git a/src/Umbraco.Web/Editors/BackOfficeController.cs b/src/Umbraco.Web/Editors/BackOfficeController.cs index fdc6bd77dc..901189e28a 100644 --- a/src/Umbraco.Web/Editors/BackOfficeController.cs +++ b/src/Umbraco.Web/Editors/BackOfficeController.cs @@ -22,6 +22,7 @@ using Newtonsoft.Json.Linq; using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Manifest; @@ -224,6 +225,9 @@ namespace Umbraco.Web.Editors {"gridConfig", Url.Action("GetGridConfig", "BackOffice")}, {"serverVarsJs", Url.Action("Application", "BackOffice")}, //API URLs + { + "packagesRestApiBaseUrl", UmbracoConfig.For.UmbracoSettings().PackageRepositories.GetDefault().RestApiUrl + }, { "redirectUrlManagementApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl( controller => controller.GetEnableState())