-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(plugins): Extract registration of extensions to its own file.
- add tests. - move the IDeckPlugin interface - remove IPluginManifest interface
- Loading branch information
1 parent
f227aa8
commit 9c27a93
Showing
5 changed files
with
52 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { registerPluginExtensions } from './deck.plugin'; | ||
import { Registry } from '../registry'; | ||
|
||
describe('deck plugin registerPluginExtensions', () => { | ||
it('should register stages', async () => { | ||
const registerSpy = spyOn(Registry.pipeline, 'registerStage'); | ||
const stage = { key: 'test' }; | ||
registerPluginExtensions({ stages: [stage] }); | ||
expect(registerSpy).toHaveBeenCalledTimes(1); | ||
expect(registerSpy).toHaveBeenCalledWith(stage); | ||
}); | ||
|
||
it('should register preconfigured job stages', async () => { | ||
const registerSpy = spyOn(Registry.pipeline, 'registerPreconfiguredJobStage'); | ||
const stage = { key: 'test' }; | ||
registerPluginExtensions({ preconfiguredJobStages: [stage] }); | ||
expect(registerSpy).toHaveBeenCalledTimes(1); | ||
expect(registerSpy).toHaveBeenCalledWith(stage); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { IStageTypeConfig } from 'core/domain'; | ||
import { Registry } from 'core/registry'; | ||
import { SearchResultType } from 'core/search'; | ||
|
||
export interface IDeckPlugin { | ||
stages?: IStageTypeConfig[]; | ||
preconfiguredJobStages?: IStageTypeConfig[]; | ||
helpContents?: { [helpKey: string]: string }; | ||
searchResultTypes?: SearchResultType[]; | ||
|
||
initialize?(): void; | ||
} | ||
|
||
/** Given a plugin, registers the plugin's extensions */ | ||
export function registerPluginExtensions(plugin: IDeckPlugin) { | ||
// Register the plugin's extensions with deck. | ||
plugin.stages?.forEach(stage => Registry.pipeline.registerStage(stage)); | ||
plugin.preconfiguredJobStages?.forEach(stage => Registry.pipeline.registerPreconfiguredJobStage(stage)); | ||
|
||
// Run code that currently does not have an extension point | ||
plugin.initialize?.(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './deck.plugin'; | ||
export * from './plugin.module'; | ||
export * from './plugin.registry'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters