Introduce feature management blazor modal

Closes: #5383
pull/5399/head
Ahmet Çotur 5 years ago
parent 6151e282eb
commit b0a1a0d9c9

@ -35,6 +35,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.FeatureManagement.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.FeatureManagement.Application.Tests", "test\Volo.Abp.FeatureManagement.Application.Tests\Volo.Abp.FeatureManagement.Application.Tests.csproj", "{13A9EAD6-F3A4-4357-BA4A-A7E8FEB4A264}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.FeatureManagement.Blazor", "src\Volo.Abp.FeatureManagement.Blazor\Volo.Abp.FeatureManagement.Blazor.csproj", "{0F34FFD5-E98F-4F77-AE0B-A790BD5810D5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -97,6 +99,10 @@ Global
{13A9EAD6-F3A4-4357-BA4A-A7E8FEB4A264}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13A9EAD6-F3A4-4357-BA4A-A7E8FEB4A264}.Release|Any CPU.ActiveCfg = Release|Any CPU
{13A9EAD6-F3A4-4357-BA4A-A7E8FEB4A264}.Release|Any CPU.Build.0 = Release|Any CPU
{0F34FFD5-E98F-4F77-AE0B-A790BD5810D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0F34FFD5-E98F-4F77-AE0B-A790BD5810D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F34FFD5-E98F-4F77-AE0B-A790BD5810D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F34FFD5-E98F-4F77-AE0B-A790BD5810D5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -116,6 +122,7 @@ Global
{E5906DE1-B2F5-472E-BE1B-1D96A68B834D} = {CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D}
{AA783A34-86E4-41A5-AE21-5D9FBD98D858} = {CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D}
{13A9EAD6-F3A4-4357-BA4A-A7E8FEB4A264} = {CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D}
{0F34FFD5-E98F-4F77-AE0B-A790BD5810D5} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4324B3B4-B60B-4E3C-91D8-59576B4E26DD}

@ -0,0 +1,16 @@
using Volo.Abp.AspNetCore.Components.WebAssembly.Theming;
using Volo.Abp.AutoMapper;
using Volo.Abp.Modularity;
namespace Volo.Abp.FeatureManagement.Blazor
{
[DependsOn(
typeof(AbpAspNetCoreComponentsWebAssemblyThemingModule),
typeof(AbpAutoMapperModule),
typeof(AbpFeatureManagementHttpApiClientModule)
)]
public class AbpFeatureManagementBlazorModule : AbpModule
{
}
}

@ -0,0 +1,85 @@
@using Microsoft.Extensions.Localization
@using Volo.Abp.FeatureManagement.Localization
@using Volo.Abp.Validation.StringValues
@inject IStringLocalizer<AbpFeatureManagementResource> L
<Modal @ref="_modal">
<ModalBackdrop />
<ModalContent Size="ModalSize.Large" IsCentered="true">
<ModalHeader>
<ModalTitle>@L["Features"]</ModalTitle>
<CloseButton Clicked="CloseModal" />
</ModalHeader>
<ModalBody MaxHeight="50">
@if (_groups == null)
{
<span>@L["NoFeatureFoundMessage"]</span>
}
else
{
<Tabs TabPosition="TabPosition.Left" Pills="true" SelectedTab="@GetNormalizedGroupName(_groups.First().Name)">
<Items>
@foreach (var group in _groups)
{
<Tab Name="@GetNormalizedGroupName(group.Name)">
<span>@group.DisplayName</span>
</Tab>
}
</Items>
<Content>
@foreach (var group in _groups)
{
<TabPanel Name="@GetNormalizedGroupName(group.Name)">
<h4>@group.DisplayName</h4>
@foreach (var feature in group.Features)
{
var disabled = IsDisabled(feature.Provider.Name);
if (feature.ValueType is FreeTextStringValueType)
{
<Field>
<FieldLabel>@feature.DisplayName</FieldLabel>
<TextEdit Disabled="@disabled" @bind-text="@feature.Value" />
@if (feature.Description != null)
{
<span>@feature.Description</span>
}
</Field>
}
if (feature.ValueType is SelectionStringValueType)
{
var items = ((SelectionStringValueType) feature.ValueType).ItemSource.Items;
<Field>
<FieldLabel>@feature.DisplayName</FieldLabel>
<Select TValue="string" SelectedValue="feature.Value">
@foreach (var item in items)
{
<SelectItem Value="@item.Value">@item.DisplayText</SelectItem>
}
</Select>
</Field>
}
if (feature.ValueType is ToggleStringValueType)
{
<Field>
<Check TValue="bool" @bind-checked="@ToggleValues[feature.Name]">@feature.DisplayName</Check>
</Field>
}
}
</TabPanel>
}
</Content>
</Tabs>
}
</ModalBody>
<ModalFooter>
<Button Color="Color.Secondary" Clicked="CloseModal">@L["Cancel"]</Button>
<Button Color="Color.Primary" Clicked="SaveAsync">@L["Save"]</Button>
</ModalFooter>
</ModalContent>
</Modal>

@ -0,0 +1,70 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Microsoft.AspNetCore.Components;
using Volo.Abp.Features;
using Volo.Abp.Validation.StringValues;
namespace Volo.Abp.FeatureManagement.Blazor.Components
{
public partial class FeatureManagementModal
{
[Inject] private IFeatureAppService FeatureAppService { get; set; }
private Modal _modal;
private string _providerName;
private string _providerKey;
private List<FeatureGroupDto> _groups { get; set; }
private Dictionary<string, bool> ToggleValues;
public async Task OpenAsync(string providerName, string providerKey)
{
_providerName = providerName;
_providerKey = providerKey;
_groups = (await FeatureAppService.GetAsync(_providerName, _providerKey)).Groups;
ToggleValues = _groups
.SelectMany(x => x.Features)
.Where(x => x.ValueType is ToggleStringValueType)
.ToDictionary(x => x.Name, x => bool.Parse(x.Value));
_modal.Show();
}
private void CloseModal()
{
_modal.Hide();
}
private async Task SaveAsync()
{
var features = new UpdateFeaturesDto
{
Features = _groups.SelectMany(g => g.Features).Select(f => new UpdateFeatureDto
{
Name = f.Name,
Value = f.ValueType is ToggleStringValueType ? ToggleValues[f.Name].ToString() : f.Value
}).ToList()
};
await FeatureAppService.UpdateAsync(_providerName, _providerKey, features);
_modal.Hide();
}
public string GetNormalizedGroupName(string name)
{
return "FeatureGroup_" + name.Replace(".", "_");
}
public virtual bool IsDisabled(string providerName)
{
return providerName != _providerName && providerName != DefaultValueFeatureValueProvider.ProviderName;
}
}
}

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait ContinueOnCapturedContext="false" />
</Weavers>

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" />
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<Import Project="..\..\..\..\configureawait.props" />
<Import Project="..\..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Components.WebAssembly.Theming\Volo.Abp.AspNetCore.Components.WebAssembly.Theming.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AutoMapper\Volo.Abp.AutoMapper.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.FeatureManagement.HttpApi.Client\Volo.Abp.FeatureManagement.HttpApi.Client.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="_Imports.razor">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
<Content Update="Components\FeatureManagementModal.razor">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
</ItemGroup>
</Project>

@ -0,0 +1,5 @@
@using Microsoft.AspNetCore.Components.Web
@using Volo.Abp.AspNetCore.Components.WebAssembly
@using Volo.Abp.BlazoriseUI
@using Blazorise
@using Blazorise.DataGrid
Loading…
Cancel
Save