Skip to content

Commit

Permalink
feat: site's followers pane permissions (#1186)
Browse files Browse the repository at this point in the history
- adds a new IWithFollowers trait with a followersGroupId property for entities to extend if they support followers
- adds business rules for site's followers pane
  • Loading branch information
juliannemarik authored Aug 24, 2023
1 parent 7ae927a commit 90feec7
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/common/src/core/traits/IWithFollowers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* properties for entities with followers
*/
export interface IWithFollowers {
/** followers group id */
followersGroupId: string;
}
4 changes: 3 additions & 1 deletion packages/common/src/core/types/IHubSite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
IWithSlug,
} from "../traits/index";
import { IHubItemEntity } from "./IHubItemEntity";
import { IWithFollowers } from "../traits/IWithFollowers";

/**
* DRAFT: Under development and more properties will likely be added
Expand All @@ -18,7 +19,8 @@ export interface IHubSite
IWithCatalog,
IWithLayout,
IWithPermissions,
IWithVersioningBehavior {
IWithVersioningBehavior,
IWithFollowers {
/**
* Array of minimal page objects
*/
Expand Down
29 changes: 29 additions & 0 deletions packages/common/src/sites/_internal/SiteBusinessRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export const SitePermissions = [
"hub:site:workspace:collaborators",
"hub:site:workspace:content",
"hub:site:workspace:metrics",
"hub:site:workspace:followers",
"hub:site:workspace:followers:member",
"hub:site:workspace:followers:manager",
] as const;

/**
Expand Down Expand Up @@ -107,6 +110,32 @@ export const SitesPermissionPolicies: IPermissionPolicy[] = [
dependencies: ["hub:site:edit"],
environments: ["devext", "qaext"],
},
{
permission: "hub:site:workspace:followers",
dependencies: ["hub:site:edit"],
},
{
permission: "hub:site:workspace:followers:member",
dependencies: ["hub:site:workspace:followers"],
assertions: [
{
property: "context:currentUser",
type: "is-group-member",
value: "entity:followersGroupId",
},
],
},
{
permission: "hub:site:workspace:followers:manager",
dependencies: ["hub:site:workspace:followers"],
assertions: [
{
property: "context:currentUser",
type: "is-group-admin",
value: "entity:followersGroupId",
},
],
},
];

/**
Expand Down
4 changes: 4 additions & 0 deletions packages/common/src/sites/_internal/getPropertyMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export function getPropertyMap(): IPropertyMap[] {
entityKey: "slug",
storeKey: "item.properties.slug",
});
map.push({
entityKey: "followersGroupId",
storeKey: "item.properties.followersGroupId",
});
map.push({
entityKey: "legacyCapabilities",
storeKey: "data.values.capabilities",
Expand Down

0 comments on commit 90feec7

Please sign in to comment.