Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: types for entity views #1477

Merged
merged 5 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"docs:dev:acetate": "acetate server --log=debug --config docs/acetate.config.js --startPath hub.js/index.html",
"docs:dev:css": "cpx \"docs/src/css/*.css\" docs/build/hub.js/css",
"docs:dev:images": "cpx \"docs/src/**/*.{png,jpg,jpeg,gif,svg,webm,ogg}\" docs/build/hub.js -w",
"docs:dev:js": "cpx \"docs/src/**/{api-search,nav-toggle}.js\" docs/build/hub.js -w",
"docs:dev:js": "cpx \"docs/src/js/*.js\" docs/build/hub.js/js",
"docs:dev:typedoc": "onchange -v 'packages/*/src/**/*.ts' -- npm run docs:typedoc",
"docs:serve": "rimraf docs/build && concurrently \"npm run docs:dev:js\" \"npm run docs:dev:images\" \"npm run docs:dev:acetate\" \"npm run docs:dev:css\" \"npm run docs:dev:typedoc\"",
"docs:srihash": "node docs/generate-srihashes.js",
Expand Down
61 changes: 61 additions & 0 deletions packages/common/src/core/traits/ICapabilityConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { IFilter, IHubCatalog } from "../../search/types/IHubCatalog";

export type HubCapability =
| "events"
| "content"
| "projects"
| "initiatives"
| "discussions"
| "pages";

/**
* Configuration for a capability
* Typically extended by other interfaces
*/
export interface ICapabilityConfig {
enabled: boolean;
/**
* If defined, the filter will be injected into
* the entitie's content catalog's scope when the gallery is
* rendered
*/
filter?: IFilter;
/**
* If defined, this catalog is used to render the gallery
*/
catalog?: IHubCatalog;
}
/**
* We intentionally want these interfaces to exist even if they are empty
* as they are used to determine if a capability can be enabled
*/
/* tslint:disable: no-empty-interface */
export interface IEventsConfig extends ICapabilityConfig {}
export interface IProjectsConfig extends ICapabilityConfig {}
export interface IInitiativesConfig extends ICapabilityConfig {}
export interface IDiscussionsConfig extends ICapabilityConfig {}
export interface IPagesConfig extends ICapabilityConfig {}
/* tslint:enable: no-empty-interface */
export interface IContentConfig extends ICapabilityConfig {
feeds?: any; // TODO: lookup the type as this is defined somewhere
}

export interface IWithEvents {
events?: IEventsConfig;
}

export interface IWithProjects {
projects?: IProjectsConfig;
}

export interface IWithInitiatives {
initiatives?: IInitiativesConfig;
}

export interface IWithPages {
pages?: IPagesConfig;
}

export interface IWithContent {
content?: IContentConfig;
}
1 change: 1 addition & 0 deletions packages/common/src/core/traits/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from "./IWithPermissions";
export * from "./IWithCatalog";
export * from "./IWithViewSettings";
export * from "./IWithDiscussions";
export * from "./ICapabilityConfig";
14 changes: 8 additions & 6 deletions packages/common/src/core/types/IHubProject.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { IWithCatalog } from "../traits/IWithCatalog";
import { IWithLayout } from "../traits/IWithLayout";
import { IWithMetrics } from "../traits/IWithMetrics";
import { IWithPermissions } from "../traits/IWithPermissions";
import { IWithSlug } from "../traits/IWithSlug";
import { IWithStatus } from "../traits/IWithStatus";
import {
IWithLayout,
IWithPermissions,
IWithSlug,
IWithCatalog,
} from "../traits/index";
import { IWithContent, IWithEvents } from "../traits/ICapabilityConfig";

import { IHubItemEntity, IHubItemEntityEditor } from "./IHubItemEntity";

