Skip to content

Commit

Permalink
Feat: condition config types as a generic for extension registry (#2473)
Browse files Browse the repository at this point in the history
get condition config types as a generic for extension registry
  • Loading branch information
nielslyngsoe committed Nov 5, 2024
1 parent 0065fc1 commit a07923c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/libs/extension-api/registry/extension.registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const sortExtensions = (a: ManifestBase, b: ManifestBase): number => (b.weight |

export class UmbExtensionRegistry<
IncomingManifestTypes extends ManifestBase,
IncomingConditionConfigTypes extends UmbConditionConfigBase = UmbConditionConfigBase,
ManifestTypes extends ManifestBase = IncomingManifestTypes | ManifestBase,
> {
readonly MANIFEST_TYPES: ManifestTypes = undefined as never;
Expand Down Expand Up @@ -490,7 +491,7 @@ export class UmbExtensionRegistry<
* @param {string} alias - The alias of the extension to append the condition to.
* @param {UmbConditionConfigBase} newCondition - The condition to append to the extension.
*/
appendCondition(alias: string, newCondition: UmbConditionConfigBase) {
appendCondition(alias: string, newCondition: IncomingConditionConfigTypes) {
this.appendConditions(alias, [newCondition]);
}

Expand All @@ -499,7 +500,7 @@ export class UmbExtensionRegistry<
* @param {string} alias - The alias of the extension to append the condition to
* @param {Array<UmbConditionConfigBase>} newConditions - An array of conditions to be appended to an extension manifest.
*/
appendConditions(alias: string, newConditions: Array<UmbConditionConfigBase>) {
appendConditions(alias: string, newConditions: Array<IncomingConditionConfigTypes>) {
const existingConditionsToBeAdded = this.#additionalConditions.get(alias);
this.#additionalConditions.set(
alias,
Expand Down
7 changes: 5 additions & 2 deletions src/packages/core/extension-registry/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import type { ManifestKind } from '@umbraco-cms/backoffice/extension-api';
import { UmbExtensionRegistry } from '@umbraco-cms/backoffice/extension-api';

export type UmbExtensionManifestKind = ManifestKind<UmbExtensionManifest>;
export type UmbBackofficeExtensionRegistry = UmbExtensionRegistry<UmbExtensionManifest>;
export type UmbBackofficeExtensionRegistry = UmbExtensionRegistry<UmbExtensionManifest, UmbExtensionConditionConfig>;

export const umbExtensionsRegistry = new UmbExtensionRegistry<UmbExtensionManifest>() as UmbBackofficeExtensionRegistry;
export const umbExtensionsRegistry = new UmbExtensionRegistry<
UmbExtensionManifest,
UmbExtensionConditionConfig
>() as UmbBackofficeExtensionRegistry;

/**
* @deprecated Use `UmbExtensionManifestKind` instead.
Expand Down

0 comments on commit a07923c

Please sign in to comment.