Add Snapshot and Restore locator. (#109886)

This commit is contained in:
CJ Cenizal 2021-08-24 17:41:32 -07:00 committed by GitHub
parent 88640a7a10
commit b300a1d7d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 58 additions and 4 deletions

View file

@ -7,7 +7,7 @@
"name": "Stack Management",
"githubTeam": "kibana-stack-management"
},
"requiredPlugins": ["licensing", "management", "features"],
"requiredPlugins": ["licensing", "management", "features", "share"],
"optionalPlugins": ["usageCollection", "security", "cloud", "home"],
"configPath": ["xpack", "snapshot_restore"],
"requiredBundles": ["esUiShared", "kibanaReact", "home"]

View file

@ -0,0 +1,45 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type { SerializableRecord } from '@kbn/utility-types';
import { ManagementAppLocator } from 'src/plugins/management/common';
import { LocatorDefinition } from '../../../../src/plugins/share/public/';
import { linkToSnapshots } from './application/services/navigation';
import { PLUGIN } from '../common/constants';
export const SNAPSHOT_RESTORE_LOCATOR_ID = 'SNAPSHOT_RESTORE_LOCATOR';
export interface SnapshotRestoreLocatorParams extends SerializableRecord {
page: 'snapshots';
}
export interface SnapshotRestoreLocatorDefinitionDependencies {
managementAppLocator: ManagementAppLocator;
}
export class SnapshotRestoreLocatorDefinition
implements LocatorDefinition<SnapshotRestoreLocatorParams> {
constructor(protected readonly deps: SnapshotRestoreLocatorDefinitionDependencies) {}
public readonly id = SNAPSHOT_RESTORE_LOCATOR_ID;
public readonly getLocation = async (params: SnapshotRestoreLocatorParams) => {
const location = await this.deps.managementAppLocator.getLocation({
sectionId: 'data',
appId: PLUGIN.id,
});
switch (params.page) {
case 'snapshots': {
return {
...location,
path: location.path + linkToSnapshots(),
};
}
}
};
}

View file

@ -7,13 +7,14 @@
import { i18n } from '@kbn/i18n';
import { CoreSetup, PluginInitializerContext } from 'src/core/public';
import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/public';
import { ManagementSetup } from '../../../../src/plugins/management/public';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/public';
import { ManagementSetup } from 'src/plugins/management/public';
import { SharePluginSetup } from 'src/plugins/share/public';
import {
FeatureCatalogueCategory,
HomePublicPluginSetup,
} from '../../../../src/plugins/home/public';
import { PLUGIN } from '../common/constants';
import { ClientConfigType } from './types';
@ -22,10 +23,12 @@ import { httpService, setUiMetricService } from './application/services/http';
import { textService } from './application/services/text';
import { UiMetricService } from './application/services';
import { UIM_APP_NAME } from './application/constants';
import { SnapshotRestoreLocatorDefinition } from './locator';
interface PluginsDependencies {
usageCollection: UsageCollectionSetup;
management: ManagementSetup;
share: SharePluginSetup;
home?: HomePublicPluginSetup;
}
@ -79,6 +82,12 @@ export class SnapshotRestoreUIPlugin {
order: 630,
});
}
plugins.share.url.locators.create(
new SnapshotRestoreLocatorDefinition({
managementAppLocator: plugins.management.locator,
})
);
}
public start() {}