Skip to content

Commit

Permalink
[ML] Fixing optional plugin dependency types (elastic#64450)
Browse files Browse the repository at this point in the history
Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
jgowdyelastic and elasticmachine committed May 15, 2020
1 parent 7827fa5 commit 44d4ddc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { LicenseManagementUIPluginSetup } from '../../../../../license_managemen

interface StartPlugins {
data: DataPublicPluginStart;
security: SecurityPluginSetup;
security?: SecurityPluginSetup;
licenseManagement?: LicenseManagementUIPluginSetup;
}
export type StartServices = CoreStart & StartPlugins;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ export const FilebeatConfigFlyout: FC<Props> = ({
} = useMlKibana();

useEffect(() => {
security.authc.getCurrentUser().then(user => {
setUsername(user.username === undefined ? null : user.username);
});
if (security !== undefined) {
security.authc.getCurrentUser().then(user => {
setUsername(user.username === undefined ? null : user.username);
});
}
}, []);

useEffect(() => {
Expand Down
7 changes: 5 additions & 2 deletions x-pack/plugins/ml/public/application/management/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ export function initManagementSection(
) {
const licensing = pluginsSetup.licensing.license$.pipe(take(1));
licensing.subscribe(license => {
if (license.check(PLUGIN_ID, MINIMUM_FULL_LICENSE).state === 'valid') {
const management = pluginsSetup.management;
const management = pluginsSetup.management;
if (
management !== undefined &&
license.check(PLUGIN_ID, MINIMUM_FULL_LICENSE).state === 'valid'
) {
const mlSection = management.sections.register({
id: PLUGIN_ID,
title: i18n.translate('xpack.ml.management.mlTitle', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface DependencyCache {
savedObjectsClient: SavedObjectsClientContract | null;
application: ApplicationStart | null;
http: HttpStart | null;
security: SecurityPluginSetup | null;
security: SecurityPluginSetup | undefined | null;
i18n: I18nStart | null;
urlGenerators: SharePluginStart['urlGenerators'] | null;
}
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/ml/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ export interface MlStartDependencies {
share: SharePluginStart;
}
export interface MlSetupDependencies {
security: SecurityPluginSetup;
security?: SecurityPluginSetup;
licensing: LicensingPluginSetup;
management: ManagementSetup;
management?: ManagementSetup;
usageCollection: UsageCollectionSetup;
licenseManagement?: LicenseManagementUIPluginSetup;
home: HomePublicPluginSetup;
Expand Down

0 comments on commit 44d4ddc

Please sign in to comment.