Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NP] Move ui/saved_objects to NP #57452

Merged
merged 15 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ import { setup, start } from '../core_plugins/visualizations/public/legacy';
| `import 'ui/query_bar'` | `import { QueryStringInput } from '../data/public'` | Directives are deprecated. |
| `import 'ui/search_bar'` | `import { SearchBar } from '../data/public'` | Directive is deprecated. |
| `import 'ui/kbn_top_nav'` | `import { TopNavMenu } from '../navigation/public'` | Directive is still available in `ui/kbn_top_nav`. |
| `ui/saved_objects/components/saved_object_finder` | `import { SavedObjectFinder } from '../kibana_react/public'` | |
maryia-lapata marked this conversation as resolved.
Show resolved Hide resolved
| `ui/saved_objects/components/saved_object_finder` | `import { SavedObjectFinder } from '../saved_objects/public'` | |
| `core_plugins/interpreter` | `data.expressions` | still in progress |
| `ui/courier` | `data.search` | still in progress |
| `ui/embeddable` | `embeddables` | still in progress |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,43 @@
* under the License.
*/

import sinon from 'sinon';
import expect from '@kbn/expect';
import { SimpleSavedObject } from '../../../../../core/public';
import { SavedObject } from '../../server';
import { SimpleSavedObject } from './simple_saved_object';
import { SavedObjectsClientContract } from './saved_objects_client';

