remove global context

This commit is contained in:
Jacob Overgaard
2024-02-29 09:47:18 +01:00
parent 7643886336
commit ce6203eba9
4 changed files with 0 additions and 53 deletions

View File

@@ -1,40 +0,0 @@
import { UmbWebhookCollectionRepository } from '../collection/index.js';
import type { UmbWebhookDetailModel } from '../types.js';
import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import { UmbBaseController } from '@umbraco-cms/backoffice/class-api';
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
import type { UmbApi } from '@umbraco-cms/backoffice/extension-api';
export class UmbAppWebhookContext extends UmbBaseController implements UmbApi {
#webhookCollectionRepository: UmbWebhookCollectionRepository;
#webhooks: Array<UmbWebhookDetailModel> = [];
#appWebhook = new UmbObjectState<UmbWebhookDetailModel | undefined>(undefined);
appWebhook = this.#appWebhook.asObservable();
constructor(host: UmbControllerHost) {
super(host);
this.provideContext(UMB_APP_WEBHOOK_CONTEXT, this);
this.#webhookCollectionRepository = new UmbWebhookCollectionRepository(this);
this.#observeWebhooks();
}
setLanguage(unique: string) {
const webhook = this.#webhooks.find((x) => x.unique === unique);
this.#appWebhook.update(webhook);
}
async #observeWebhooks() {
const { data } = await this.#webhookCollectionRepository.requestCollection({ skip: 0, take: 100 });
// TODO: make this observable / update when webhooks are added/removed/updated
if (data) {
this.#webhooks = data.items;
}
}
}
// Default export to enable this as a globalContext extension js:
export default UmbAppWebhookContext;
export const UMB_APP_WEBHOOK_CONTEXT = new UmbContextToken<UmbAppWebhookContext>('UmbAppWebhookContext');

View File

@@ -1 +0,0 @@
export * from './app-webhook.context.js';

View File

@@ -1,10 +0,0 @@
import type { ManifestGlobalContext } from '@umbraco-cms/backoffice/extension-registry';
export const manifests: Array<ManifestGlobalContext> = [
{
type: 'globalContext',
alias: 'Umb.GlobalContext.AppWebhook',
name: 'App Webhook Context',
js: () => import('./app-webhook.context.js'),
},
];

View File

@@ -3,7 +3,6 @@ import { manifests as treeManifests } from './menu-item/manifests.js';
//import { manifests as entityActions } from './entity-actions/manifests.js';
import { manifests as workspaceManifests } from './workspace/manifests.js';
import { manifests as collectionManifests } from './collection/manifests.js';
import { manifests as globalContextManifests } from './global-contexts/manifests.js';
export const manifests = [
...repositoryManifests,
@@ -11,5 +10,4 @@ export const manifests = [
...treeManifests,
...workspaceManifests,
...collectionManifests,
...globalContextManifests,
];