/**
Expand All @@ -18,6 +18,8 @@ export interface IHubProject
IWithLayout,
IWithMetrics,
IWithPermissions,
IWithEvents,
IWithContent,
IWithStatus {}

/**
Expand Down
5 changes: 5 additions & 0 deletions packages/common/src/events/_internal/EventBusinessRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const EventPermissions = [
"hub:event:workspace:collaborators",
"hub:event:workspace:manage",
"hub:event:workspace:attendees",
"hub:event:workspace:content",
"hub:event:manage",
] as const;

Expand Down Expand Up @@ -110,6 +111,10 @@ export const EventPermissionPolicies: IPermissionPolicy[] = [
permission: "hub:event:workspace:attendees",
dependencies: ["hub:event:workspace", "hub:event:edit"],
},
{
permission: "hub:event:workspace:content",
dependencies: ["hub:event:workspace", "hub:event:edit"],
},
{
permission: "hub:event:manage",
dependencies: ["hub:event:edit"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const InitiativePermissions = [
"hub:initiative:workspace:settings",
"hub:initiative:workspace:collaborators",
"hub:initiative:workspace:content",
"hub:initiative:workspace:events",
"hub:initiative:workspace:metrics",
"hub:initiative:workspace:associationGroup:create",
"hub:initiative:manage",
Expand Down Expand Up @@ -175,6 +176,12 @@ export const InitiativePermissionPolicies: IPermissionPolicy[] = [
{
permission: "hub:initiative:workspace:content",
dependencies: ["hub:initiative:workspace", "hub:initiative:edit"],
availability: ["alpha"],
},
{
permission: "hub:initiative:workspace:events",
dependencies: ["hub:initiative:workspace", "hub:initiative:edit"],
availability: ["alpha"],
},
{
permission: "hub:initiative:workspace:metrics",
Expand Down
4 changes: 4 additions & 0 deletions packages/common/src/initiatives/_internal/getPropertyMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export function getPropertyMap(): IPropertyMap[] {
map.push({ entityKey: "contacts", storeKey: "data.contacts" });
map.push({ entityKey: "timeline", storeKey: "data.timeline" });

// Capabilities
map.push({ entityKey: "content", storeKey: "data.content" });
map.push({ entityKey: "events", storeKey: "data.events" });

// Deeper/Indirect mappings
map.push({ entityKey: "metrics", storeKey: "item.properties.metrics" });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const ProjectPermissions = [
"hub:project:workspace:settings",
"hub:project:workspace:collaborators",
"hub:project:workspace:content",
"hub:project:workspace:events",
"hub:project:workspace:metrics",
"hub:project:manage",
] as const;
Expand Down Expand Up @@ -151,6 +152,12 @@ export const ProjectPermissionPolicies: IPermissionPolicy[] = [
{
permission: "hub:project:workspace:content",
dependencies: ["hub:project:workspace", "hub:project:edit"],
availability: ["alpha"],
},
{
permission: "hub:project:workspace:events",
dependencies: ["hub:project:workspace", "hub:project:edit"],
availability: ["alpha"],
},
{
permission: "hub:project:workspace:metrics",
Expand Down
8 changes: 7 additions & 1 deletion packages/common/src/projects/_internal/getPropertyMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@ import { getBasePropertyMap } from "../../core/_internal/getBasePropertyMap";

export function getPropertyMap(): IPropertyMap[] {
const map = getBasePropertyMap();

// Type specific mappings
map.push({ entityKey: "status", storeKey: "data.status" });

// TOOD: Remove catalog and swap to using the content-capability-pane in the UI
map.push({ entityKey: "catalog", storeKey: "data.catalog" });

// Capabilities
map.push({ entityKey: "content", storeKey: "data.content" });
map.push({ entityKey: "events", storeKey: "data.events" });

map.push({ entityKey: "permissions", storeKey: "data.permissions" });
map.push({
entityKey: "features",
Expand Down
24 changes: 24 additions & 0 deletions packages/common/src/sites/_internal/SiteBusinessRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export const SitePermissions = [
"hub:site:workspace:followers:manager",
"hub:site:workspace:followers:create",
"hub:site:workspace:discussion",
"hub:site:workspace:pages",
"hub:site:workspace:events",
"hub:site:workspace:projects",
"hub:site:workspace:initiatives",
"hub:site:manage",
] as const;

Expand Down Expand Up @@ -150,6 +154,16 @@ export const SitesPermissionPolicies: IPermissionPolicy[] = [
permission: "hub:site:workspace:content",
dependencies: ["hub:site:workspace", "hub:site:edit"],
},
{
permission: "hub:site:workspace:pages",
dependencies: ["hub:site:workspace", "hub:site:edit"],
availability: ["alpha"],
},
{
permission: "hub:site:workspace:events",
dependencies: ["hub:site:workspace", "hub:site:edit"],
availability: ["alpha"],
},
{
permission: "hub:site:workspace:metrics",
dependencies: ["hub:site:workspace", "hub:site:edit"],
Expand Down Expand Up @@ -198,6 +212,16 @@ export const SitesPermissionPolicies: IPermissionPolicy[] = [
permission: "hub:site:workspace:discussion",
dependencies: ["hub:site:workspace", "hub:site:edit"],
},
{
permission: "hub:site:workspace:projects",
dependencies: ["hub:site:workspace", "hub:site:edit"],
availability: ["alpha"],
},
{
permission: "hub:site:workspace:initiatives",
dependencies: ["hub:site:workspace", "hub:site:edit"],
availability: ["alpha"],
},
{
permission: "hub:site:manage",
dependencies: ["hub:site:edit"],
Expand Down
5 changes: 5 additions & 0 deletions packages/common/src/sites/_internal/getPropertyMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export function getPropertyMap(): IPropertyMap[] {
valueProps.forEach((entry) => {
map.push({ entityKey: entry, storeKey: `data.values.${entry}` });
});
// Capabilities
map.push({ entityKey: "events", storeKey: "data.events" });
map.push({ entityKey: "initiatives", storeKey: "data.initiatives" });
map.push({ entityKey: "projects", storeKey: "data.projects" });

// Deeper/Indirect mappings
map.push({
entityKey: "slug",
Expand Down
Loading