Skip to content

Commit

Permalink
Resolved merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
valadas committed Jun 28, 2024
2 parents 4823a71 + 00b3ffe commit f4ae89c
Show file tree
Hide file tree
Showing 73 changed files with 20,827 additions and 20,641 deletions.
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ updates:
Cake-Issues:
patterns:
- "Cake.Issues*"
- "Cake.Frosting.Issues*"
DependencyInjection:
patterns:
- "Microsoft.Extensions.DependencyInjection*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@
<WarningsNotAsErrors>CS0618,SA1600</WarningsNotAsErrors>
</PropertyGroup>
<ItemGroup>
<Reference Include="LiteDB, Version=5.0.13.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\LiteDB.5.0.13\lib\net45\LiteDB.dll</HintPath>
<Reference Include="LiteDB, Version=5.0.19.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27">
<HintPath>..\..\..\packages\LiteDB.5.0.19\lib\net45\LiteDB.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="LiteDB" version="5.0.13" targetFramework="net48" />
<package id="LiteDB" version="5.0.19" targetFramework="net48" />
<package id="Microsoft.Build.Tasks.Git" version="8.0.0" targetFramework="net48" developmentDependency="true" />
<package id="Microsoft.SourceLink.Common" version="8.0.0" targetFramework="net48" developmentDependency="true" />
<package id="Microsoft.SourceLink.GitHub" version="8.0.0" targetFramework="net48" developmentDependency="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IRole } from '@dnncommunity/dnn-elements/dist/types/components/dnn-perm
import { Component, Element, Event, EventEmitter, Host, h, State, Prop } from '@stencil/core';
import state from '../../store/store';
import { FolderDetails, ItemsClient, SaveFolderDetailsRequest } from '../../services/ItemsClient';
import { IPermissions, IRolePermission, IUserPermission } from '@dnncommunity/dnn-elements/dist/types/components/dnn-permissions-grid/permissions-interface';
import { IPermissionDefinition, IPermissions, IRolePermission, IUserPermission } from '@dnncommunity/dnn-elements/dist/types/components/dnn-permissions-grid/permissions-interface';
import { ISearchedUser } from '@dnncommunity/dnn-elements/dist/types/components/dnn-permissions-grid/searched-user-interface';
@Component({
tag: 'dnn-rm-edit-folder',
Expand All @@ -28,6 +28,7 @@ export class DnnRmEditFolder {
@State() folderIconUrl: string;
@State() folderDetails: FolderDetails;
@State() foundUsers: ISearchedUser[];
@State() lastPermissions: IPermissions;

private itemsClient: ItemsClient;

Expand Down Expand Up @@ -90,6 +91,7 @@ export class DnnRmEditFolder {
],
},
};
this.lastPermissions = {...this.folderDetails.permissions};
})
.catch(error => alert(error));

Expand Down Expand Up @@ -130,128 +132,107 @@ export class DnnRmEditFolder {
}

private handlePermissionsChanged(newPermissions: IPermissions): void {
newPermissions.rolePermissions.forEach(rolePermission => this.adjustRelatedPermissions(rolePermission));
newPermissions.userPermissions.forEach(userPermission => this.adjustRelatedPermissions(userPermission));
// Get previous role permissions and adjust related permissions
newPermissions.rolePermissions.forEach(rolePermission => {
const previousPermissions = this.lastPermissions?.rolePermissions?.find(p => p.roleId === rolePermission.roleId).permissions ?? [];
this.adjustRelatedPermissions(rolePermission, previousPermissions);
});

// Get previous user permissions and adjust related permissions
newPermissions.userPermissions.forEach(userPermission => {
const previousPermissions = this.lastPermissions?.userPermissions?.find(p => p.userId === userPermission.userId).permissions ?? [];
this.adjustRelatedPermissions(userPermission, previousPermissions);
});

// Update the folder details with the new permissions
this.folderDetails = {
...this.folderDetails,
permissions: newPermissions,
};

// Update the last known permissions state
this.lastPermissions = newPermissions;
}

