Skip to content

Commit

Permalink
Fix/user team permission (#1213)
Browse files Browse the repository at this point in the history
* feat:disabled user and team permission check

* feat:update package
  • Loading branch information
MayueCif authored Jul 28, 2023
1 parent f45ad99 commit db6ff7e
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="Humanizer.Core.zh-CN" Version="2.14.1" />
<PackageReference Include="Mapster" Version="7.3.0" />
<PackageReference Include="Masa.Stack.Components" Version="0.0.419" />
<PackageReference Include="Masa.Stack.Components" Version="0.0.421" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.7" />
<!--Support GB2312-->
<PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
@inherits AdminCompontentBase

<ExpansionMenuWrapper Value="Menu" />
@if (HasPreview)
{
<ExpansionMenuWrapper Value="Menu" />

<DefaultSheetDialog Value="Preview" ValueChanged="PreviewChanged" Title="@T("Preview Permissions")">
<AutoHeight>
<AutoHeightContent>
<div class="global-nav" style="max-height:calc(100vh - 230px);">
<ExpansionMenuWrapper Value="PreviewMenu" />
</div>
</AutoHeightContent>
<FooterContent>
<div class="d-flex mt-6">
<MSpacer />
<SButton OnClick="async() => await PreviewChanged.InvokeAsync(false)" Medium Outlined>
@T("Back")
</SButton>
</div>
</FooterContent>
</AutoHeight>
</DefaultSheetDialog>
<DefaultSheetDialog Value="Preview" ValueChanged="PreviewChanged" Title="@T("Preview Permissions")">
<AutoHeight>
<AutoHeightContent>
<div class="global-nav" style="max-height:calc(100vh - 230px);">
<ExpansionMenuWrapper Value="PreviewMenu" />
</div>
</AutoHeightContent>
<FooterContent>
<div class="d-flex mt-6">
<MSpacer />
<SButton OnClick="async() => await PreviewChanged.InvokeAsync(false)" Medium Outlined>
@T("Back")
</SButton>
</div>
</FooterContent>
</AutoHeight>
</DefaultSheetDialog>
}
else
{
<ExpansionMenuWrapper Value="PreviewMenu" />
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public partial class PermissionsConfigure
[Parameter]
public EventCallback<List<SubjectPermissionRelationDto>> ValueChanged { get; set; }

[Parameter]
public bool HasPreview { get; set; }

[Parameter]
public bool Preview { get; set; }

Expand Down Expand Up @@ -129,6 +132,15 @@ protected async override Task OnParametersSetAsync()
}
}

public override Task SetParametersAsync(ParameterView parameters)
{
if (parameters.TryGetValue(nameof(Preview), out bool preview) && preview != Preview)
{
_shouldRender = true;
}
return base.SetParametersAsync(parameters);
}

protected override bool ShouldRender()
{
return _shouldRender;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</HeaderContent>
<AutoHeightContent>
<div class="global-nav" style="max-height:calc(100vh - 320px);">
<PermissionsConfigure Roles=Role.ChildrenRoles
<PermissionsConfigure Roles=Role.ChildrenRoles HasPreview
@bind-Value=Role.Permissions
@bind-Preview=_preview />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public async Task GetRolesAsync()
var response = await RoleService.GetListAsync(reuquest);
Roles = response.Items;
Total = response.Total;
StateHasChanged();
}

public void OpenAddRoleDialog()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<div class="global-nav" style="display: flex;max-height:calc(100vh - 370px);">
<PermissionsConfigure
Roles=Role.ChildrenRoles
HasPreview
@bind-Value=Role.Permissions
@bind-Preview=Preview/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<RoleSelectForTeam @bind-Value="Value.Roles" TeamUserCount=Value.Staffs.Count RoleLimitChanged="value => RoleLimit=value" Class="mb-6" Label="@T("Role")" />
<div class="global-nav" style="max-height:calc(100vh - 450px);">
<PermissionsConfigure Roles=Value.Roles
@bind-Value="Value.Permissions"
Preview=Preview
PreviewChanged=PreviewChanged />
@bind-Value="Value.Permissions"/>
</div>
</MCardText>
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,5 @@ public partial class TeamAdmin
[Parameter]
public EventCallback<TeamPersonnelDto> ValueChanged { get; set; }

[Parameter]
public bool Preview { get; set; }

[Parameter]
public EventCallback<bool> PreviewChanged { get; set; }

