From cb385e5315f0583d0337afe3e30664314581c1ee Mon Sep 17 00:00:00 2001 From: Jordan Sanz Date: Tue, 3 Oct 2023 13:55:58 -0400 Subject: [PATCH] feat(): initiative template workspace (#1246) * feat(): initial initiative template entity scaffolding * feat(): more scaffolding with crud and editor functionality * feat(): add schema and uiSchema logic for initiative templates * fix(): export correctly * test(): add tests around entity editor and fetch/update * test(): add testing * feat(): add more scaffolding and the assoc testing * fix(): correct types on fromEditor * fix(): fix type error on create * fix(): update tests with async * test(): fix entityEditorSchemas test * test(): continue updating tests * test(): update imports to get spies working * test(): add catalog to default * test(): fix branch coverage * test(): additional testing * test(): additional testing * feat(): business logic * feat(): add initiative template permissions to hub permissions * fix(): typo * feat(): add ui schema for initiative template edit * fix(): pr feedback * feat(): rest of pr feedback * feat(): gate initiative template to alpha * test(): update uischema test * feat(): add dashboard pane * feat(): remove alpha from initiativetemplate business rules * feat(): update permissions * feat(): add format url * feat(): update edit uiSchema * feat(): reimplement alpha gating * test(): update uischema test * feat(): utilize compute links * fix(): url formatting * test(): update uischema test --- .../InitiativeTemplateBusinessRules.ts | 11 ++++ .../_internal/InitiativeTemplateSchema.ts | 6 +++ .../InitiativeTemplateUiSchemaEdit.ts | 53 +++++++++++++++++++ .../InitiativeTemplateUiSchemaEdit.test.ts | 53 +++++++++++++++++++ .../projects/_internal/computeProps.test.ts | 1 + 5 files changed, 124 insertions(+) diff --git a/packages/common/src/initiative-templates/_internal/InitiativeTemplateBusinessRules.ts b/packages/common/src/initiative-templates/_internal/InitiativeTemplateBusinessRules.ts index 5d81d35041d..10138a88354 100644 --- a/packages/common/src/initiative-templates/_internal/InitiativeTemplateBusinessRules.ts +++ b/packages/common/src/initiative-templates/_internal/InitiativeTemplateBusinessRules.ts @@ -19,6 +19,7 @@ export const InitiativeTemplatePermissions = [ "hub:initiativeTemplate:edit", "hub:initiativeTemplate:view", "hub:initiativeTemplate:workspace:overview", + "hub:initiativeTemplate:workspace:dashboard", "hub:initiativeTemplate:workspace:details", "hub:initiativeTemplate:workspace:collaborators", "hub:initiativeTemplate:workspace:settings", @@ -51,10 +52,20 @@ export const InitiativeTemplatePermissionPolicies: IPermissionPolicy[] = [ authenticated: true, entityEdit: true, }, + { + permission: "hub:initiativeTemplate:delete", + dependencies: ["hub:initiativeTemplate"], + authenticated: true, + entityOwner: true, + }, { permission: "hub:initiativeTemplate:workspace:overview", dependencies: ["hub:initiativeTemplate:view"], }, + { + permission: "hub:initiativeTemplate:workspace:dashboard", + dependencies: ["hub:initiativeTemplate:edit"], + }, { permission: "hub:initiativeTemplate:workspace:details", dependencies: ["hub:initiativeTemplate:edit"], diff --git a/packages/common/src/initiative-templates/_internal/InitiativeTemplateSchema.ts b/packages/common/src/initiative-templates/_internal/InitiativeTemplateSchema.ts index 0805f93869f..d39cd258a11 100644 --- a/packages/common/src/initiative-templates/_internal/InitiativeTemplateSchema.ts +++ b/packages/common/src/initiative-templates/_internal/InitiativeTemplateSchema.ts @@ -12,5 +12,11 @@ export const InitiativeTemplateSchema: IConfigurationSchema = { ...HubItemEntitySchema, properties: { ...HubItemEntitySchema.properties, + previewUrl: { + type: "string", + if: { minLength: 1 }, + then: { format: "uri" }, + }, }, + // we have to do this to allow the format: url to pass through } as IConfigurationSchema; diff --git a/packages/common/src/initiative-templates/_internal/InitiativeTemplateUiSchemaEdit.ts b/packages/common/src/initiative-templates/_internal/InitiativeTemplateUiSchemaEdit.ts index 09335421bdd..4c8564526d0 100644 --- a/packages/common/src/initiative-templates/_internal/InitiativeTemplateUiSchemaEdit.ts +++ b/packages/common/src/initiative-templates/_internal/InitiativeTemplateUiSchemaEdit.ts @@ -36,6 +36,59 @@ export const buildUiSchema = async ( ], }, }, + { + type: "Control", + scope: "/properties/previewUrl", + labelKey: `${i18nScope}.fields.previewUrl.label`, + options: { + helperText: { + labelKey: `${i18nScope}.fields.previewUrl.helperText`, + }, + messages: [ + { + type: "ERROR", + keyword: "if", + hidden: true, + }, + ], + }, + }, + { + type: "Control", + scope: "/properties/summary", + labelKey: `${i18nScope}.fields.summary.label`, + options: { + control: "hub-field-input-input", + type: "textarea", + }, + }, + { + type: "Control", + scope: "/properties/description", + labelKey: `${i18nScope}.fields.description.label`, + options: { + control: "hub-field-input-input", + type: "textarea", + }, + }, + { + type: "Control", + scope: "/properties/_thumbnail", + labelKey: `${i18nScope}.fields._thumbnail.label`, + options: { + control: "hub-field-input-image-picker", + imgSrc: entity.thumbnailUrl, + maxWidth: 727, + maxHeight: 484, + aspectRatio: 1.5, + helperText: { + labelKey: `${i18nScope}.fields._thumbnail.helperText`, + }, + sizeDescription: { + labelKey: `${i18nScope}.fields._thumbnail.sizeDescription`, + }, + }, + }, ], }; }; diff --git a/packages/common/test/initiative-templates/_internal/InitiativeTemplateUiSchemaEdit.test.ts b/packages/common/test/initiative-templates/_internal/InitiativeTemplateUiSchemaEdit.test.ts index 64e9876f17e..53eceb10799 100644 --- a/packages/common/test/initiative-templates/_internal/InitiativeTemplateUiSchemaEdit.test.ts +++ b/packages/common/test/initiative-templates/_internal/InitiativeTemplateUiSchemaEdit.test.ts @@ -27,6 +27,59 @@ describe("buildUiSchema: initiative template edit", () => { ], }, }, + { + type: "Control", + scope: "/properties/previewUrl", + labelKey: `some.scope.fields.previewUrl.label`, + options: { + helperText: { + labelKey: "some.scope.fields.previewUrl.helperText", + }, + messages: [ + { + type: "ERROR", + keyword: "if", + hidden: true, + }, + ], + }, + }, + { + type: "Control", + scope: "/properties/summary", + labelKey: `some.scope.fields.summary.label`, + options: { + control: "hub-field-input-input", + type: "textarea", + }, + }, + { + type: "Control", + scope: "/properties/description", + labelKey: `some.scope.fields.description.label`, + options: { + control: "hub-field-input-input", + type: "textarea", + }, + }, + { + type: "Control", + scope: "/properties/_thumbnail", + labelKey: `some.scope.fields._thumbnail.label`, + options: { + control: "hub-field-input-image-picker", + imgSrc: "https://some-thumbnail-url.com", + maxWidth: 727, + maxHeight: 484, + aspectRatio: 1.5, + helperText: { + labelKey: "some.scope.fields._thumbnail.helperText", + }, + sizeDescription: { + labelKey: "some.scope.fields._thumbnail.sizeDescription", + }, + }, + }, ], }); }); diff --git a/packages/common/test/projects/_internal/computeProps.test.ts b/packages/common/test/projects/_internal/computeProps.test.ts index f364a6bb10f..fe38cb9f645 100644 --- a/packages/common/test/projects/_internal/computeProps.test.ts +++ b/packages/common/test/projects/_internal/computeProps.test.ts @@ -98,6 +98,7 @@ describe("projects: computeProps:", () => { expect(chk.features?.settings).toBeFalsy(); expect(spy.calls.argsFor(0)[0]).toEqual({ details: true }); }); + it("generates a links hash", () => { const computeLinksSpy = spyOn( computeLinksModule,