mirror of https://github.com/abpframework/abp.git
85 changed files with 465 additions and 111 deletions
@ -0,0 +1,70 @@ |
|||
using Shouldly; |
|||
using Volo.Abp.Cli.ProjectModification; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.Cli |
|||
{ |
|||
public class ProjectVersionParse_Tests |
|||
{ |
|||
[Fact] |
|||
public void Find_Abp_Version() |
|||
{ |
|||
const string csprojContent = "<Project Sdk=\"Microsoft.NET.Sdk\">" + |
|||
"<Import Project=\"..\\..\\common.props\" />" + |
|||
"<PropertyGroup>" + |
|||
"<TargetFramework>net5.0</TargetFramework>" + |
|||
"<RootNamespace>Blazoor.EfCore07062034</RootNamespace>" + |
|||
"</PropertyGroup>" + |
|||
"<ItemGroup>" + |
|||
"<ProjectReference Include=\"..\\Blazoor.EfCore07062034.Domain.Shared\\Blazoor.EfCore07062034.Domain.Shared.csproj\" />" + |
|||
"</ItemGroup>" + |
|||
"<ItemGroup>" + |
|||
"< PackageReference Include = \"Volo.Abp.Emailing\" Version = \"4.4.0-rc.1\" />" + |
|||
"<PackageReference Include= \"Volo.Abp.PermissionManagement.Domain.Identity\" Version= \"4.4.0-rc.1\" />" + |
|||
"<PackageReference Include=\"Volo.Abp.IdentityServer.Domain\" Version=\"4.4.0-rc.1\" />" + |
|||
"<PackageReference Include=\"Volo.Abp.PermissionManagement.Domain.IdentityServer\" Version=\"4.4.0-rc.1\" />" + |
|||
"<PackageReference Include=\"Volo.Abp.BackgroundJobs.Domain\" Version=\"4.4.0-rc.1\" />" + |
|||
"<PackageReference Include=\"Volo.Abp.AuditLogging.Domain\" Version=\"4.4.0-rc.1\" />" + |
|||
"<PackageReference Include=\"Volo.Abp.FeatureManagement.Domain\" Version=\"4.4.0-rc.1\" />" + |
|||
"<PackageReference Include=\"Volo.Abp.SettingManagement.Domain\" Version=\"4.4.0-rc.1\" />" + |
|||
"<PackageReference Include=\"Volo.Abp.BlobStoring.Database.Domain\" Version=\"4.4.0-rc.1\" />" + |
|||
"<PackageReference Include=\"Volo.Abp.Identity.Pro.Domain\" Version=\"4.4.0-rc.1\" />" + |
|||
"<PackageReference Include=\"Volo.Abp.LanguageManagement.Domain\" Version=\"4.4.0-rc.1\" />" + |
|||
"<PackageReference Include=\"Volo.Abp.LeptonTheme.Management.Domain\" Version=\"4.4.0-rc.1\" />" + |
|||
"<PackageReference Include=\"Volo.Saas.Domain\" Version=\"4.4.0-rc.1\" />" + |
|||
"<PackageReference Include=\"Volo.Abp.TextTemplateManagement.Domain\" Version=\"4.4.0-rc.1\" />" + |
|||
"</ItemGroup>" + |
|||
"</Project>"; |
|||
|
|||
var success = SolutionAbpVersionFinder.TryParseVersionFromCsprojFile(csprojContent, out var version); |
|||
success.ShouldBe(true); |
|||
version.ShouldBe("4.4.0-rc.1"); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Find_Abp_Semantic_Version() |
|||
{ |
|||
const string csprojContent = "<Project Sdk=\"Microsoft.NET.Sdk\">" + |
|||
"<Import Project=\"..\\..\\common.props\" />" + |
|||
"<PropertyGroup>" + |
|||
"<TargetFramework>net5.0</TargetFramework>" + |
|||
"<RootNamespace>Blazoor.EfCore07062034</RootNamespace>" + |
|||
"</PropertyGroup>" + |
|||
"<ItemGroup>" + |
|||
"<ProjectReference Include=\"..\\Blazoor.EfCore07062034.Domain.Shared\\Blazoor.EfCore07062034.Domain.Shared.csproj\" />" + |
|||
"</ItemGroup>" + |
|||
"<ItemGroup>" + |
|||
"< PackageReference Include = \"Volo.Abp.Emailing\" Version= \"12.8.3-beta.1\" />" + |
|||
"</ItemGroup>" + |
|||
"</Project>"; |
|||
|
|||
var success = SolutionAbpVersionFinder.TryParseSemanticVersionFromCsprojFile(csprojContent, out var version); |
|||
success.ShouldBe(true); |
|||
version.Major.ShouldBe(12); |
|||
version.Minor.ShouldBe(8); |
|||
version.Patch.ShouldBe(3); |
|||
version.Release.ShouldBe("beta.1"); |
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
import { ConfigStateService, featuresFactory, noop } from '@abp/ng.core'; |
|||
import { APP_INITIALIZER, inject, InjectionToken } from '@angular/core'; |
|||
import { Observable } from 'rxjs'; |
|||
import { map } from 'rxjs/operators'; |
|||
|
|||
export const SETTING_MANAGEMENT_FEATURES = new InjectionToken<Observable<{ enable: boolean }>>( |
|||
'SETTING_MANAGEMENT_FEATURES', |
|||
{ |
|||
providedIn: 'root', |
|||
factory: () => { |
|||
const configState = inject(ConfigStateService); |
|||
const featureKey = 'SettingManagement.Enable'; |
|||
const mapFn = features => ({ |
|||
enable: features[featureKey].toLowerCase() !== 'false', |
|||
}); |
|||
return featuresFactory(configState, [featureKey], mapFn); |
|||
}, |
|||
}, |
|||
); |
|||
|
|||
export const SETTING_MANAGEMENT_ROUTE_VISIBILITY = new InjectionToken<Observable<boolean>>( |
|||
'SETTING_MANAGEMENT_ROUTE_VISIBILITY', |
|||
{ |
|||
providedIn: 'root', |
|||
factory: () => { |
|||
const stream = inject(SETTING_MANAGEMENT_FEATURES); |
|||
return stream.pipe(map(features => features.enable)); |
|||
}, |
|||
}, |
|||
); |
|||
|
|||
export const SETTING_MANAGEMENT_FEATURES_PROVIDERS = [ |
|||
{ |
|||
provide: APP_INITIALIZER, |
|||
useFactory: noop, |
|||
deps: [SETTING_MANAGEMENT_ROUTE_VISIBILITY], |
|||
multi: true, |
|||
}, |
|||
]; |
|||
@ -1,2 +1,3 @@ |
|||
export * from './route.provider'; |
|||
export * from './setting-tab.provider'; |
|||
export * from './visible.provider'; |
|||
|
|||
@ -0,0 +1,30 @@ |
|||
import { APP_INITIALIZER, Injector } from '@angular/core'; |
|||
import { combineLatest } from 'rxjs'; |
|||
import { RoutesService } from '@abp/ng.core'; |
|||
import { SETTING_MANAGEMENT_HAS_SETTING } from './route.provider'; |
|||
import { SETTING_MANAGEMENT_ROUTE_VISIBILITY } from './features.token'; |
|||
import { eSettingManagementRouteNames } from '../enums'; |
|||
|
|||
export const SETTING_MANAGEMENT_VISIBLE_PROVIDERS = [ |
|||
{ |
|||
provide: APP_INITIALIZER, |
|||
useFactory: setSettingManagementVisibility, |
|||
deps: [Injector], |
|||
multi: true, |
|||
}, |
|||
]; |
|||
|
|||
export function setSettingManagementVisibility(injector: Injector) { |
|||
return () => { |
|||
const settingManagementHasSetting$ = injector.get(SETTING_MANAGEMENT_HAS_SETTING); |
|||
const isSettingManagementFeatureEnable$ = injector.get(SETTING_MANAGEMENT_ROUTE_VISIBILITY); |
|||
const routes = injector.get(RoutesService); |
|||
combineLatest([settingManagementHasSetting$, isSettingManagementFeatureEnable$]).subscribe( |
|||
([settingManagementHasSetting, isSettingManagementFeatureEnable]) => { |
|||
routes.patch(eSettingManagementRouteNames.Settings, { |
|||
invisible: !(settingManagementHasSetting && isSettingManagementFeatureEnable), |
|||
}); |
|||
}, |
|||
); |
|||
}; |
|||
} |
|||
Loading…
Reference in new issue