Skip to content

Commit

Permalink
fix: align the prefix order of sample data install and uninstall
Browse files Browse the repository at this point in the history
rename appendPrefix to addPrefix

Signed-off-by: Yulong Ruan <[email protected]>
  • Loading branch information
ruanyl committed Sep 12, 2023
1 parent 3bda7bd commit 4646b4a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { i18n } from '@osd/i18n';
import { getSavedObjects } from './saved_objects';
import { fieldMappings } from './field_mappings';
import { SampleDatasetSchema, AppLinkSchema } from '../../lib/sample_dataset_registry_types';
import { appendPrefixTo } from '../util';
import { addPrefixTo } from '../util';

const ecommerceName = i18n.translate('home.sampleData.ecommerceSpecTitle', {
defaultMessage: 'Sample eCommerce orders',
Expand All @@ -54,10 +54,10 @@ export const ecommerceSpecProvider = function (): SampleDatasetSchema {
previewImagePath: '/plugins/home/assets/sample_data_resources/ecommerce/dashboard.png',
darkPreviewImagePath: '/plugins/home/assets/sample_data_resources/ecommerce/dashboard_dark.png',
overviewDashboard: DASHBOARD_ID,
getDashboardWithPrefix: appendPrefixTo(DASHBOARD_ID),
getDashboardWithPrefix: addPrefixTo(DASHBOARD_ID),
appLinks: initialAppLinks,
defaultIndex: DEFAULT_INDEX,
getDataSourceIntegratedDefaultIndex: appendPrefixTo(DEFAULT_INDEX),
getDataSourceIntegratedDefaultIndex: addPrefixTo(DEFAULT_INDEX),
savedObjects: getSavedObjects(),
dataIndices: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { i18n } from '@osd/i18n';
import { getSavedObjects } from './saved_objects';
import { fieldMappings } from './field_mappings';
import { SampleDatasetSchema, AppLinkSchema } from '../../lib/sample_dataset_registry_types';
import { appendPrefixTo } from '../util';
import { addPrefixTo } from '../util';

const flightsName = i18n.translate('home.sampleData.flightsSpecTitle', {
defaultMessage: 'Sample flight data',
Expand All @@ -54,10 +54,10 @@ export const flightsSpecProvider = function (): SampleDatasetSchema {
previewImagePath: '/plugins/home/assets/sample_data_resources/flights/dashboard.png',
darkPreviewImagePath: '/plugins/home/assets/sample_data_resources/flights/dashboard_dark.png',
overviewDashboard: DASHBOARD_ID,
getDashboardWithPrefix: appendPrefixTo(DASHBOARD_ID),
getDashboardWithPrefix: addPrefixTo(DASHBOARD_ID),
appLinks: initialAppLinks,
defaultIndex: DEFAULT_INDEX,
getDataSourceIntegratedDefaultIndex: appendPrefixTo(DEFAULT_INDEX),
getDataSourceIntegratedDefaultIndex: addPrefixTo(DEFAULT_INDEX),
savedObjects: getSavedObjects(),
dataIndices: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { i18n } from '@osd/i18n';
import { getSavedObjects } from './saved_objects';
import { fieldMappings } from './field_mappings';
import { SampleDatasetSchema, AppLinkSchema } from '../../lib/sample_dataset_registry_types';
import { appendPrefixTo } from '../util';
import { addPrefixTo } from '../util';

const logsName = i18n.translate('home.sampleData.logsSpecTitle', {
defaultMessage: 'Sample web logs',
Expand All @@ -54,10 +54,10 @@ export const logsSpecProvider = function (): SampleDatasetSchema {
previewImagePath: '/plugins/home/assets/sample_data_resources/logs/dashboard.png',
darkPreviewImagePath: '/plugins/home/assets/sample_data_resources/logs/dashboard_dark.png',
overviewDashboard: DASHBOARD_ID,
getDashboardWithPrefix: appendPrefixTo(DASHBOARD_ID),
getDashboardWithPrefix: addPrefixTo(DASHBOARD_ID),
appLinks: initialAppLinks,
defaultIndex: DEFAULT_INDEX,
getDataSourceIntegratedDefaultIndex: appendPrefixTo(DEFAULT_INDEX),
getDataSourceIntegratedDefaultIndex: addPrefixTo(DEFAULT_INDEX),
savedObjects: getSavedObjects(),
dataIndices: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const withPrefix = (...args: Array<string | undefined>) => (id: string) => {
return id;
};

export const appendPrefixTo = (id: string) => (...args: Array<string | undefined>) => {
export const addPrefixTo = (id: string) => (...args: Array<string | undefined>) => {
return withPrefix(...args)(id);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,16 @@ export function createInstallRoute(

let createResults;
let savedObjectsList = sampleDataset.savedObjects;
if (workspaceId) {
savedObjectsList = getWorkspaceIntegratedSavedObjects(savedObjectsList, workspaceId);
}
if (dataSourceId) {
savedObjectsList = getDataSourceIntegratedSavedObjects(
savedObjectsList,
dataSourceId,
dataSourceTitle
);
}
if (workspaceId) {
savedObjectsList = getWorkspaceIntegratedSavedObjects(savedObjectsList, workspaceId);
}

try {
createResults = await context.core.savedObjects.client.bulkCreate(
Expand Down

0 comments on commit 4646b4a

Please sign in to comment.