-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enables the feature catalogue registry to be controlled via uiCapabil… (
#27945) * Enables the feature catalogue registry to be controlled via uiCapabilities * update snapshot * xpack_main populates uiCapabilities with the full list of catalogue entries * builds application privileges using catalogue actions * prevent 'catalogue' from being registered as a feature id * fix mocha tests
- Loading branch information
Showing
31 changed files
with
439 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
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,102 @@ | ||
/* | ||
* 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. | ||
*/ | ||
jest.mock('ui/chrome', () => ({ | ||
getInjected: key => { | ||
if (key === 'uiCapabilities') { | ||
return { | ||
navLinks: {}, | ||
management: {}, | ||
catalogue: { | ||
item1: true, | ||
item2: false, | ||
item3: true, | ||
}, | ||
}; | ||
} | ||
throw new Error(`Unexpected call to chrome.getInjected with key ${key}`); | ||
}, | ||
})); | ||
import { FeatureCatalogueCategory, FeatureCatalogueRegistryProvider } from './feature_catalogue'; | ||
|
||
describe('FeatureCatalogueRegistryProvider', () => { | ||
|
||
beforeAll(() => { | ||
FeatureCatalogueRegistryProvider.register(() => { | ||
return { | ||
id: 'item1', | ||
title: 'foo', | ||
description: 'this is foo', | ||
icon: 'savedObjectsApp', | ||
path: '/app/kibana#/management/kibana/objects', | ||
showOnHomePage: true, | ||
category: FeatureCatalogueCategory.ADMIN, | ||
}; | ||
}); | ||
|
||
FeatureCatalogueRegistryProvider.register(() => { | ||
return { | ||
id: 'item2', | ||
title: 'bar', | ||
description: 'this is bar', | ||
icon: 'savedObjectsApp', | ||
path: '/app/kibana#/management/kibana/objects', | ||
showOnHomePage: true, | ||
category: FeatureCatalogueCategory.ADMIN, | ||
}; | ||
}); | ||
|
||
// intentionally not listed in uiCapabilities.catalogue above | ||
FeatureCatalogueRegistryProvider.register(() => { | ||
return { | ||
id: 'item4', | ||
title: 'secret', | ||
description: 'this is a secret', | ||
icon: 'savedObjectsApp', | ||
path: '/app/kibana#/management/kibana/objects', | ||
showOnHomePage: true, | ||
category: FeatureCatalogueCategory.ADMIN, | ||
}; | ||
}); | ||
}); | ||
|
||
it('should not return items hidden by uiCapabilities', () => { | ||
const mockPrivate = entityFn => entityFn(); | ||
const mockInjector = () => null; | ||
|
||
// eslint-disable-next-line new-cap | ||
const foo = FeatureCatalogueRegistryProvider(mockPrivate, mockInjector).inTitleOrder; | ||
expect(foo).toEqual([{ | ||
id: 'item1', | ||
title: 'foo', | ||
description: 'this is foo', | ||
icon: 'savedObjectsApp', | ||
path: '/app/kibana#/management/kibana/objects', | ||
showOnHomePage: true, | ||
category: FeatureCatalogueCategory.ADMIN, | ||
}, { | ||
id: 'item4', | ||
title: 'secret', | ||
description: 'this is a secret', | ||
icon: 'savedObjectsApp', | ||
path: '/app/kibana#/management/kibana/objects', | ||
showOnHomePage: true, | ||
category: FeatureCatalogueCategory.ADMIN, | ||
}]); | ||
}); | ||
}); |
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
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
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
Oops, something went wrong.