Migrate saved object of type url to kibana platform (#64043)

This commit is contained in:
Matthias Wilhelm 2020-04-27 13:38:03 +02:00 committed by GitHub
parent 5f13ad107f
commit 0b8cd6eb46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 75 additions and 32 deletions

View file

@ -118,16 +118,6 @@ export default function(kibana) {
},
],
savedObjectsManagement: {
url: {
defaultSearchField: 'url',
isImportableAndExportable: true,
getTitle(obj) {
return `/goto/${encodeURIComponent(obj.id)}`;
},
},
},
injectDefaultVars(server, options) {
const mapConfig = server.config().get('map');
const tilemap = mapConfig.tilemap;

View file

@ -1,26 +1,4 @@
{
"url": {
"properties": {
"accessCount": {
"type": "long"
},
"accessDate": {
"type": "date"
},
"createDate": {
"type": "date"
},
"url": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 2048
}
}
}
}
},
"server": {
"properties": {
"uuid": {

View file

@ -19,12 +19,14 @@
import { CoreSetup, Plugin, PluginInitializerContext } from 'kibana/server';
import { createRoutes } from './routes/create_routes';
import { url } from './saved_objects';
export class SharePlugin implements Plugin {
constructor(private readonly initializerContext: PluginInitializerContext) {}
public async setup(core: CoreSetup) {
createRoutes(core, this.initializerContext.logger.get());
core.savedObjects.registerType(url);
}
public start() {

View file

@ -0,0 +1,19 @@
/*
* 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 { url } from './url';

View file

@ -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 { SavedObjectsType } from 'kibana/server';
export const url: SavedObjectsType = {
name: 'url',
namespaceType: 'single',
hidden: false,
management: {
icon: 'link',
defaultSearchField: 'url',
importableAndExportable: true,
getTitle(obj) {
return `/goto/${encodeURIComponent(obj.id)}`;
},
},
mappings: {
properties: {
accessCount: {
type: 'long',
},
accessDate: {
type: 'date',
},
createDate: {
type: 'date',
},
url: {
type: 'text',
fields: {
keyword: {
type: 'keyword',
},
},
},
},
},
};