describe('SimpleSavedObject', () => {
let client: SavedObjectsClientContract;

beforeEach(() => {
client = {
update: jest.fn(),
create: jest.fn(),
delete: jest.fn(),
} as any;
});

it('persists type and id', () => {
const id = 'logstash-*';
const type = 'index-pattern';

const client = sinon.stub();
const savedObject = new SimpleSavedObject(client, { id, type });
const savedObject = new SimpleSavedObject(client, { id, type } as SavedObject);

expect(savedObject.id).to.be(id);
expect(savedObject.type).to.be(type);
expect(savedObject.id).toEqual(id);
expect(savedObject.type).toEqual(type);
});

it('persists attributes', () => {
const attributes = { title: 'My title' };

const client = sinon.stub();
const savedObject = new SimpleSavedObject(client, { attributes });
const savedObject = new SimpleSavedObject(client, { attributes } as SavedObject);

expect(savedObject.attributes).to.be(attributes);
expect(savedObject.attributes).toEqual(attributes);
});

it('persists version', () => {
const version = 2;
const version = '2';

const client = sinon.stub();
const savedObject = new SimpleSavedObject(client, { version });
expect(savedObject._version).to.be(version);
const savedObject = new SimpleSavedObject(client, { version } as SavedObject);
expect(savedObject._version).toEqual(version);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
* directly where they are needed.
*/

export { SavedObjectSaveOpts } from 'ui/saved_objects/types';
export { npSetup, npStart } from 'ui/new_platform';
export { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
export { KbnUrl } from 'ui/url/kbn_url';
Expand All @@ -33,7 +32,6 @@ export { createTopNavDirective, createTopNavHelper } from 'ui/kbn_top_nav/kbn_to
// @ts-ignore
export { KbnUrlProvider, RedirectWhenMissingProvider } from 'ui/url/index';
export { IInjector } from 'ui/chrome';
export { SavedObjectLoader } from 'ui/saved_objects';
export { absoluteToParsedUrl } from 'ui/url/absolute_to_parsed_url';
export {
configureAppAngularModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import {
PrivateProvider,
PromiseServiceCreator,
RedirectWhenMissingProvider,
SavedObjectLoader,
} from '../legacy_imports';
// @ts-ignore
import { initDashboardApp } from './legacy_app';
Expand All @@ -47,6 +46,7 @@ import { NavigationPublicPluginStart as NavigationStart } from '../../../../../.
import { DataPublicPluginStart } from '../../../../../../plugins/data/public';
import { SharePluginStart } from '../../../../../../plugins/share/public';
import { KibanaLegacyStart } from '../../../../../../plugins/kibana_legacy/public';
import { SavedObjectLoader } from '../../../../../../plugins/saved_objects/public';

export interface RenderDeps {
pluginInitializerContext: PluginInitializerContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ import angular from 'angular';
import { Subscription } from 'rxjs';
import { map } from 'rxjs/operators';
import { History } from 'history';
import { SavedObjectSaveOpts } from 'src/plugins/saved_objects/public';
import { DashboardEmptyScreen, DashboardEmptyScreenProps } from './dashboard_empty_screen';

import { migrateLegacyQuery, SavedObjectSaveOpts, subscribeWithScope } from '../legacy_imports';
import { migrateLegacyQuery, subscribeWithScope } from '../legacy_imports';
import {
esFilters,
IndexPattern,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { TimefilterContract } from 'src/plugins/data/public';
import { SavedObjectSaveOpts } from '../../legacy_imports';
import { SavedObjectSaveOpts } from '../../../../../../../plugins/saved_objects/public';
import { updateSavedDashboard } from './update_saved_dashboard';
import { DashboardStateManager } from '../dashboard_state_manager';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
import { SavedObject, SavedObjectKibanaServices } from 'ui/saved_objects/types';
import { createSavedObjectClass } from 'ui/saved_objects/saved_object';
import {
createSavedObjectClass,
SavedObject,
SavedObjectKibanaServices,
} from '../../../../../../plugins/saved_objects/public';
import { extractReferences, injectReferences } from './saved_dashboard_references';

import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
* under the License.
*/

import { SavedObjectLoader } from 'ui/saved_objects';
import { SavedObjectKibanaServices } from 'ui/saved_objects/types';
import {
SavedObjectLoader,
SavedObjectKibanaServices,
} from '../../../../../../plugins/saved_objects/public';
import { createSavedDashboardClass } from './saved_dashboard';

export function createSavedDashboardLoader(services: SavedObjectKibanaServices) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
import { SavedObjectKibanaServices } from 'ui/saved_objects/types';
import { createSavedObjectClass } from 'ui/saved_objects/saved_object';

import {
createSavedObjectClass,
SavedObjectKibanaServices,
} from '../../../../../../plugins/saved_objects/public';

export function createSavedSearchClass(services: SavedObjectKibanaServices) {
const SavedObjectClass = createSavedObjectClass(services);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
import { SavedObjectLoader } from 'ui/saved_objects';
import { SavedObjectKibanaServices } from 'ui/saved_objects/types';

import {
SavedObjectLoader,
SavedObjectKibanaServices,
} from '../../../../../../plugins/saved_objects/public';
import { createSavedSearchClass } from './_saved_search';

export function createSavedSearchesLoader(services: SavedObjectKibanaServices) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import _ from 'lodash';
import { i18n } from '@kbn/i18n';
import { npStart } from 'ui/new_platform';
import { SavedObjectLoader } from 'ui/saved_objects';
import { SavedObjectLoader } from '../../../../../plugins/saved_objects/public';
import { createSavedDashboardLoader } from '../dashboard';
import { createSavedSearchesLoader } from '../discover';
import { TypesService, createSavedVisLoader } from '../../../visualizations/public';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('CreateIndexPatternWizardRender', () => {
config: {},
changeUrl: () => {},
indexPatternCreationType: {},
openConfirm: jest.fn(),
});

expect(render.mock.calls.length).toBe(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
i18n-id="timelion.savedObjects.howToSaveAsNewDescription"
i18n-default-message="In previous versions of Kibana, changing the name of a {savedObjectName} would make a copy with the new name. Use the 'Save as a new {savedObjectName}' checkbox to do this now."
i18n-values="{ savedObjectName: savedObject.getDisplayName() }"
i18n-description="'Save as a new {savedObjectName}' refers to common.ui.savedObjects.saveAsNewLabel and should be the same text."
i18n-description="'Save as a new {savedObjectName}' refers to timelion.savedObjects.saveAsNewLabel and should be the same text."
></div>

<label class="kuiCheckBoxLabel kuiVerticalRhythmSmall">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
* under the License.
*/

import { createSavedObjectClass } from 'ui/saved_objects/saved_object';
import { SavedObjectKibanaServices } from 'ui/saved_objects/types';
import { IUiSettingsClient } from 'kibana/public';
import {
createSavedObjectClass,
SavedObjectKibanaServices,
} from '../../../../../plugins/saved_objects/public';

// Used only by the savedSheets service, usually no reason to change this
export function createSavedSheetClass(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
* under the License.
*/
import { npStart } from 'ui/new_platform';
import { SavedObjectLoader } from 'ui/saved_objects';
// @ts-ignore
import { uiModules } from 'ui/modules';
import { SavedObjectLoader } from '../../../../../plugins/saved_objects/public';
import { createSavedSheetClass } from './_saved_sheet';

const module = uiModules.get('app/sheet');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { PersistedState } from 'ui/persisted_state';
import { Subscription } from 'rxjs';
import * as Rx from 'rxjs';
import { buildPipeline } from 'ui/visualize/loader/pipeline_helpers';
import { SavedObject } from 'ui/saved_objects/types';
import { npStart } from 'ui/new_platform';
import { IExpressionLoaderParams } from 'src/plugins/expressions/public';
import { VISUALIZE_EMBEDDABLE_TYPE } from './constants';
Expand All @@ -44,6 +43,7 @@ import {
SELECT_RANGE_TRIGGER,
} from '../../../../../plugins/embeddable/public';
import { dispatchRenderComplete } from '../../../../../plugins/kibana_utils/public';
import { SavedObject } from '../../../../../plugins/saved_objects/public';
import { SavedSearch } from '../../../kibana/public/discover/np_ready/types';
import { Vis } from '../np_ready/public';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@
*
* NOTE: It's a type of SavedObject, but specific to visualizations.
*/
import { SavedObject, SavedObjectKibanaServices } from 'ui/saved_objects/types';
import { createSavedObjectClass } from 'ui/saved_objects/saved_object';
import {
createSavedObjectClass,
SavedObject,
SavedObjectKibanaServices,
} from '../../../../../plugins/saved_objects/public';
import { updateOldState } from '../index';
import { extractReferences, injectReferences } from './saved_visualization_references';
import { IIndexPattern } from '../../../../../plugins/data/public';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
import { SavedObjectLoader } from 'ui/saved_objects';
import { SavedObjectKibanaServices } from 'ui/saved_objects/types';
import {
SavedObjectLoader,
SavedObjectKibanaServices,
} from '../../../../../plugins/saved_objects/public';

// @ts-ignore
import { findListItems } from './find_list_items';
Expand Down
1 change: 1 addition & 0 deletions src/plugins/data/public/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const createStartContract = (): Start => {
fetchForWildcard: jest.fn(),
},
}),
get: jest.fn().mockReturnValue(Promise.resolve({})),
} as unknown) as IndexPatternsContract,
};
return startContract;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/plugins/saved_objects/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "savedObjects",
"version": "kibana",
"server": false,
"ui": true,
"requiredPlugins": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,15 @@ import { i18n } from '@kbn/i18n';
* An error message to be used when the user rejects a confirm overwrite.
* @type {string}
*/
export const OVERWRITE_REJECTED = i18n.translate(
'common.ui.savedObjects.overwriteRejectedDescription',
{
defaultMessage: 'Overwrite confirmation was rejected',
}
);
export const OVERWRITE_REJECTED = i18n.translate('savedObjects.overwriteRejectedDescription', {
defaultMessage: 'Overwrite confirmation was rejected',
});
/**
* An error message to be used when the user rejects a confirm save with duplicate title.
* @type {string}
*/
export const SAVE_DUPLICATE_REJECTED = i18n.translate(
'common.ui.savedObjects.saveDuplicateRejectedDescription',
'savedObjects.saveDuplicateRejectedDescription',
{
defaultMessage: 'Save with duplicate title confirmation was rejected',
}
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/saved_objects/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,11 @@
* under the License.
*/

import { SavedObjectsPublicPlugin } from './plugin';

export { OnSaveProps, SavedObjectSaveModal, SaveResult, showSaveModal } from './save_modal';
export { getSavedObjectFinder, SavedObjectFinderUi, SavedObjectMetaData } from './finder';
export { SavedObjectLoader, createSavedObjectClass } from './saved_object';
export { SavedObjectSaveOpts, SavedObjectKibanaServices, SavedObject } from './types';

export const plugin = () => new SavedObjectsPublicPlugin();
25 changes: 25 additions & 0 deletions src/plugins/saved_objects/public/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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 { Plugin } from 'src/core/public';

export class SavedObjectsPublicPlugin implements Plugin {
public setup() {}
public start() {}
}
Loading