private adjustRelatedPermissions(permission: IRolePermission | IUserPermission): void {
const permissionId =
{
private adjustRelatedPermissions(permission: IRolePermission | IUserPermission, previousPermissions: IPermissionDefinition[]): void {
const permissionIds = {
view: this.folderDetails.permissions.permissionDefinitions.find(p => p.permissionName === 'View Folder').permissionId,
browse: this.folderDetails.permissions.permissionDefinitions.find(p => p.permissionName === 'Browse Folder').permissionId,
write: this.folderDetails.permissions.permissionDefinitions.find(p => p.permissionName === 'Write to Folder').permissionId,
};

const viewPermission = permission.permissions.find(p => p.permissionId === permissionIds.view);
const browsePermission = permission.permissions.find(p => p.permissionId === permissionIds.browse);
const writePermission = permission.permissions.find(p => p.permissionId === permissionIds.write);

// Check if specific permissions have changed from the last known state
const viewChanged = viewPermission && this.hasPermissionChanged(previousPermissions, viewPermission, permissionIds.view);
const browseChanged = browsePermission && this.hasPermissionChanged(previousPermissions, browsePermission, permissionIds.browse);
const writeChanged = writePermission && this.hasPermissionChanged(previousPermissions, writePermission, permissionIds.write);

const viewPermission = permission.permissions.find(p => p.permissionId == permissionId.view);
// If view permission is denied, then deny all other permissions
if (viewPermission && viewPermission.allowAccess == false){
// Deny all permissions
permission.permissions = [
{
allowAccess: false,
fullControl: false,
permissionId: permissionId.view,
permissionCode: null,
permissionKey: null,
permissionName: "View Folder",
view: false,
},
{
allowAccess: false,
fullControl: false,
permissionId: permissionId.browse,
permissionCode: null,
permissionKey: null,
permissionName: "Browse Folder",
view: false,
},
{
allowAccess: false,
fullControl: false,
permissionId: permissionId.write,
permissionCode: null,
permissionKey: null,
permissionName: "Write to Folder",
view: false,
},
]
if (viewChanged && !viewPermission.allowAccess) {
if (browsePermission) {
browsePermission.allowAccess = false;
}
if (writePermission) {
writePermission.allowAccess = false;
}
}

// If browse was denied, then deny write
const browsePermission = permission.permissions.find(p => p.permissionId == permissionId.browse);
if (browsePermission && browsePermission.allowAccess == false){
// Deny write
permission.permissions = [
...permission.permissions.filter(p => p.permissionId != permissionId.write),
{
allowAccess: false,
fullControl: false,
permissionId: permissionId.write,
permissionCode: null,
permissionKey: null,
permissionName: "Write to Folder",
view: false,
}
]
if (browseChanged && !browsePermission.allowAccess && writePermission) {
writePermission.allowAccess = false;
}

// If browse was allowed, then allow view
if (browsePermission && browsePermission.allowAccess == true){
// Allow browse
permission.permissions = [
{
if (browseChanged && browsePermission.allowAccess) {
if (!viewPermission) {
// Create a new list with all existing permissions plus the new view permission
permission.permissions = [...permission.permissions, {
permissionId: permissionIds.view,
allowAccess: true,
fullControl: false,
permissionId: permissionId.view,
permissionCode: null,
permissionKey: null,
permissionName: "Browse Folder",
permissionName: "View Folder",
view: false,
},
...permission.permissions.filter(p => p.permissionId != permissionId.view),
];
}];
} else {
viewPermission.allowAccess = true;
}
}

// If write was allowed, then allow all other permissions
const writePermission = permission.permissions.find(p => p.permissionId == permissionId.write);
if (writePermission && writePermission.allowAccess == true){
// Allow all permissions
if (writeChanged && writePermission.allowAccess) {
permission.permissions = [
...permission.permissions.filter(p => ![permissionIds.view, permissionIds.browse].includes(p.permissionId)),
{
permissionId: permissionIds.view,
allowAccess: true,
fullControl: false,
permissionId: permissionId.view,
permissionCode: null,
permissionKey: null,
permissionName: "View Folder",
view: false,
},
{
allowAccess: true,
fullControl: false,
permissionId: permissionId.browse,
permissionCode: null,
permissionKey: null,
permissionName: "Browse Folder",
view: false,
},
{
allowAccess: true,
fullControl: false,
permissionId: permissionId.write,
permissionCode: null,
permissionKey: null,
permissionName: "Write to Folder",
view: false,
},
]
permissionId: permissionIds.browse,
allowAccess: true,
fullControl: false,
permissionCode: null,
permissionKey: null,
permissionName: "Browse Folder",
view: false,
}];
}
}

private hasPermissionChanged(lastPermissions: IPermissionDefinition[], currentPermission: IPermissionDefinition, permissionId: number): boolean {
const lastPermission = lastPermissions.find(p => p.permissionId === permissionId)
return !lastPermission || JSON.stringify(lastPermission) !== JSON.stringify(currentPermission);
}

private handleUserSearchQueryChanged(detail: string): void {
this.itemsClient.searchUsers(detail)
.then(data => this.foundUsers = data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
<Reference Include="Castle.Core, Version=5.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Castle.Core.5.1.1\lib\net462\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.18.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Moq.4.18.4\lib\net462\Moq.dll</HintPath>
<Reference Include="Moq, Version=4.20.70.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Moq.4.20.70\lib\net462\Moq.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Newtonsoft.Json.13.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<package id="Microsoft.Build.Tasks.Git" version="8.0.0" targetFramework="net48" developmentDependency="true" />
<package id="Microsoft.SourceLink.Common" version="8.0.0" targetFramework="net48" developmentDependency="true" />
<package id="Microsoft.SourceLink.GitHub" version="8.0.0" targetFramework="net48" developmentDependency="true" />
<package id="Moq" version="4.18.4" targetFramework="net48" />
<package id="Moq" version="4.20.70" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
<package id="NUnit" version="3.13.3" targetFramework="net48" />
<package id="NUnit3TestAdapter" version="4.5.0" targetFramework="net48" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
<Reference Include="ICSharpCode.SharpZipLib, Version=1.4.2.13, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\SharpZipLib.1.4.2\lib\netstandard2.0\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.18.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Moq.4.18.4\lib\net462\Moq.dll</HintPath>
<Reference Include="Moq, Version=4.20.70.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Moq.4.20.70\lib\net462\Moq.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.13.3.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\NUnit.3.13.3\lib\net45\nunit.framework.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Castle.Core" version="5.1.1" targetFramework="net48" />
<package id="Moq" version="4.18.4" targetFramework="net48" />
<package id="Moq" version="4.20.70" targetFramework="net48" />
<package id="NUnit" version="3.13.3" targetFramework="net48" />
<package id="NUnit3TestAdapter" version="4.5.0" targetFramework="net48" />
<package id="SharpZipLib" version="1.4.2" targetFramework="net48" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
<Reference Include="Castle.Core, Version=5.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Castle.Core.5.1.1\lib\net462\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.18.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Moq.4.18.4\lib\net462\Moq.dll</HintPath>
<Reference Include="Moq, Version=4.20.70.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Moq.4.20.70\lib\net462\Moq.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.13.3.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\NUnit.3.13.3\lib\net45\nunit.framework.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Castle.Core" version="5.1.1" targetFramework="net48" />
<package id="Moq" version="4.18.4" targetFramework="net48" />
<package id="Moq" version="4.20.70" targetFramework="net48" />
<package id="NUnit" version="3.13.3" targetFramework="net48" />
<package id="NUnit3TestAdapter" version="4.5.0" targetFramework="net48" />
<package id="StyleCop.Analyzers" version="1.1.118" targetFramework="net48" developmentDependency="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.18.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Moq.4.18.4\lib\net462\Moq.dll</HintPath>
<Reference Include="Moq, Version=4.20.70.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Moq.4.20.70\lib\net462\Moq.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Newtonsoft.Json.13.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.DependencyInjection" version="8.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="8.0.0" targetFramework="net48" />
<package id="Moq" version="4.18.4" targetFramework="net48" />
<package id="Moq" version="4.20.70" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
<package id="NUnit" version="3.13.3" targetFramework="net48" />
<package id="NUnit3TestAdapter" version="4.5.0" targetFramework="net48" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.18.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Moq.4.18.4\lib\net462\Moq.dll</HintPath>
<Reference Include="Moq, Version=4.20.70.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Moq.4.20.70\lib\net462\Moq.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.13.3.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\NUnit.3.13.3\lib\net45\nunit.framework.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion DNN Platform/Tests/DotNetNuke.Tests.Core/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.DependencyInjection" version="8.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="8.0.0" targetFramework="net48" />
<package id="Moq" version="4.18.4" targetFramework="net48" />
<package id="Moq" version="4.20.70" targetFramework="net48" />
<package id="NUnit" version="3.13.3" targetFramework="net48" />
<package id="NUnit3TestAdapter" version="4.5.0" targetFramework="net48" />
<package id="SharpZipLib" version="1.4.2" targetFramework="net48" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.18.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Moq.4.18.4\lib\net462\Moq.dll</HintPath>
<Reference Include="Moq, Version=4.20.70.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Moq.4.20.70\lib\net462\Moq.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.13.3.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\NUnit.3.13.3\lib\net45\nunit.framework.dll</HintPath>
Expand Down
Loading

0 comments on commit f4ae89c

Please sign in to comment.