public RoleLimitModel RoleLimit { get; set; } = new("", int.MaxValue);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<RoleSelectForTeam @bind-Value="Value.Roles" ScopeItems="ScopeRoles" TeamUserCount=Value.Staffs.Count RoleLimitChanged="value => RoleLimit=value" Class="mb-6" Label="@T("Role")" />
<div class="global-nav" style="max-height:calc(100vh - 450px);">
<PermissionsConfigure Roles=Value.Roles
@bind-Value="Value.Permissions"
Preview=Preview
PreviewChanged=PreviewChanged />
@bind-Value="Value.Permissions"/>
</div>
</MCardText>
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ public partial class TeamMember
[Parameter]
public EventCallback<TeamPersonnelDto> ValueChanged { get; set; }

[Parameter]
public bool Preview { get; set; }

[Parameter]
public EventCallback<bool> PreviewChanged { get; set; }

public RoleLimitModel RoleLimit { get; set; } = new("", int.MaxValue);

private PermissionService PermissionService => AuthCaller.PermissionService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,17 @@
<TeamBasicInfo @bind-Value="Dto.TeamBasicInfo" />
</SElevationTabItem>
<SElevationTabItem>
<TeamAdmin IgnoreStaffIds="Dto.TeamMember.Staffs" @bind-Preview=_adminPreview @bind-Value="Dto.TeamAdmin" />
<TeamAdmin IgnoreStaffIds="Dto.TeamMember.Staffs" @bind-Value="Dto.TeamAdmin" />
</SElevationTabItem>
<SElevationTabItem>
<TeamMember IgnoreStaffIds="Dto.TeamAdmin.Staffs" @bind-Preview=_memberPreview @bind-Value="Dto.TeamMember" />
<TeamMember IgnoreStaffIds="Dto.TeamAdmin.Staffs" @bind-Value="Dto.TeamMember" />
</SElevationTabItem>
</SElevationTab>
<MCardActions class="d-flex align-center px-6">
<SButton Text Color="error" MinWidth="100" OnClick="OnDeleteHandler">
@T("Delete")
</SButton>
<MSpacer />
@if (_tabs.IndexOf(_tab)>0)
{
<SButton Outlined Medium Class="mr-4" OnClick="OnPreview">@T("Preview")</SButton>
}
<SButton Medium MinWidth="100" OnClick="OnUpdateHandler">@T("Save")</SButton>
</MCardActions>
</DefaultSheetDialog>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class UpdateSheet
[Parameter]
public Func<Guid, string, Task<bool>>? OnDelete { get; set; }

bool _adminPreview, _memberPreview, _visible;
bool _visible;
string _tab = "";
List<string> _tabs = new();

Expand All @@ -34,18 +34,6 @@ protected override void OnAfterRender(bool firstRender)
base.OnAfterRender(firstRender);
}

private void OnPreview()
{
if (_tab == T("Setup team admins"))
{
_adminPreview = true;
}
else
{
_memberPreview = true;
}
}

public void Show(TeamDetailDto model)
{
Dto = model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,15 @@
</HeaderContent>
<AutoHeightContent>
<div class="global-nav" style="display: flex;max-height:calc(100vh - 380px);">
<PermissionsConfigure
User=_userId
<PermissionsConfigure User=_userId
Teams=Teams
Roles=Authorization.Roles
@bind-Value=Authorization.Permissions
@bind-Preview=_preview/>
@bind-Value=Authorization.Permissions/>
</div>
</AutoHeightContent>
<FooterContent>
<div class="d-flex mt-6">
<MSpacer></MSpacer>
<SButton Medium Outlined OnClick="() => _preview = true">@T("Preview")</SButton>
<SButton Medium Class="ml-6" OnClick="async () => await UpdateAuthorizationAsync()">@T("Save")</SButton>
</div>
</FooterContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ public partial class UserAuthorizeDialog
{
private bool _visible = false;
private Guid _userId = Guid.Empty;
private bool _preview = false;
private List<Guid> _roles = new();

[Parameter]
public EventCallback<bool> VisibleChanged { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/Web/Masa.Auth.Web.Sso/Masa.Auth.Web.Sso.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PackageReference Include="IdentityServer4" Version="4.1.2" />
<PackageReference Include="Mapster" Version="7.3.0" />
<PackageReference Include="FluentValidation" Version="11.4.0" />
<PackageReference Include="Masa.Blazor" Version="1.0.0" />
<PackageReference Include="Masa.Blazor" Version="1.0.1" />
<PackageReference Include="Masa.Contrib.Authentication.OpenIdConnect.Cache.Storage" Version="$(MasaFrameworkPackageVersion)" />
<PackageReference Include="Masa.Contrib.Development.DaprStarter.AspNetCore" Version="$(MasaFrameworkPackageVersion)" />
<PackageReference Include="Masa.Contrib.StackSdks.Caller" Version="$(MasaFrameworkPackageVersion)" />
Expand Down

0 comments on commit db6ff7e

Please sign in to comment.