Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should unregister capability and its implicit intent, but not the implicit intents of wildcard (*) capabilities', fakeAsync(inject([ManifestRegistry], (manifestRegistry: ManifestRegistry) => {
const type = PlatformCapabilityTypes.View;
const qualifier1: Qualifier = {entity: 'entity', id: 1};
const qualifier2: Qualifier = {entity: '*', id: '*'}; // implicit intent of this capability should not be unregistered
manifestRegistry.registerCapability('app-1', [{type, qualifier: qualifier1, private: false}]);
manifestRegistry.registerCapability('app-1', [{type, qualifier: qualifier2, private: false}]);
manifestRegistry.unregisterCapability('app-1', type, qualifier1);
expect(manifestRegistry.getCapabilitiesByApplication('app-1').length).toBe(1);
expect(manifestRegistry.getCapabilitiesByType(type).length).toBe(1);
expect(manifestRegistry.getIntentsByApplication('app-1').length).toBe(1);
expect(manifestRegistry.getIntentsByApplication('app-1')[0].qualifier).toEqual(qualifier2);
})));
private onIntent(envelope: MessageEnvelope): void {
this._manifestRegistry.getCapabilities(PlatformCapabilityTypes.View, envelope.message.qualifier)
.filter(capability => this._manifestRegistry.isVisibleForApplication(capability, envelope.sender))
.forEach((viewCapability: ViewCapability) => {
const intentMessage: ViewIntentMessage = envelope.message;
const view = envelope._injector.get(WorkbenchView as Type, null); // TODO [Angular 9]: remove type cast for abstract symbols once 'angular/issues/29905' and 'angular/issues/23611' are fixed
const matrixParamObject = Url.writeMatrixParamObject({
matrixParams: Url.substituteParamVariables({...viewCapability.properties.matrixParams, ...intentMessage.payload.matrixParams}, envelope.message.qualifier),
queryParams: Url.substituteParamVariables({...viewCapability.properties.queryParams, ...intentMessage.payload.queryParams}, envelope.message.qualifier),
});
const extras: WbNavigationExtras = {
activateIfPresent: intentMessage.payload.activateIfPresent,
closeIfPresent: intentMessage.payload.closeIfPresent,
selfViewRef: view && view.viewRef,
blankViewPartRef: view && this._workbench.resolveViewPart(view.viewRef),
blankInsertionIndex: intentMessage.payload.blankInsertionIndex,
public onClick(event: Event): void {
event.preventDefault(); // prevent UA to follow 'href'
const viewIntentMessage: ViewIntentMessage = {
type: PlatformCapabilityTypes.View,
qualifier: this.action.properties.qualifier,
payload: {
queryParams: this.action.properties.queryParams,
matrixParams: this.action.properties.matrixParams,
activateIfPresent: this.action.properties.activateIfPresent,
closeIfPresent: this.action.properties.closeIfPresent,
},
};
this._messageBus.publishMessageIfQualified({channel: 'intent', message: viewIntentMessage}, this.action.metadata.symbolicAppName, {injector: this._injector});
}
}
public open(popup: Popup, qualifier: Qualifier): Promise {
const {top, right, bottom, left, width, height} = popup.anchor.getBoundingClientRect();
const popupIntentMessage: PopupIntentMessage = {
type: PlatformCapabilityTypes.Popup,
qualifier: qualifier,
payload: {
queryParams: popup.queryParams,
matrixParams: popup.matrixParams,
anchor: {top, right, bottom, left, width, height},
position: popup.position,
closeStrategy: popup.closeStrategy,
},
};
return Platform.getService(MessageBus).requestReply({channel: 'intent', message: popupIntentMessage})
.then(replyEnvelope => replyEnvelope && replyEnvelope.message); // replyEnvelope is 'undefined' on shutdown
}
public onClick(event: Event): void {
event.preventDefault(); // prevent UA to follow 'href'
const closeStrategy = this.action.properties.closeStrategy;
const popupIntentMessage: PopupIntentMessage = {
type: PlatformCapabilityTypes.Popup,
qualifier: this.action.properties.qualifier,
payload: {
queryParams: this.action.properties.queryParams,
matrixParams: this.action.properties.matrixParams,
anchor: (event.target as Element).getBoundingClientRect(),
position: 'south',
closeStrategy: {
onFocusLost: closeStrategy && closeStrategy.onFocusLost,
onEscape: closeStrategy && closeStrategy.onEscape,
onGridLayoutChange: closeStrategy && closeStrategy.onGridLayoutChange,
},
},
};
this._messageBus.requestReply({channel: 'intent', message: popupIntentMessage}, this.action.metadata.symbolicAppName, {injector: this._injector}).then(noop);
}
public getProperties(): Promise {
return Platform.getService(MessageBus).requestReply({
channel: 'host',
message: {type: ActivityHostMessageTypes.PropertiesRead} as HostMessage,
}).then(envelope => envelope && envelope.message as ActivityProperties || {}); // envelope is 'undefined' on shutdown
}
// provide fallback for the former 'query' property of manifest commands
const command = envelope.message.payload.command || envelope.message.payload.query;
switch (command) {
case ManifestCommands.FindManifests: {
this.queryManifests(envelope as MessageEnvelope);
break;
}
case ManifestCommands.FindManifest: {
this.queryManifest(envelope as MessageEnvelope);
break;
}
case ManifestCommands.FindCapabilityProviders: {
this.queryCapabilityProviders(envelope as MessageEnvelope);
break;
}
case ManifestCommands.FindCapabilityConsumers: {
this.queryCapabilityConsumers(envelope as MessageEnvelope);
break;
}
case ManifestCommands.FindCapability: {
this.queryCapability(envelope as MessageEnvelope);
break;
}
case ManifestCommands.FindCapabilities: {
this.queryCapabilities(envelope as MessageEnvelope);
break;
}
case ManifestCommands.RegisterCapability: {
this.registerCapability(envelope as MessageEnvelope);
break;
}
case ManifestCommands.UnregisterCapability: {
public onIntent(envelope: MessageEnvelope): void {
// provide fallback for the former 'query' property of manifest commands
const command = envelope.message.payload.command || envelope.message.payload.query;
switch (command) {
case ManifestCommands.FindManifests: {
this.queryManifests(envelope as MessageEnvelope);
break;
}
case ManifestCommands.FindManifest: {
this.queryManifest(envelope as MessageEnvelope);
break;
}
case ManifestCommands.FindCapabilityProviders: {
this.queryCapabilityProviders(envelope as MessageEnvelope);
break;
}
case ManifestCommands.FindCapabilityConsumers: {
this.queryCapabilityConsumers(envelope as MessageEnvelope);
break;
}
case ManifestCommands.FindCapability: {
this.queryCapability(envelope as MessageEnvelope);
break;
}
case ManifestCommands.FindCapabilities: {
this.queryCapabilities(envelope as MessageEnvelope);
break;
}
case ManifestCommands.RegisterCapability: {
public onIntent(envelope: MessageEnvelope): void {
// provide fallback for the former 'query' property of manifest commands
const command = envelope.message.payload.command || envelope.message.payload.query;
switch (command) {
case ManifestCommands.FindManifests: {
this.queryManifests(envelope as MessageEnvelope);
break;
}
case ManifestCommands.FindManifest: {
this.queryManifest(envelope as MessageEnvelope);
break;
}
case ManifestCommands.FindCapabilityProviders: {
this.queryCapabilityProviders(envelope as MessageEnvelope);
break;
}
case ManifestCommands.FindCapabilityConsumers: {
this.queryCapabilityConsumers(envelope as MessageEnvelope);
break;
}
case ManifestCommands.FindCapability: {
this.queryCapability(envelope as MessageEnvelope);
break;
}
case ManifestCommands.FindCapabilities: {
public onIntent(envelope: MessageEnvelope): void {
// provide fallback for the former 'query' property of manifest commands
const command = envelope.message.payload.command || envelope.message.payload.query;
switch (command) {
case ManifestCommands.FindManifests: {
this.queryManifests(envelope as MessageEnvelope);
break;
}
case ManifestCommands.FindManifest: {
this.queryManifest(envelope as MessageEnvelope);
break;
}
case ManifestCommands.FindCapabilityProviders: {
this.queryCapabilityProviders(envelope as MessageEnvelope);
break;
}
case ManifestCommands.FindCapabilityConsumers: {
this.queryCapabilityConsumers(envelope as MessageEnvelope);
break;
}
case ManifestCommands.FindCapability: {