Skip to content

Commit

Permalink
Migrate saved object of type url to kibana platform (elastic#64043)
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal committed Apr 27, 2020
1 parent aa01c28 commit 584b581
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 32 deletions.
10 changes: 0 additions & 10 deletions src/legacy/core_plugins/kibana/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 0 additions & 22 deletions src/legacy/core_plugins/kibana/mappings.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/share/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
19 changes: 19 additions & 0 deletions src/plugins/share/server/saved_objects/index.ts
Original file line number Diff line number Diff line change
@@ -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';
54 changes: 54 additions & 0 deletions src/plugins/share/server/saved_objects/url.ts
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 { 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',
},
},
},
},
},
};

0 comments on commit 584b581

Please sign in to comment.