forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate ui/registry/feature_catalogue to New Platform plugin (elastic…
- Loading branch information
Showing
14 changed files
with
442 additions
and
10 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Feature catalogue plugin | ||
|
||
Replaces the legacy `ui/registry/feature_catalogue` module for registering "features" that should be showed in the home | ||
page's feature catalogue. This should not be confused with the "feature" plugin for registering features used to derive | ||
UI capabilities for feature controls. | ||
|
||
## Example registration | ||
|
||
```ts | ||
// For legacy plugins | ||
import { npSetup } from 'ui/new_platform'; | ||
npSetup.plugins.feature_catalogue.register(/* same details here */); | ||
|
||
// For new plugins: first add 'feature_catalogue` to the list of `optionalPlugins` | ||
// in your kibana.json file. Then access the plugin directly in `setup`: | ||
|
||
class MyPlugin { | ||
setup(core, plugins) { | ||
if (plugins.feature_catalogue) { | ||
plugins.feature_catalogue.register(/* same details here. */); | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Note that the old module supported providing a Angular DI function to receive Angular dependencies. This is no longer supported as we migrate away from Angular and will be removed in 8.0. |
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,6 @@ | ||
{ | ||
"id": "feature_catalogue", | ||
"version": "kibana", | ||
"server": false, | ||
"ui": true | ||
} |
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,24 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
export { FeatureCatalogueSetup, FeatureCatalogueStart } from './plugin'; | ||
export { FeatureCatalogueEntry, FeatureCatalogueCategory } from './services'; | ||
import { FeatureCataloguePlugin } from './plugin'; | ||
|
||
export const plugin = () => new FeatureCataloguePlugin(); |
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,25 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { featureCatalogueRegistryMock } from './services/feature_catalogue_registry.mock'; | ||
|
||
export const registryMock = featureCatalogueRegistryMock.create(); | ||
jest.doMock('./services', () => ({ | ||
FeatureCatalogueRegistry: jest.fn(() => registryMock), | ||
})); |
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,49 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { registryMock } from './plugin.test.mocks'; | ||
import { FeatureCataloguePlugin } from './plugin'; | ||
|
||
describe('FeatureCataloguePlugin', () => { | ||
beforeEach(() => { | ||
registryMock.setup.mockClear(); | ||
registryMock.start.mockClear(); | ||
}); | ||
|
||
describe('setup', () => { | ||
test('wires up and returns registry', async () => { | ||
const setup = await new FeatureCataloguePlugin().setup(); | ||
expect(registryMock.setup).toHaveBeenCalledWith(); | ||
expect(setup.register).toBeDefined(); | ||
}); | ||
}); | ||
|
||
describe('start', () => { | ||
test('wires up and returns registry', async () => { | ||
const service = new FeatureCataloguePlugin(); | ||
await service.setup(); | ||
const core = { application: { capabilities: { catalogue: {} } } } as any; | ||
const start = await service.start(core); | ||
expect(registryMock.start).toHaveBeenCalledWith({ | ||
capabilities: core.application.capabilities, | ||
}); | ||
expect(start.get).toBeDefined(); | ||
}); | ||
}); | ||
}); |
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,50 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { CoreStart, Plugin } from 'src/core/public'; | ||
import { | ||
FeatureCatalogueRegistry, | ||
FeatureCatalogueRegistrySetup, | ||
FeatureCatalogueRegistryStart, | ||
} from './services'; | ||
|
||
export class FeatureCataloguePlugin | ||
implements Plugin<FeatureCatalogueSetup, FeatureCatalogueStart> { | ||
private readonly featuresCatalogueRegistry = new FeatureCatalogueRegistry(); | ||
|
||
public async setup() { | ||
return { | ||
...this.featuresCatalogueRegistry.setup(), | ||
}; | ||
} | ||
|
||
public async start(core: CoreStart) { | ||
return { | ||
...this.featuresCatalogueRegistry.start({ | ||
capabilities: core.application.capabilities, | ||
}), | ||
}; | ||
} | ||
} | ||
|
||
/** @public */ | ||
export type FeatureCatalogueSetup = FeatureCatalogueRegistrySetup; | ||
|
||
/** @public */ | ||
export type FeatureCatalogueStart = FeatureCatalogueRegistryStart; |
54 changes: 54 additions & 0 deletions
54
src/plugins/feature_catalogue/public/services/feature_catalogue_registry.mock.ts
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,54 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { | ||
FeatureCatalogueRegistrySetup, | ||
FeatureCatalogueRegistryStart, | ||
FeatureCatalogueRegistry, | ||
} from './feature_catalogue_registry'; | ||
|
||
const createSetupMock = (): jest.Mocked<FeatureCatalogueRegistrySetup> => { | ||
const setup = { | ||
register: jest.fn(), | ||
}; | ||
return setup; | ||
}; | ||
|
||
const createStartMock = (): jest.Mocked<FeatureCatalogueRegistryStart> => { | ||
const start = { | ||
get: jest.fn(), | ||
}; | ||
return start; | ||
}; | ||
|
||
const createMock = (): jest.Mocked<PublicMethodsOf<FeatureCatalogueRegistry>> => { | ||
const service = { | ||
setup: jest.fn(), | ||
start: jest.fn(), | ||
}; | ||
service.setup.mockImplementation(createSetupMock); | ||
service.start.mockImplementation(createStartMock); | ||
return service; | ||
}; | ||
|
||
export const featureCatalogueRegistryMock = { | ||
createSetup: createSetupMock, | ||
createStart: createStartMock, | ||
create: createMock, | ||
}; |
Oops, something went wrong.