{
onChange={this.setImportFile}
/>
+
+ {this.renderImportControl(importMode, isLegacyFile, dataSourceEnabled)}
+
+ );
+ }
+
+ onSelectedDataSourceChange = (e) => {
+ const dataSourceId = e[0] ? e[0].id : undefined;
+ this.setState({ selectedDataSourceId: dataSourceId });
+ };
+
+ renderImportControl(importMode: ImportMode, isLegacyFile: boolean, dataSourceEnabled: boolean) {
+ if (dataSourceEnabled) {
+ return this.renderImportControlForDataSource(importMode, isLegacyFile);
+ }
+ return (
+
+ this.changeImportMode(newValues)}
+ optionLabel={i18n.translate(
+ 'savedObjectsManagement.objectsTable.importModeControl.importOptionsTitle',
+ { defaultMessage: 'Import options' }
+ )}
+ />
+
+ );
+ }
+
+ renderImportControlForDataSource(importMode: ImportMode, isLegacyFile: boolean) {
+ return (
+
+
+
+ Import options
+
+ ),
+ }}
+ >
+
+
+
this.changeImportMode(newValues)}
+ optionLabel={i18n.translate(
+ 'savedObjectsManagement.objectsTable.importModeControl.importOptionsTitle',
+ { defaultMessage: 'Conflict management' }
+ )}
/>
-
+
);
}
diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/components/import_mode_control.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/components/import_mode_control.tsx
index beabcfbb6308..d0c800553996 100644
--- a/src/plugins/saved_objects_management/public/management_section/objects_table/components/import_mode_control.tsx
+++ b/src/plugins/saved_objects_management/public/management_section/objects_table/components/import_mode_control.tsx
@@ -46,6 +46,7 @@ export interface ImportModeControlProps {
initialValues: ImportMode;
isLegacyFile: boolean;
updateSelection: (result: ImportMode) => void;
+ optionLabel: string;
}
export interface ImportMode {
@@ -70,7 +71,7 @@ const createNewCopiesEnabled = {
id: 'createNewCopiesEnabled',
text: i18n.translate(
'savedObjectsManagement.objectsTable.importModeControl.createNewCopies.enabledTitle',
- { defaultMessage: 'Create new objects with random IDs' }
+ { defaultMessage: 'Create new objects with unique IDs' }
),
tooltip: i18n.translate(
'savedObjectsManagement.objectsTable.importModeControl.createNewCopies.enabledText',
@@ -93,10 +94,6 @@ const overwriteDisabled = {
{ defaultMessage: 'Request action on conflict' }
),
};
-const importOptionsTitle = i18n.translate(
- 'savedObjectsManagement.objectsTable.importModeControl.importOptionsTitle',
- { defaultMessage: 'Import options' }
-);
const createLabel = ({ text, tooltip }: { text: string; tooltip: string }) => (
@@ -109,10 +106,23 @@ const createLabel = ({ text, tooltip }: { text: string; tooltip: string }) => (
);
+const overwriteRadio = (disabled: boolean, overwrite: boolean, onChange) => {
+ return (
+ onChange({ overwrite: id === overwriteEnabled.id })}
+ disabled={disabled}
+ data-test-subj={'savedObjectsManagement-importModeControl-overwriteRadioGroup'}
+ />
+ );
+};
+
export const ImportModeControl = ({
initialValues,
isLegacyFile,
updateSelection,
+ optionLabel,
}: ImportModeControlProps) => {
const [createNewCopies, setCreateNewCopies] = useState(initialValues.createNewCopies);
const [overwrite, setOverwrite] = useState(initialValues.overwrite);
@@ -126,18 +136,8 @@ export const ImportModeControl = ({
updateSelection({ createNewCopies, overwrite, ...partial });
};
- const overwriteRadio = (
- onChange({ overwrite: id === overwriteEnabled.id })}
- disabled={createNewCopies}
- data-test-subj={'savedObjectsManagement-importModeControl-overwriteRadioGroup'}
- />
- );
-
if (isLegacyFile) {
- return overwriteRadio;
+ return overwriteRadio(false, overwrite, onChange);
}
return (
@@ -145,28 +145,30 @@ export const ImportModeControl = ({
legend={{
children: (
- {importOptionsTitle}
+ {optionLabel}
),
}}
>
+ onChange({ createNewCopies: true })}
+ data-test-subj={'savedObjectsManagement-importModeControl-createNewCopiesEnabled'}
+ />
+
+
+
onChange({ createNewCopies: false })}
+ data-test-subj={'savedObjectsManagement-importModeControl-createNewCopiesDisabled'}
>
- {overwriteRadio}
+ {overwriteRadio(createNewCopies, overwrite, onChange)}
-
-
-
- onChange({ createNewCopies: true })}
- />
);
};
diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx
index 2f78f307d165..8e2f2a18f8f4 100644
--- a/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx
+++ b/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx
@@ -114,6 +114,7 @@ export interface SavedObjectsTableProps {
goInspectObject: (obj: SavedObjectWithMetadata) => void;
canGoInApp: (obj: SavedObjectWithMetadata) => boolean;
dateFormat: string;
+ dataSourceEnabled: boolean;
}
export interface SavedObjectsTableState {
@@ -558,6 +559,9 @@ export class SavedObjectsTable extends Component
);
}
diff --git a/src/plugins/saved_objects_management/public/management_section/saved_objects_table_page.tsx b/src/plugins/saved_objects_management/public/management_section/saved_objects_table_page.tsx
index 09937388ba57..1776f3e7bfd9 100644
--- a/src/plugins/saved_objects_management/public/management_section/saved_objects_table_page.tsx
+++ b/src/plugins/saved_objects_management/public/management_section/saved_objects_table_page.tsx
@@ -49,6 +49,7 @@ const SavedObjectsTablePage = ({
columnRegistry,
namespaceRegistry,
setBreadcrumbs,
+ dataSourceEnabled,
}: {
coreStart: CoreStart;
dataStart: DataPublicPluginStart;
@@ -58,6 +59,7 @@ const SavedObjectsTablePage = ({
columnRegistry: SavedObjectsManagementColumnServiceStart;
namespaceRegistry: SavedObjectsManagementNamespaceServiceStart;
setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void;
+ dataSourceEnabled: boolean;
}) => {
const capabilities = coreStart.application.capabilities;
const itemsPerPage = coreStart.uiSettings.get('savedObjects:perPage', 50);
@@ -102,6 +104,7 @@ const SavedObjectsTablePage = ({
const { inAppUrl } = savedObject.meta;
return inAppUrl ? Boolean(get(capabilities, inAppUrl.uiCapabilitiesPath)) : false;
}}
+ dataSourceEnabled={dataSourceEnabled}
/>
);
};
diff --git a/src/plugins/saved_objects_management/public/plugin.ts b/src/plugins/saved_objects_management/public/plugin.ts
index 14beb73386a8..690dee9c21e4 100644
--- a/src/plugins/saved_objects_management/public/plugin.ts
+++ b/src/plugins/saved_objects_management/public/plugin.ts
@@ -31,6 +31,7 @@
import { i18n } from '@osd/i18n';
import { CoreSetup, CoreStart, Plugin } from 'src/core/public';
+import { DataSourcePluginSetup } from 'src/plugins/data_source/public';
import { VisBuilderStart } from '../../vis_builder/public';
import { ManagementSetup } from '../../management/public';
import { UiActionsSetup, UiActionsStart } from '../../ui_actions/public';
@@ -73,6 +74,7 @@ export interface SetupDependencies {
management: ManagementSetup;
home?: HomePublicPluginSetup;
uiActions: UiActionsSetup;
+ dataSource?: DataSourcePluginSetup;
}
export interface StartDependencies {
@@ -100,7 +102,7 @@ export class SavedObjectsManagementPlugin
public setup(
core: CoreSetup,
- { home, management, uiActions }: SetupDependencies
+ { home, management, uiActions, dataSource }: SetupDependencies
): SavedObjectsManagementPluginSetup {
const actionSetup = this.actionService.setup();
const columnSetup = this.columnService.setup();
@@ -136,6 +138,7 @@ export class SavedObjectsManagementPlugin
core,
serviceRegistry: this.serviceRegistry,
mountParams,
+ dataSourceEnabled: !!dataSource,
});
},
});
diff --git a/test/functional/apps/dashboard/time_zones.js b/test/functional/apps/dashboard/time_zones.js
index 13a424bd7ea6..4c82cfe8006c 100644
--- a/test/functional/apps/dashboard/time_zones.js
+++ b/test/functional/apps/dashboard/time_zones.js
@@ -54,7 +54,9 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickOpenSearchDashboardsSavedObjects();
await PageObjects.savedObjects.importFile(
- path.join(__dirname, 'exports', 'timezonetest_6_2_4.json')
+ path.join(__dirname, 'exports', 'timezonetest_6_2_4.json'),
+ true,
+ true
);
await PageObjects.savedObjects.checkImportSucceeded();
await PageObjects.common.navigateToApp('dashboard');
diff --git a/test/functional/apps/management/_import_objects.js b/test/functional/apps/management/_import_objects.js
index 2c432964f309..a4a919aedcd9 100644
--- a/test/functional/apps/management/_import_objects.js
+++ b/test/functional/apps/management/_import_objects.js
@@ -226,7 +226,9 @@ export default function ({ getService, getPageObjects }) {
it('should import saved objects', async function () {
await PageObjects.savedObjects.importFile(
- path.join(__dirname, 'exports', '_import_objects.json')
+ path.join(__dirname, 'exports', '_import_objects.json'),
+ true,
+ true
);
await PageObjects.savedObjects.checkImportSucceeded();
await PageObjects.savedObjects.clickImportDone();
@@ -237,7 +239,9 @@ export default function ({ getService, getPageObjects }) {
it('should provide dialog to allow the importing of saved objects with index pattern conflicts', async function () {
await PageObjects.savedObjects.importFile(
- path.join(__dirname, 'exports', '_import_objects-conflicts.json')
+ path.join(__dirname, 'exports', '_import_objects-conflicts.json'),
+ true,
+ true
);
await PageObjects.savedObjects.checkImportLegacyWarning();
await PageObjects.savedObjects.checkImportConflictsWarning();
@@ -258,7 +262,8 @@ export default function ({ getService, getPageObjects }) {
// so that we can override the existing visualization.
await PageObjects.savedObjects.importFile(
path.join(__dirname, 'exports', '_import_objects_exists.json'),
- false
+ false,
+ true
);
await PageObjects.savedObjects.checkImportLegacyWarning();
@@ -278,7 +283,8 @@ export default function ({ getService, getPageObjects }) {
// so that we can be prompted to override the existing visualization.
await PageObjects.savedObjects.importFile(
path.join(__dirname, 'exports', '_import_objects_exists.json'),
- false
+ false,
+ true
);
await PageObjects.savedObjects.checkImportLegacyWarning();
@@ -298,7 +304,8 @@ export default function ({ getService, getPageObjects }) {
// so that we can override the existing visualization.
await PageObjects.savedObjects.importFile(
path.join(__dirname, 'exports', '_import_objects_multiple_exists.json'),
- false
+ false,
+ true
);
await PageObjects.savedObjects.checkImportLegacyWarning();
@@ -325,7 +332,8 @@ export default function ({ getService, getPageObjects }) {
// so that we can override the existing visualization.
await PageObjects.savedObjects.importFile(
path.join(__dirname, 'exports', '_import_index_patterns_multiple_exists.json'),
- false
+ false,
+ true
);
// Override the index patterns.
@@ -343,13 +351,17 @@ export default function ({ getService, getPageObjects }) {
it('should import saved objects linked to saved searches', async function () {
await PageObjects.savedObjects.importFile(
- path.join(__dirname, 'exports', '_import_objects_saved_search.json')
+ path.join(__dirname, 'exports', '_import_objects_saved_search.json'),
+ true,
+ true
);
await PageObjects.savedObjects.checkImportSucceeded();
await PageObjects.savedObjects.clickImportDone();
await PageObjects.savedObjects.importFile(
- path.join(__dirname, 'exports', '_import_objects_connected_to_saved_search.json')
+ path.join(__dirname, 'exports', '_import_objects_connected_to_saved_search.json'),
+ true,
+ true
);
await PageObjects.savedObjects.checkImportSucceeded();
await PageObjects.savedObjects.clickImportDone();
@@ -361,7 +373,9 @@ export default function ({ getService, getPageObjects }) {
it('should not import saved objects linked to saved searches when saved search does not exist', async function () {
await PageObjects.savedObjects.importFile(
- path.join(__dirname, 'exports', '_import_objects_connected_to_saved_search.json')
+ path.join(__dirname, 'exports', '_import_objects_connected_to_saved_search.json'),
+ true,
+ true
);
await PageObjects.savedObjects.checkImportFailedWarning();
await PageObjects.savedObjects.clickImportDone();
@@ -374,7 +388,9 @@ export default function ({ getService, getPageObjects }) {
it('should not import saved objects linked to saved searches when saved search index pattern does not exist', async function () {
// First, import the saved search
await PageObjects.savedObjects.importFile(
- path.join(__dirname, 'exports', '_import_objects_saved_search.json')
+ path.join(__dirname, 'exports', '_import_objects_saved_search.json'),
+ true,
+ true
);
// Wait for all the saves to happen
await PageObjects.savedObjects.checkImportSucceeded();
@@ -387,7 +403,9 @@ export default function ({ getService, getPageObjects }) {
// Last, import a saved object connected to the saved search
// This should NOT show the conflicts
await PageObjects.savedObjects.importFile(
- path.join(__dirname, 'exports', '_import_objects_connected_to_saved_search.json')
+ path.join(__dirname, 'exports', '_import_objects_connected_to_saved_search.json'),
+ true,
+ true
);
// Wait for all the saves to happen
await PageObjects.savedObjects.checkNoneImported();
@@ -401,7 +419,9 @@ export default function ({ getService, getPageObjects }) {
it('should import saved objects with index patterns when index patterns already exists', async () => {
// First, import the objects
await PageObjects.savedObjects.importFile(
- path.join(__dirname, 'exports', '_import_objects_with_index_patterns.json')
+ path.join(__dirname, 'exports', '_import_objects_with_index_patterns.json'),
+ true,
+ true
);
await PageObjects.savedObjects.clickImportDone();
@@ -417,7 +437,9 @@ export default function ({ getService, getPageObjects }) {
// Then, import the objects
await PageObjects.savedObjects.importFile(
- path.join(__dirname, 'exports', '_import_objects_with_index_patterns.json')
+ path.join(__dirname, 'exports', '_import_objects_with_index_patterns.json'),
+ true,
+ true
);
await PageObjects.savedObjects.checkImportSucceeded();
await PageObjects.savedObjects.clickImportDone();
diff --git a/test/functional/apps/management/_mgmt_import_saved_objects.js b/test/functional/apps/management/_mgmt_import_saved_objects.js
index 631b4e85cb8b..c5f852bae5c0 100644
--- a/test/functional/apps/management/_mgmt_import_saved_objects.js
+++ b/test/functional/apps/management/_mgmt_import_saved_objects.js
@@ -53,7 +53,9 @@ export default function ({ getService, getPageObjects }) {
it('should import saved objects mgmt', async function () {
await PageObjects.settings.clickOpenSearchDashboardsSavedObjects();
await PageObjects.savedObjects.importFile(
- path.join(__dirname, 'exports', 'mgmt_import_objects.json')
+ path.join(__dirname, 'exports', 'mgmt_import_objects.json'),
+ true,
+ true
);
await PageObjects.settings.associateIndexPattern(
'4c3f3c30-ac94-11e8-a651-614b2788174a',
diff --git a/test/functional/page_objects/management/saved_objects_page.ts b/test/functional/page_objects/management/saved_objects_page.ts
index 3a6a987b3b68..d0014065e216 100644
--- a/test/functional/page_objects/management/saved_objects_page.ts
+++ b/test/functional/page_objects/management/saved_objects_page.ts
@@ -50,15 +50,22 @@ export function SavedObjectsPageProvider({ getService, getPageObjects }: FtrProv
await this.waitTableIsLoaded();
}
- async importFile(path: string, overwriteAll = true) {
+ async importFile(path: string, overwriteAll = true, isLegacy = false) {
log.debug(`importFile(${path})`);
log.debug(`Clicking importObjects`);
await testSubjects.click('importObjects');
await PageObjects.common.setFileInputPath(path);
+ if (!isLegacy) {
+ await testSubjects.click(
+ 'savedObjectsManagement-importModeControl-createNewCopiesDisabled'
+ );
+ }
+
if (!overwriteAll) {
log.debug(`Toggling overwriteAll`);
+
const radio = await testSubjects.find(
'savedObjectsManagement-importModeControl-overwriteRadioGroup'
);