Browse Source

Merge branch 'dev' into cotur/component-base

pull/6008/head
Ahmet 6 years ago
parent
commit
c7cbd2db3a
  1. 30
      framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs
  2. 8
      framework/src/Volo.Abp.BlazoriseUI/Components/ActionType.cs
  3. 30
      framework/src/Volo.Abp.BlazoriseUI/Components/DataGridEntityActionsColumn.cs
  4. 21
      framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor
  5. 75
      framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs
  6. 30
      framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor
  7. 49
      framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor.cs
  8. 117
      modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor
  9. 14
      modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor.cs
  10. 62
      modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor
  11. 27
      modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs
  12. 1
      modules/identity/src/Volo.Abp.Identity.Blazor/_Imports.razor
  13. 56
      modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor
  14. 37
      modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor.cs
  15. 1
      modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/_Imports.razor

30
framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs

@ -15,6 +15,7 @@ using Volo.Abp.Application.Services;
using Volo.Abp.AspNetCore.Components;
using Volo.Abp.AspNetCore.Components.WebAssembly;
using Volo.Abp.Authorization;
using Volo.Abp.BlazoriseUI.Components;
using Volo.Abp.ObjectMapping;
namespace Volo.Abp.BlazoriseUI
@ -170,7 +171,6 @@ namespace Volo.Abp.BlazoriseUI
where TUpdateViewModel : class, new()
{
[Inject] protected TAppService AppService { get; set; }
[Inject] protected IUiMessageService UiMessageService { get; set; }
[Inject] protected IStringLocalizer<AbpUiResource> UiLocalizer { get; set; }
[Inject] protected IAuthorizationService AuthorizationService { get; set; }
@ -189,6 +189,7 @@ namespace Volo.Abp.BlazoriseUI
protected Validations CreateValidationsRef;
protected Validations EditValidationsRef;
protected List<BreadcrumbItem> BreadcrumbItems = new List<BreadcrumbItem>(2);
protected DataGridEntityActionsColumn<TListViewModel> EntityActionsColumn;
protected string CreatePolicyName { get; set; }
protected string UpdatePolicyName { get; set; }
@ -281,9 +282,7 @@ namespace Volo.Abp.BlazoriseUI
protected virtual async Task OpenCreateModalAsync()
{
await OnOpeningCreateModalAsync();
CreateValidationsRef.ClearAll();
CreateValidationsRef?.ClearAll();
await CheckCreatePolicyAsync();
@ -296,11 +295,6 @@ namespace Volo.Abp.BlazoriseUI
CreateModal.Show();
}
protected virtual Task OnOpeningCreateModalAsync()
{
return Task.CompletedTask;
}
protected virtual Task CloseCreateModalAsync()
{
CreateModal.Hide();
@ -309,9 +303,7 @@ namespace Volo.Abp.BlazoriseUI
protected virtual async Task OpenEditModalAsync(TKey id)
{
await OnOpeningEditModalAsync(id);
EditValidationsRef.ClearAll();
EditValidationsRef?.ClearAll();
await CheckUpdatePolicyAsync();
@ -325,11 +317,6 @@ namespace Volo.Abp.BlazoriseUI
EditModal.Show();
}
protected virtual Task OnOpeningEditModalAsync(TKey id)
{
return Task.CompletedTask;
}
protected virtual TUpdateViewModel MapToEditingEntity(TGetOutputDto entityDto)
{
return ObjectMapper.Map<TGetOutputDto, TUpdateViewModel>(entityDto);
@ -363,7 +350,7 @@ namespace Volo.Abp.BlazoriseUI
protected virtual async Task CreateEntityAsync()
{
if (CreateValidationsRef.ValidateAll())
if (CreateValidationsRef?.ValidateAll() ?? false)
{
await OnCreatingEntityAsync();
@ -390,7 +377,7 @@ namespace Volo.Abp.BlazoriseUI
protected virtual async Task UpdateEntityAsync()
{
if (EditValidationsRef.ValidateAll())
if (EditValidationsRef?.ValidateAll() ?? false)
{
await OnUpdatingEntityAsync();
@ -419,11 +406,6 @@ namespace Volo.Abp.BlazoriseUI
{
await CheckDeletePolicyAsync();
if (!await UiMessageService.ConfirmAsync(GetDeleteConfirmationMessage(entity)))
{
return;
}
await AppService.DeleteAsync(entity.Id);
await GetEntitiesAsync();
}

8
framework/src/Volo.Abp.BlazoriseUI/Components/ActionType.cs

@ -0,0 +1,8 @@
namespace Volo.Abp.BlazoriseUI.Components
{
public enum ActionType
{
Dropdown,
Button
}
}

30
framework/src/Volo.Abp.BlazoriseUI/Components/DataGridEntityActionsColumn.cs

@ -0,0 +1,30 @@
using System.Linq;
using System.Threading.Tasks;
using Blazorise.DataGrid;
using Localization.Resources.AbpUi;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
namespace Volo.Abp.BlazoriseUI.Components
{
public class DataGridEntityActionsColumn<TItem> : DataGridColumn<TItem>
{
[Inject]
public IStringLocalizer<AbpUiResource> UiLocalizer { get; set; }
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
await SetDefaultValuesAsync();
}
protected virtual ValueTask SetDefaultValuesAsync()
{
Caption = UiLocalizer["Actions"];
Width = "150px";
Sortable = false;
Field = typeof(TItem).GetProperties().First().Name;
return ValueTask.CompletedTask;
}
}
}

21
framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor

@ -0,0 +1,21 @@
@typeparam TItem
@using Blazorise
@if (ParentActions.Type == ActionType.Dropdown)
{
if (IsVisible && Primary == false)
{
<DropdownItem Clicked="@ActionClickedAsync">@Text</DropdownItem>
}
}
else
{
if (IsVisible)
{
<Blazorise.Button Block="true"
Color="@Color"
Clicked="@ActionClickedAsync">
@Text
</Blazorise.Button>
}
}

75
framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs

@ -0,0 +1,75 @@
using System;
using System.Threading.Tasks;
using Blazorise;
using Localization.Resources.AbpUi;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
using Volo.Abp.AspNetCore.Components.WebAssembly;
namespace Volo.Abp.BlazoriseUI.Components
{
public partial class EntityAction<TItem> : ComponentBase
{
internal bool IsVisible = true;
[Parameter]
public string Text { get; set; }
[Parameter]
public bool Primary { get; set; }
[Parameter]
public EventCallback Clicked { get; set; }
[Parameter]
public string RequiredPolicy { get; set; }
[Parameter]
public Color Color { get; set; }
[Parameter]
public Func<string> ConfirmationMessage { get; set; }
[CascadingParameter]
public EntityActions<TItem> ParentActions { get; set; }
[Inject]
protected IAuthorizationService AuthorizationService { get; set; }
[Inject]
protected IUiMessageService UiMessageService { get; set; }
protected async override Task OnInitializedAsync()
{
await base.OnInitializedAsync();
await SetDefaultValuesAsync();
if (!RequiredPolicy.IsNullOrEmpty())
{
IsVisible = await AuthorizationService.IsGrantedAsync(RequiredPolicy);
}
ParentActions.AddAction(this);
}
protected internal virtual async Task ActionClickedAsync()
{
if (ConfirmationMessage != null)
{
if (await UiMessageService.ConfirmAsync(ConfirmationMessage()))
{
await Clicked.InvokeAsync();
}
}
else
{
await Clicked.InvokeAsync();
}
}
protected virtual ValueTask SetDefaultValuesAsync()
{
Color = Color.Primary;
return ValueTask.CompletedTask;
}
}
}

30
framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor

@ -0,0 +1,30 @@
@typeparam TItem
<CascadingValue Value="this">
@if (Type == ActionType.Dropdown)
{
<Dropdown>
@if (HasPrimaryAction)
{
<Blazorise.Button Block="true"
Color="@PrimaryAction.Color"
Clicked="async ()=> await PrimaryAction.ActionClickedAsync()">
@PrimaryAction.Text
</Blazorise.Button>
<DropdownToggle Color="@ToggleColor" Split="true" />
}
else
{
<DropdownToggle Color="@ToggleColor">
@ToggleText
</DropdownToggle>
}
<DropdownMenu>
@ChildContent
</DropdownMenu>
</Dropdown>
}
else
{
@ChildContent
}
</CascadingValue>

49
framework/src/Volo.Abp.BlazoriseUI/Components/EntityActions.razor.cs

@ -0,0 +1,49 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Localization.Resources.AbpUi;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
namespace Volo.Abp.BlazoriseUI.Components
{
public partial class EntityActions<TItem> : ComponentBase
{
protected readonly List<EntityAction<TItem>> Actions = new List<EntityAction<TItem>>();
protected bool HasPrimaryAction => Actions.Any(t => t.Primary);
protected EntityAction<TItem> PrimaryAction => Actions.FirstOrDefault(t => t.Primary);
protected internal ActionType Type => Actions.Count(t => t.IsVisible) > 1 ? ActionType.Dropdown : ActionType.Button;
[Parameter]
public Color ToggleColor { get; set; } = Color.Primary;
[Parameter]
public string ToggleText { get; set; }
[Parameter]
public RenderFragment ChildContent { get; set; }
[Parameter]
public DataGridEntityActionsColumn<TItem> EntityActionsColumn { get; set; }
[Inject]
public IStringLocalizer<AbpUiResource> UiLocalizer { get; set; }
internal void AddAction(EntityAction<TItem> action)
{
Actions.Add(action);
if (EntityActionsColumn != null)
{
EntityActionsColumn.Displayable = Actions.Any(t => t.IsVisible);
}
StateHasChanged();
}
protected override void OnInitialized()
{
base.OnInitialized();
ToggleText = UiLocalizer["Actions"];
}
}
}

117
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor

@ -1,5 +1,5 @@
@page "/identity/roles"
@attribute [Authorize( IdentityPermissions.Roles.Default )]
@attribute [Authorize(IdentityPermissions.Roles.Default)]
@using Volo.Abp.Identity
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Forms
@ -16,7 +16,7 @@
<Heading Size="HeadingSize.Is1">@L["Roles"]</Heading>
</Column>
<Column ColumnSize="ColumnSize.Is6">
@if ( HasCreatePermission )
@if (HasCreatePermission)
{
<Paragraph Alignment="TextAlignment.Right">
<Button Color="Color.Primary" Clicked="OpenCreateModalAsync">@L["NewRole"]</Button>
@ -33,40 +33,33 @@
ShowPager="true"
PageSize="PageSize">
<DataGridColumns>
@if ( ShouldShowEntityActions )
{
<DataGridColumn Width="150px" TItem="IdentityRoleDto" Field="@nameof(IdentityRoleDto.Name)" Sortable="false" Caption="@L["Actions"].Value">
<DisplayTemplate>
<Dropdown>
<DropdownToggle Color="Color.Primary">
@L["Actions"]
</DropdownToggle>
<DropdownMenu>
@if ( HasUpdatePermission )
{
<DropdownItem Clicked="() => OpenEditModalAsync(context.As<IdentityRoleDto>().Id)">@L["Edit"]</DropdownItem>
}
@if ( HasManagePermissionsPermission )
{
<DropdownItem Clicked="() => PermissionManagementModal.OpenAsync(PermissionProviderName, context.As<IdentityRoleDto>().Name)">@L["Permissions"]</DropdownItem>
}
@if ( HasDeletePermission )
{
<DropdownItem Clicked="() => DeleteEntityAsync(context.As<IdentityRoleDto>())">@L["Delete"]</DropdownItem>
}
</DropdownMenu>
</Dropdown>
</DisplayTemplate>
</DataGridColumn>
}
<DataGridEntityActionsColumn TItem="IdentityRoleDto" @ref="@EntityActionsColumn">
<DisplayTemplate>
<EntityActions TItem="IdentityRoleDto" EntityActionsColumn="@EntityActionsColumn">
<EntityAction TItem="IdentityRoleDto"
RequiredPolicy="@UpdatePolicyName"
Clicked="() => OpenEditModalAsync(context.Id)"
Text="@L["Edit"]"></EntityAction>
<EntityAction TItem="IdentityRoleDto"
RequiredPolicy="@ManagePermissionsPolicyName"
Clicked="() => PermissionManagementModal.OpenAsync(PermissionProviderName, context.Name)"
Text="@L["Permissions"]"></EntityAction>
<EntityAction TItem="IdentityRoleDto"
RequiredPolicy="@DeletePolicyName"
Clicked="() => DeleteEntityAsync(context)"
ConfirmationMessage="()=> GetDeleteConfirmationMessage(context)"
Text="@L["Delete"]"></EntityAction>
</EntityActions>
</DisplayTemplate>
</DataGridEntityActionsColumn>
<DataGridColumn TItem="IdentityRoleDto" Field="@nameof(IdentityRoleDto.Name)" Caption="@L["RoleName"].Value">
<DisplayTemplate>
@(context.As<IdentityRoleDto>().Name)
@if ( context.As<IdentityRoleDto>().IsDefault )
@(context.Name)
@if (context.IsDefault)
{
<Badge Color="Color.Primary">@L["DisplayName:IsDefault"]</Badge>
}
@if ( context.As<IdentityRoleDto>().IsPublic )
@if (context.IsPublic)
{
<Badge Color="Color.Light">@L["DisplayName:IsPublic"]</Badge>
}
@ -76,42 +69,42 @@
</DataGrid>
@* ************************* CREATE MODAL ************************* *@
@if ( HasCreatePermission )
@if (HasCreatePermission)
{
<Modal @ref="CreateModal">
<ModalBackdrop />
<ModalContent Centered="true">
<ModalHeader>
<ModalTitle>@L["NewRole"]</ModalTitle>
<CloseButton Clicked="CloseCreateModalAsync" />
</ModalHeader>
<ModalBody>
<Validations @ref="@CreateValidationsRef" Model="@NewEntity" ValidateOnLoad="false">
<Validation MessageLocalizer="@LH.Localize">
<Field>
<FieldLabel>@L["DisplayName:RoleName"]</FieldLabel>
<TextEdit @bind-Text="@NewEntity.Name">
<Feedback>
<ValidationError />
</Feedback>
</TextEdit>
</Field>
</Validation>
<Modal @ref="CreateModal">
<ModalBackdrop />
<ModalContent Centered="true">
<ModalHeader>
<ModalTitle>@L["NewRole"]</ModalTitle>
<CloseButton Clicked="CloseCreateModalAsync" />
</ModalHeader>
<ModalBody>
<Validations @ref="@CreateValidationsRef" Model="@NewEntity" ValidateOnLoad="false">
<Validation MessageLocalizer="@LH.Localize">
<Field>
<Check TValue="bool" @bind-Checked="@NewEntity.IsDefault">@L["DisplayName:IsDefault"]</Check>
<Check TValue="bool" @bind-Checked="@NewEntity.IsPublic">@L["DisplayName:IsPublic"]</Check>
<FieldLabel>@L["DisplayName:RoleName"]</FieldLabel>
<TextEdit @bind-Text="@NewEntity.Name">
<Feedback>
<ValidationError />
</Feedback>
</TextEdit>
</Field>
</Validations>
</ModalBody>
<ModalFooter>
<Button Color="Color.Secondary" Clicked="CloseCreateModalAsync">@L["Cancel"]</Button>
<Button Color="Color.Primary" Clicked="CreateEntityAsync">@L["Save"]</Button>
</ModalFooter>
</ModalContent>
</Modal>
</Validation>
<Field>
<Check TValue="bool" @bind-Checked="@NewEntity.IsDefault">@L["DisplayName:IsDefault"]</Check>
<Check TValue="bool" @bind-Checked="@NewEntity.IsPublic">@L["DisplayName:IsPublic"]</Check>
</Field>
</Validations>
</ModalBody>
<ModalFooter>
<Button Color="Color.Secondary" Clicked="CloseCreateModalAsync">@L["Cancel"]</Button>
<Button Color="Color.Primary" Clicked="CreateEntityAsync">@L["Save"]</Button>
</ModalFooter>
</ModalContent>
</Modal>
}
@* ************************* EDIT MODAL ************************* *@
@if ( HasUpdatePermission )
@if (HasUpdatePermission)
{
<Modal @ref="EditModal">
<ModalBackdrop />

14
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor.cs

@ -12,6 +12,7 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity
protected const string PermissionProviderName = "R";
protected PermissionManagementModal PermissionManagementModal;
protected string ManagePermissionsPolicyName;
protected bool HasManagePermissionsPermission { get; set; }
@ -25,19 +26,12 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity
CreatePolicyName = IdentityPermissions.Roles.Create;
UpdatePolicyName = IdentityPermissions.Roles.Update;
DeletePolicyName = IdentityPermissions.Roles.Delete;
ManagePermissionsPolicyName = IdentityPermissions.Roles.ManagePermissions;
}
protected async override Task SetPermissionsAsync()
protected override string GetDeleteConfirmationMessage(IdentityRoleDto entity)
{
await base.SetPermissionsAsync();
HasManagePermissionsPermission = await AuthorizationService.IsGrantedAsync(
IdentityPermissions.Roles.ManagePermissions
);
ShouldShowEntityActions = HasUpdatePermission ||
HasDeletePermission ||
HasManagePermissionsPermission;
return string.Format(L["RoleDeletionConfirmationMessage"], entity.Name);
}
}
}

62
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor

@ -1,5 +1,5 @@
@page "/identity/users"
@attribute [Authorize( IdentityPermissions.Users.Default )]
@attribute [Authorize(IdentityPermissions.Users.Default)]
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Forms
@using Volo.Abp.PermissionManagement.Blazor.Components
@ -15,7 +15,7 @@
<h1>@L["Users"]</h1>
</Column>
<Column ColumnSize="ColumnSize.Is6">
@if ( HasCreatePermission )
@if (HasCreatePermission)
{
<Paragraph Alignment="TextAlignment.Right">
<Button Color="Color.Primary" Clicked="OpenCreateModalAsync">@L["NewUser"]</Button>
@ -32,33 +32,25 @@
ShowPager="true"
PageSize="PageSize">
<DataGridColumns>
@if ( ShouldShowEntityActions )
{
<DataGridColumn Width="150px" TItem="IdentityUserDto" Field="@nameof(IdentityUserDto.UserName)" Sortable="false" Caption="@L["Actions"].Value">
<DisplayTemplate>
<Dropdown>
<DropdownToggle Color="Color.Primary">
@L["Actions"]
</DropdownToggle>
<DropdownMenu>
@if ( HasUpdatePermission )
{
<DropdownItem Clicked="() => OpenEditModalAsync(context.As<IdentityUserDto>().Id)">@L["Edit"]</DropdownItem>
}
@if ( HasManagePermissionsPermission )
{
<DropdownItem Clicked="() => PermissionManagementModal.OpenAsync(PermissionProviderName, context.As<IdentityUserDto>().Id.ToString())">@L["Permissions"]</DropdownItem>
}
@if ( HasDeletePermission )
{
<DropdownDivider />
<DropdownItem Clicked="() => DeleteEntityAsync(context.As<IdentityUserDto>())">@L["Delete"]</DropdownItem>
}
</DropdownMenu>
</Dropdown>
</DisplayTemplate>
</DataGridColumn>
}
<DataGridEntityActionsColumn TItem="IdentityUserDto" @ref="@EntityActionsColumn">
<DisplayTemplate>
<EntityActions TItem="IdentityUserDto" EntityActionsColumn="@EntityActionsColumn">
<EntityAction TItem="IdentityUserDto"
RequiredPolicy="@UpdatePolicyName"
Clicked="() => OpenEditModalAsync(context.Id)"
Text="@L["Edit"]" />
<EntityAction TItem="IdentityUserDto"
RequiredPolicy="@ManagePermissionsPolicyName"
Clicked="() => PermissionManagementModal.OpenAsync(PermissionProviderName, context.Id.ToString())"
Text="@L["Permissions"]" />
<EntityAction TItem="IdentityUserDto"
RequiredPolicy="@DeletePolicyName"
Clicked="() => DeleteEntityAsync(context)"
ConfirmationMessage="()=>GetDeleteConfirmationMessage(context)"
Text="@L["Delete"]" />
</EntityActions>
</DisplayTemplate>
</DataGridEntityActionsColumn>
<DataGridColumn TItem="IdentityUserDto" Field="@nameof(IdentityUserDto.UserName)" Caption="@L["UserName"].Value">
<DisplayTemplate>
@(context.As<IdentityUserDto>().UserName)
@ -78,7 +70,7 @@
</DataGrid>
@* ************************* CREATE MODAL ************************* *@
@if ( HasCreatePermission )
@if (HasCreatePermission)
{
<Modal @ref="CreateModal">
<ModalBackdrop />
@ -161,9 +153,9 @@
</Field>
</TabPanel>
<TabPanel Name="Roles">
@if ( NewUserRoles != null )
@if (NewUserRoles != null)
{
@foreach ( var role in NewUserRoles )
@foreach (var role in NewUserRoles)
{
<Field>
<input type="hidden" @bind-value="@role.Name" />
@ -185,7 +177,7 @@
}
@* ************************* EDIT MODAL ************************* *@
@if ( HasUpdatePermission )
@if (HasUpdatePermission)
{
<Modal @ref="EditModal">
<ModalBackdrop />
@ -270,9 +262,9 @@
</Field>
</TabPanel>
<TabPanel Name="Roles">
@if ( EditUserRoles != null )
@if (EditUserRoles != null)
{
@foreach ( var role in EditUserRoles )
@foreach (var role in EditUserRoles)
{
<Field>
<input type="hidden" @bind-value="@role.Name" />

27
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs

@ -23,8 +23,7 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity
protected AssignedRoleViewModel[] EditUserRoles;
protected bool ShouldShowEntityActions { get; set; }
protected bool HasManagePermissionsPermission { get; set; }
protected string ManagePermissionsPolicyName;
protected string CreateModalSelectedTab = DefaultSelectedTab;
@ -38,6 +37,7 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity
CreatePolicyName = IdentityPermissions.Users.Create;
UpdatePolicyName = IdentityPermissions.Users.Update;
DeletePolicyName = IdentityPermissions.Users.Delete;
ManagePermissionsPolicyName = IdentityPermissions.Users.ManagePermissions;
}
protected async override Task OnInitializedAsync()
@ -47,20 +47,8 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity
Roles = (await AppService.GetAssignableRolesAsync()).Items;
}
protected async override Task SetPermissionsAsync()
{
await base.SetPermissionsAsync();
HasManagePermissionsPermission = await AuthorizationService.IsGrantedAsync(
IdentityPermissions.Users.ManagePermissions
);
ShouldShowEntityActions = HasUpdatePermission ||
HasDeletePermission ||
HasManagePermissionsPermission;
}
protected override async Task OnOpeningCreateModalAsync()
protected override Task OpenCreateModalAsync()
{
CreateModalSelectedTab = DefaultSelectedTab;
@ -70,7 +58,7 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity
IsAssigned = x.IsDefault
}).ToArray();
await base.OnOpeningCreateModalAsync();
return base.OpenCreateModalAsync();
}
protected override Task OnCreatingEntityAsync()
@ -93,7 +81,7 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity
IsAssigned = userRoleNames.Contains(x.Name)
}).ToArray();
await base.OnOpeningEditModalAsync(id);
await base.OpenEditModalAsync(id);
}
protected override Task OnUpdatingEntityAsync()
@ -103,6 +91,11 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity
return base.OnUpdatingEntityAsync();
}
protected override string GetDeleteConfirmationMessage(IdentityUserDto entity)
{
return string.Format(L["UserDeletionConfirmationMessage"], entity.UserName);
}
}
public class AssignedRoleViewModel

1
modules/identity/src/Volo.Abp.Identity.Blazor/_Imports.razor

@ -2,5 +2,6 @@
@using Volo.Abp.AspNetCore.Components.WebAssembly
@using Microsoft.AspNetCore.Components.Forms
@using Volo.Abp.BlazoriseUI
@using Volo.Abp.BlazoriseUI.Components
@using Blazorise
@using Blazorise.DataGrid

56
modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor

@ -29,40 +29,32 @@
ShowPager="true"
PageSize="PageSize">
<DataGridColumns>
@if (ShouldShowEntityActions)
{
<DataGridColumn Width="150px" TItem="TenantDto" Field="@nameof(TenantDto.Name)" Sortable="false" Caption="@L["Actions"].Value">
<DisplayTemplate>
<Dropdown>
<DropdownToggle Color="Color.Primary">
@L["Actions"]
</DropdownToggle>
<DropdownMenu>
@if (HasUpdatePermission)
{
<DropdownItem Clicked="() => OpenEditModalAsync(context.As<TenantDto>().Id)">@L["Edit"]</DropdownItem>
}
@if (HasManageConnectionStringsPermission)
{
<DropdownItem Clicked="() => OpenEditConnectionStringModalAsync(context.As<TenantDto>().Id)">@L["ConnectionStrings"]</DropdownItem>
}
@if (HasManageFeaturesPermission)
{
<DropdownItem Clicked="() => FeatureManagementModal.OpenAsync(FeatureProviderName, context.As<TenantDto>().Id.ToString())">@L["Features"]</DropdownItem>
}
@if (HasDeletePermission)
{
<DropdownDivider />
<DropdownItem Clicked="() => DeleteEntityAsync(context.As<TenantDto>())">@L["Delete"]</DropdownItem>
}
</DropdownMenu>
</Dropdown>
</DisplayTemplate>
</DataGridColumn>
}
<DataGridEntityActionsColumn TItem="TenantDto" @ref="@EntityActionsColumn">
<DisplayTemplate>
<EntityActions TItem="TenantDto" EntityActionsColumn="@EntityActionsColumn">
<EntityAction TItem="TenantDto"
RequiredPolicy="@UpdatePolicyName"
Clicked="() => OpenEditModalAsync(context.Id)"
Text="@L["Edit"]"></EntityAction>
<EntityAction TItem="TenantDto"
RequiredPolicy="@ManageConnectionStringsPolicyName"
Clicked="() => OpenEditConnectionStringModalAsync(context.Id)"
Text="@L["ConnectionStrings"]"></EntityAction>
<EntityAction TItem="TenantDto"
RequiredPolicy="@ManageFeaturesPolicyName"
Clicked="() => FeatureManagementModal.OpenAsync(FeatureProviderName, context.Id.ToString())"
Text="@L["Features"]"></EntityAction>
<EntityAction TItem="TenantDto"
RequiredPolicy="@DeletePolicyName"
Clicked="() => DeleteEntityAsync(context)"
ConfirmationMessage="()=>GetDeleteConfirmationMessage(context)"
Text="@L["Delete"]"></EntityAction>
</EntityActions>
</DisplayTemplate>
</DataGridEntityActionsColumn>
<DataGridColumn TItem="TenantDto" Field="@nameof(TenantDto.Name)" Caption="@L["TenantName"].Value">
<DisplayTemplate>
@(context.As<TenantDto>().Name)
@(context.Name)
</DisplayTemplate>
</DataGridColumn>
</DataGridColumns>

37
modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Pages/TenantManagement/TenantManagement.razor.cs

@ -11,13 +11,14 @@ namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement
public partial class TenantManagement
{
protected const string FeatureProviderName = "T";
protected bool ShouldShowEntityActions;
protected bool HasManageConnectionStringsPermission;
protected bool HasManageFeaturesPermission;
protected string ManageConnectionStringsPolicyName;
protected string ManageFeaturesPolicyName;
protected FeatureManagementModal FeatureManagementModal;
protected Modal ManageConnectionStringModal;
protected TenantInfoModel TenantInfo;
@ -30,7 +31,9 @@ namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement
CreatePolicyName = TenantManagementPermissions.Tenants.Create;
UpdatePolicyName = TenantManagementPermissions.Tenants.Update;
DeletePolicyName = TenantManagementPermissions.Tenants.Delete;
ManageConnectionStringsPolicyName = TenantManagementPermissions.Tenants.ManageConnectionStrings;
ManageFeaturesPolicyName = TenantManagementPermissions.Tenants.ManageFeatures;
TenantInfo = new TenantInfoModel();
}
@ -38,29 +41,24 @@ namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement
{
await base.SetPermissionsAsync();
HasManageConnectionStringsPermission = await AuthorizationService.IsGrantedAsync(TenantManagementPermissions.Tenants.ManageConnectionStrings);
HasManageFeaturesPermission = await AuthorizationService.IsGrantedAsync(TenantManagementPermissions.Tenants.ManageFeatures);
ShouldShowEntityActions = HasUpdatePermission ||
HasDeletePermission ||
HasManageConnectionStringsPermission ||
HasManageFeaturesPermission;
HasManageConnectionStringsPermission = await AuthorizationService.IsGrantedAsync(ManageConnectionStringsPolicyName);
HasManageFeaturesPermission = await AuthorizationService.IsGrantedAsync(ManageFeaturesPolicyName);
}
protected virtual async Task OpenEditConnectionStringModalAsync(Guid id)
{
var tenantConnectionString = await AppService.GetDefaultConnectionStringAsync(id);
TenantInfo = new TenantInfoModel
{
Id = id,
DefaultConnectionString = tenantConnectionString,
UseSharedDatabase = tenantConnectionString.IsNullOrWhiteSpace()
};
ManageConnectionStringModal.Show();
}
protected virtual Task CloseEditConnectionStringModal()
{
ManageConnectionStringModal.Hide();
@ -69,7 +67,7 @@ namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement
protected virtual async Task UpdateConnectionStringAsync()
{
await CheckPolicyAsync(TenantManagementPermissions.Tenants.ManageConnectionStrings);
await CheckPolicyAsync(ManageConnectionStringsPolicyName);
if (TenantInfo.UseSharedDatabase || TenantInfo.DefaultConnectionString.IsNullOrWhiteSpace())
{
@ -79,9 +77,14 @@ namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement
{
await AppService.UpdateDefaultConnectionStringAsync(TenantInfo.Id, TenantInfo.DefaultConnectionString);
}
ManageConnectionStringModal.Hide();
}
protected override string GetDeleteConfirmationMessage(TenantDto entity)
{
return string.Format(L["TenantDeletionConfirmationMessage"], entity.Name);
}
}
public class TenantInfoModel
@ -89,7 +92,7 @@ namespace Volo.Abp.TenantManagement.Blazor.Pages.TenantManagement
public Guid Id { get; set; }
public bool UseSharedDatabase { get; set; }
public string DefaultConnectionString { get; set; }
}
}

1
modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/_Imports.razor

@ -2,5 +2,6 @@
@using Volo.Abp.AspNetCore.Components.WebAssembly
@using Microsoft.AspNetCore.Components.Forms
@using Volo.Abp.BlazoriseUI
@using Volo.Abp.BlazoriseUI.Components
@using Blazorise
@using Blazorise.DataGrid

Loading…
Cancel
Save