Learn how to declare requirements for your extensions using the Extension Conditions.
Extension Conditions declare requirements that should be permitted for the extension to be available. Many, but not all, Extension Types support Conditions.
You can make your own Conditions by creating a class that implements the UmbExtensionCondition interface.
import { UmbConditionConfigBase, UmbConditionControllerArguments, UmbExtensionCondition} from'@umbraco-cms/backoffice/extension-api';import { UmbConditionBase } from'@umbraco-cms/backoffice/extension-registry';import { UmbControllerHost } from'@umbraco-cms/backoffice/controller-api';exporttypeMyExtensionConditionConfig=UmbConditionConfigBase<'My.Condition.CustomName'> & { match?:string;};exportclassMyExtensionConditionextendsUmbConditionBase<MyExtensionConditionConfig> implementsUmbExtensionCondition {constructor(host:UmbControllerHost, args:UmbConditionControllerArguments<MyExtensionConditionConfig>) {super(host, args);// enable extension after 10 secondssetTimeout(() => {this.permitted =true;args.onChange(); },10000); }}// Declare the Condition Configuration Type in the global UmbExtensionConditionConfigMap interface:declare global {interfaceUmbExtensionConditionConfigMap { MyExtensionConditionConfig:MyExtensionConditionConfig; }}
The global declaration on the last five lines makes your Condition appear valid for manifests using the type UmbExtensionManifest. Also, the Condition Config Type alias should match the alias given when registering the condition below.
The Condition then needs to be registered in the Extension Registry:
As shown in the code above, the configuration property match isn't used for our condition. We can do this by replacing the timeout with some other check: