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 9 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
1 change: 0 additions & 1 deletion src/core/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,6 @@ 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
| `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 { AppState } from 'ui/state_management/app_state';
import { npStart } from 'ui/new_platform';
import { IExpressionLoaderParams } from 'src/plugins/expressions/public';
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
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
2 changes: 2 additions & 0 deletions src/plugins/saved_objects/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@

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';
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
* under the License.
*/
import _ from 'lodash';
import { EsResponse, SavedObject, SavedObjectConfig } from 'ui/saved_objects/types';
import { parseSearchSource } from 'ui/saved_objects/helpers/parse_search_source';
import { expandShorthand, SavedObjectNotFound } from '../../../../../plugins/kibana_utils/public';
import { IndexPattern } from '../../../../../plugins/data/public';
import { EsResponse, SavedObject, SavedObjectConfig } from '../../types';
import { parseSearchSource } from './parse_search_source';
import { expandShorthand, SavedObjectNotFound } from '../../../../kibana_utils/public';
import { IndexPattern } from '../../../../data/public';

/**
* A given response of and ElasticSearch containing a plain saved object is applied to the given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import _ from 'lodash';
import { SearchSource } from '../../../../../plugins/data/public';
import { SearchSource } from '../../../../data/public';
import { hydrateIndexPattern } from './hydrate_index_pattern';
import { intializeSavedObject } from './initialize_saved_object';
import { serializeSavedObject } from './serialize_saved_object';
Expand All @@ -28,7 +28,7 @@ import {
SavedObjectConfig,
SavedObjectKibanaServices,
SavedObjectSaveOpts,
} from '../types';
} from '../../types';
import { applyESResp } from './apply_es_resp';
import { saveSavedObject } from './save_saved_object';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
import { SavedObject, SavedObjectKibanaServices } from '../types';
import { SavedObject, SavedObjectKibanaServices } from '../../types';
import { findObjectByTitle } from './find_object_by_title';
import { SAVE_DUPLICATE_REJECTED } from '../constants';
import { SAVE_DUPLICATE_REJECTED } from '../../constants';
import { displayDuplicateTitleConfirmModal } from './display_duplicate_title_confirm_modal';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import React from 'react';
import { OverlayStart } from 'kibana/public';
import { i18n } from '@kbn/i18n';
import { EuiConfirmModal } from '@elastic/eui';
import { toMountPoint } from '../../../../../plugins/kibana_react/public';
import { toMountPoint } from '../../../../kibana_react/public';

export function confirmModalPromise(
message = '',
Expand All @@ -29,12 +29,9 @@ export function confirmModalPromise(
overlays: OverlayStart
): Promise<true> {
return new Promise((resolve, reject) => {
const cancelButtonText = i18n.translate(
'common.ui.savedObjects.confirmModal.cancelButtonLabel',
{
defaultMessage: 'Cancel',
}
);
const cancelButtonText = i18n.translate('savedObjects.confirmModal.cancelButtonLabel', {
defaultMessage: 'Cancel',
});

const modal = overlays.openModal(
toMountPoint(
Expand Down
Loading