Skip to content

Commit 54d1fe6

Browse files
feat: scaffold solution template entity (#1253)
Scaffolds the Hub Solution Template entity
1 parent 96ec555 commit 54d1fe6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2469
-99
lines changed

packages/common/src/core/EntityEditor.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { HubInitiativeTemplate } from "../initiative-templates";
77
import { HubPage } from "../pages/HubPage";
88
import { HubProject } from "../projects/HubProject";
99
import { HubSite } from "../sites/HubSite";
10+
import { HubTemplate } from "../templates";
1011
import { IEditorConfig, IWithEditorBehavior } from "./behaviors";
1112
import { getTypeFromEntity } from "./getTypeFromEntity";
1213
import { EditorType, UiSchemaElementOptions } from "./schemas";
@@ -42,6 +43,9 @@ export class EntityEditor {
4243
if (entityType === "discussion") {
4344
editor = HubDiscussion.fromJson(entity, context) as IWithEditorBehavior;
4445
}
46+
if (entityType === "template") {
47+
editor = HubTemplate.fromJson(entity, context) as IWithEditorBehavior;
48+
}
4549
if (entityType === "group") {
4650
editor = HubGroup.fromJson(
4751
entity as unknown as HubGroup,

packages/common/src/core/fetchHubEntity.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { fetchInitiative } from "../initiatives/HubInitiatives";
44
import { fetchPage } from "../pages/HubPages";
55
import { fetchProject } from "../projects/fetch";
66
import { fetchSite } from "../sites/HubSites";
7+
import { fetchTemplate } from "../templates/fetch";
78
import { HubEntity } from "./types/HubEntity";
89
import { HubEntityType } from "./types/HubEntityType";
910
import { IArcGISContext } from "../ArcGISContext";
@@ -42,6 +43,9 @@ export async function fetchHubEntity(
4243
case "content":
4344
result = await fetchHubContent(identifier, context.requestOptions);
4445
break;
46+
case "template":
47+
result = await fetchTemplate(identifier, context.requestOptions);
48+
break;
4549
case "group":
4650
result = await fetchHubGroup(identifier, context.userRequestOptions);
4751
break;

packages/common/src/core/getTypeFromEntity.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ export function getTypeFromEntity(
2929
case "Discussion":
3030
type = "discussion";
3131
break;
32+
case "Solution":
33+
type = "template";
34+
break;
3235
case "Group":
3336
type = "group";
3437
break;

packages/common/src/core/schemas/internal/getEntityEditorSchemas.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { InitiativeEditorType } from "../../../initiatives/_internal/InitiativeS
88
import { DiscussionEditorType } from "../../../discussions/_internal/DiscussionSchema";
99
import { PageEditorType } from "../../../pages/_internal/PageSchema";
1010
import { ContentEditorType } from "../../../content/_internal/ContentSchema";
11+
import { TemplateEditorType } from "../../../templates/_internal/TemplateSchema";
1112
import { GroupEditorType } from "../../../groups/_internal/GroupSchema";
1213
import { ConfigurableEntity } from "./ConfigurableEntity";
1314
import { IArcGISContext } from "../../../ArcGISContext";
@@ -20,6 +21,7 @@ import {
2021
IHubPage,
2122
IHubProject,
2223
IHubSite,
24+
IHubTemplate,
2325
} from "../../../core/types";
2426
import { InitiativeTemplateEditorType } from "../../../initiative-templates/_internal/InitiativeTemplateSchema";
2527

@@ -171,6 +173,25 @@ export async function getEntityEditorSchemas(
171173
);
172174

173175
break;
176+
// ----------------------------------------------------
177+
case "template":
178+
const { TemplateSchema } = await import(
179+
"../../../templates/_internal/TemplateSchema"
180+
);
181+
schema = cloneObject(TemplateSchema);
182+
183+
const templateModule = await {
184+
"hub:template:edit": () =>
185+
import("../../../templates/_internal/TemplateUiSchemaEdit"),
186+
}[type as TemplateEditorType]();
187+
uiSchema = await templateModule.buildUiSchema(
188+
i18nScope,
189+
entity as IHubTemplate,
190+
context
191+
);
192+
193+
break;
194+
// ----------------------------------------------------
174195
case "group":
175196
const { GroupSchema } = await import(
176197
"../../../groups/_internal/GroupSchema"

packages/common/src/core/schemas/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { SiteEditorTypes } from "../../sites/_internal/SiteSchema";
77
import { DiscussionEditorTypes } from "../../discussions/_internal/DiscussionSchema";
88
import { PageEditorTypes } from "../../pages/_internal/PageSchema";
99
import { ContentEditorTypes } from "../../content/_internal/ContentSchema";
10+
import { TemplateEditorTypes } from "../../templates/_internal/TemplateSchema";
1011
import { GroupEditorTypes } from "../../groups/_internal/GroupSchema";
1112
import { InitiativeTemplateEditorTypes } from "../../initiative-templates/_internal/InitiativeTemplateSchema";
1213

@@ -22,6 +23,7 @@ export const validEditorTypes = [
2223
...SiteEditorTypes,
2324
...DiscussionEditorTypes,
2425
...PageEditorTypes,
26+
...TemplateEditorTypes,
2527
...GroupEditorTypes,
2628
...InitiativeTemplateEditorTypes,
2729
] as const;

packages/common/src/core/types/HubEntity.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import { IHubProject } from "./IHubProject";
44
import { IHubSite } from "./IHubSite";
55
import { IHubDiscussion } from "./IHubDiscussion";
66
import { IHubGroup } from "./IHubGroup";
7+
import { IHubTemplate } from "./IHubTemplate";
78

89
export type HubEntity =
910
| IHubSite
1011
| IHubProject
1112
| IHubDiscussion
1213
| IHubInitiative
1314
| IHubPage
14-
| IHubGroup;
15+
| IHubGroup
16+
| IHubTemplate;

packages/common/src/core/types/HubEntityType.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ export const HUB_ENTITY_TYPES = [
88
"content",
99
"org",
1010
"group",
11+
"template",
1112
] as const;
1213
export type HubEntityType = (typeof HUB_ENTITY_TYPES)[number];
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { IWithSlug } from "../traits";
2+
import { IHubItemEntity, IHubItemEntityEditor } from "./IHubItemEntity";
3+
4+
/** Defines the properties of a Hub Template entity */
5+
export interface IHubTemplate extends IHubItemEntity, IWithSlug {
6+
previewUrl: string;
7+
isDeployed: boolean;
8+
deployedType: string;
9+
}
10+
11+
/**
12+
* This type redefines the IHubTemplate interface in such a way
13+
* that it can be consumed by the entity editor.
14+
*/
15+
export type IHubTemplateEditor = IHubItemEntityEditor<IHubTemplate> & {};

packages/common/src/core/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export * from "./IHubLayout";
1717
export * from "./IHubLocation";
1818
export * from "./IHubPage";
1919
export * from "./IHubProject";
20+
export * from "./IHubTemplate";
2021
export * from "./IHubSite";
2122
export * from "./IHubSiteTheme";
2223
export * from "./IHubTimeline";

packages/common/src/core/updateHubEntity.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { updateProject } from "../projects/edit";
66
import { updateSite } from "../sites/HubSites";
77
import { updatePage } from "../pages/HubPages";
88
import { updateInitiativeTemplate } from "../initiative-templates/edit";
9+
import { updateTemplate } from "../templates/edit";
910
import {
1011
HubEntity,
1112
HubEntityType,
@@ -16,6 +17,7 @@ import {
1617
IHubSite,
1718
IHubPage,
1819
IHubInitiativeTemplate,
20+
IHubTemplate,
1921
} from "./types";
2022

2123
/**
@@ -63,6 +65,12 @@ export const updateHubEntity = async (
6365
case "page":
6466
result = await updatePage(entity as IHubPage, context.userRequestOptions);
6567
break;
68+
case "template":
69+
result = await updateTemplate(
70+
entity as IHubTemplate,
71+
context.userRequestOptions
72+
);
73+
break;
6674
case "initiativeTemplate":
6775
result = await updateInitiativeTemplate(
6876
entity as IHubInitiativeTemplate,

packages/common/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export * from "./resources";
3030
export * from "./search";
3131
export * from "./sites";
3232
export * from "./surveys";
33+
export * from "./templates";
3334
export * from "./types";
3435
export * from "./urls";
3536
export * from "./users";

packages/common/src/permissions/HubPermissionPolicies.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { GroupPermissionPolicies } from "../groups/_internal/GroupBusinessRules"
99
import { PagePermissionPolicies } from "../pages/_internal/PageBusinessRules";
1010
import { PlatformPermissionPolicies } from "./PlatformPermissionPolicies";
1111
import { InitiativeTemplatePermissionPolicies } from "../initiative-templates/_internal/InitiativeTemplateBusinessRules";
12+
import { TemplatePermissionPolicies } from "../templates/_internal/TemplateBusinessRules";
13+
1214
// Examples of possible Permission Policies
1315
// const DiscussionPermissionPolicies: IPermissionPolicy[] = [
1416
// {
@@ -82,6 +84,7 @@ export const HubPermissionsPolicies: IPermissionPolicy[] = [
8284
...ContentPermissionPolicies,
8385
...GroupPermissionPolicies,
8486
...PagePermissionPolicies,
87+
...TemplatePermissionPolicies,
8588
...PlatformPermissionPolicies,
8689
...TempPermissionPolicies,
8790
...InitiativeTemplatePermissionPolicies,

packages/common/src/permissions/types/Permission.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { GroupPermissions } from "../../groups/_internal/GroupBusinessRules";
77
import { PagePermissions } from "../../pages/_internal/PageBusinessRules";
88
import { PlatformPermissions } from "../PlatformPermissionPolicies";
99
import { InitiativeTemplatePermissions } from "../../initiative-templates/_internal/InitiativeTemplateBusinessRules";
10+
import { TemplatePermissions } from "../../templates/_internal/TemplateBusinessRules";
1011
/**
1112
* Defines the values for Permissions
1213
* It's critical that the arrays defined in the modules use `as const`
@@ -27,6 +28,7 @@ const validPermissions = [
2728
...TempPermissions,
2829
...DiscussionPermissions,
2930
...InitiativeTemplatePermissions,
31+
...TemplatePermissions,
3032
] as const;
3133

3234
/**
@@ -42,7 +44,8 @@ export type Permission =
4244
| (typeof PlatformPermissions)[number]
4345
| (typeof TempPermissions)[number]
4446
| (typeof DiscussionPermissions)[number]
45-
| (typeof InitiativeTemplatePermissions)[number];
47+
| (typeof InitiativeTemplatePermissions)[number]
48+
| (typeof TemplatePermissions)[number];
4649

4750
/**
4851
* Validate a Permission

packages/common/src/search/_internal/portalSearchItems.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { serializeQueryForPortal } from "../serializeQueryForPortal";
55
import { enrichPageSearchResult } from "../../pages/HubPages";
66
import { enrichProjectSearchResult } from "../../projects";
77
import { enrichSiteSearchResult } from "../../sites";
8+
import { enrichTemplateSearchResult } from "../../templates/fetch";
89
import { IHubRequestOptions } from "../../types";
910

1011
import {
@@ -225,7 +226,9 @@ export async function itemToSearchResult(
225226
case "Hub Project":
226227
fn = enrichProjectSearchResult;
227228
break;
228-
229+
case "Solution":
230+
fn = enrichTemplateSearchResult;
231+
break;
229232
// handle old hub sites
230233
case "Web Mapping Application":
231234
if (item.typeKeywords.includes("hubSite")) {

0 commit comments

Comments
 (0)