Skip to content

Commit

Permalink
Merge branch 'main' into feature/auto-trigger-schema-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
mengweieric authored Oct 11, 2024
2 parents 45f437f + e4029fb commit 0c9a3ca
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,6 @@ jobs:
with:
path: OpenSearch-Dashboards/plugins/dashboards-observability

- name: Get yarn cache dir
id: setup-yarn
shell: bash
run: |
cd ./OpenSearch-Dashboards
source $NVM_DIR/nvm.sh
nvm use
echo "yarn-cache-dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Yarn Cache
uses: actions/cache@v4
with:
path: ${{ steps.setup-yarn.outputs.yarn-cache-dir }}
key: ${{ runner.OS }}-yarn-${{ hashFiles('OpenSearch-Dashboards/**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-yarn-
- name: Plugin Bootstrap
uses: nick-fields/retry@v2
with:
Expand Down Expand Up @@ -135,20 +118,6 @@ jobs:
- run: node -v
- run: yarn -v

- name: Get yarn cache dir
id: setup-yarn
shell: bash
run: |
echo "yarn-cache-dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Yarn Cache
uses: actions/cache@v4
with:
path: ${{ steps.setup-yarn.outputs.yarn-cache-dir }}
key: ${{ runner.OS }}-yarn-${{ hashFiles('OpenSearch-Dashboards/**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-yarn-
- name: Checkout Dashboards Observability
uses: actions/checkout@v2
with:
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/ftr-e2e-dashboards-observability-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,16 @@ jobs:
npm uninstall -g yarn
echo "Installing yarn ${{ steps.versions_step.outputs.yarn_version }}"
npm i -g yarn@${{ steps.versions_step.outputs.yarn_version }}
echo "yarn-cache-dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Yarn Cache
uses: actions/cache@v4
with:
path: ${{ steps.setup-yarn.outputs.yarn-cache-dir }}
key: ${{ runner.OS }}-yarn-${{ hashFiles('OpenSearch-Dashboards/**/yarn.lock') }}
path: |
OpenSearch-Dashboards/**/target
OpenSearch-Dashboards/**/node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('OpenSearch-Dashboards/**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-yarn-
${{ runner.OS }}-build-
- name: Bootstrap OpenSearch Dashboards
run: |
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/integration-tests-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,16 @@ jobs:
npm uninstall -g yarn
echo "Installing yarn ${{ steps.versions_step.outputs.yarn_version }}"
npm i -g yarn@${{ steps.versions_step.outputs.yarn_version }}
echo "yarn-cache-dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Yarn Cache
uses: actions/cache@v4
with:
path: ${{ steps.setup-yarn.outputs.yarn-cache-dir }}
key: ${{ runner.OS }}-yarn-${{ hashFiles('OpenSearch-Dashboards/**/yarn.lock') }}
path: |
OpenSearch-Dashboards/**/target
OpenSearch-Dashboards/**/node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('OpenSearch-Dashboards/**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-yarn-
${{ runner.OS }}-build-
- name: Bootstrap OpenSearch Dashboards
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,11 +531,11 @@ exports[`Added Integration View Test Renders added integration view using dummy
>
<EuiFlexGroup
alignItems="center"
gutterSize="m"
gutterSize="s"
wrap={true}
>
<div
className="euiFlexGroup euiFlexGroup--gutterMedium euiFlexGroup--alignItemsCenter euiFlexGroup--directionRow euiFlexGroup--responsive euiFlexGroup--wrap"
className="euiFlexGroup euiFlexGroup--gutterSmall euiFlexGroup--alignItemsCenter euiFlexGroup--directionRow euiFlexGroup--responsive euiFlexGroup--wrap"
>
<EuiFlexItem
className="euiSearchBar__searchHolder"
Expand Down
79 changes: 41 additions & 38 deletions public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,47 @@ export class ObservabilityPlugin
window.location.assign(convertLegacyTraceAnalyticsUrl(window.location));
}

const BASE_URL = core.http.basePath.prepend('/app/observability-dashboards#');
setupDeps.dashboard.registerDashboardProvider({
appId: 'observability-panel',
savedObjectsType: 'observability-panel',
savedObjectsName: 'Observability',
editUrlPathFn: (obj: SavedObject) => `${BASE_URL}/${obj.id}/edit`,
viewUrlPathFn: (obj: SavedObject) => `${BASE_URL}/${obj.id}`,
createLinkText: 'Observability Dashboard',
createSortText: 'Observability Dashboard',
createUrl: `${BASE_URL}/create`,
});
// if MDS is not enabled register observability dashboards & PPL visualizations in core
if (!setupDeps.dataSource) {
const BASE_URL = core.http.basePath.prepend('/app/observability-dashboards#');
setupDeps.dashboard.registerDashboardProvider({
appId: 'observability-panel',
savedObjectsType: 'observability-panel',
savedObjectsName: 'Observability',
editUrlPathFn: (obj: SavedObject) => `${BASE_URL}/${obj.id}/edit`,
viewUrlPathFn: (obj: SavedObject) => `${BASE_URL}/${obj.id}`,
createLinkText: 'Observability Dashboard',
createSortText: 'Observability Dashboard',
createUrl: `${BASE_URL}/create`,
});

setupDeps.visualizations.registerAlias({
name: OBSERVABILITY_EMBEDDABLE_ID,
title: OBSERVABILITY_EMBEDDABLE_DISPLAY_NAME,
description: OBSERVABILITY_EMBEDDABLE_DESCRIPTION,
icon: OBSERVABILITY_EMBEDDABLE_ICON,
aliasApp: observabilityLogsID,
aliasPath: `#/explorer/?${CREATE_TAB_PARAM_KEY}=${CREATE_TAB_PARAM[TAB_CHART_ID]}`,
stage: 'production',
appExtensions: {
visualizations: {
docTypes: [VISUALIZATION_SAVED_OBJECT],
toListItem: ({ id, attributes, updated_at: updatedAt }) => ({
description: attributes?.description,
editApp: observabilityLogsID,
editUrl: `#/explorer/${VISUALIZATION_SAVED_OBJECT}:${id}`,
icon: OBSERVABILITY_EMBEDDABLE_ICON,
id,
savedObjectType: VISUALIZATION_SAVED_OBJECT,
title: attributes?.title,
typeTitle: OBSERVABILITY_EMBEDDABLE_DISPLAY_NAME,
stage: 'production',
updated_at: updatedAt,
}),
},
},
});
}

const OBSERVABILITY_APP_CATEGORIES: Record<string, AppCategory> = Object.freeze({
observability: {
Expand Down Expand Up @@ -401,33 +431,6 @@ export class ObservabilityPlugin
}));
setupDeps.embeddable.registerEmbeddableFactory(OBSERVABILITY_EMBEDDABLE, embeddableFactory);

setupDeps.visualizations.registerAlias({
name: OBSERVABILITY_EMBEDDABLE_ID,
title: OBSERVABILITY_EMBEDDABLE_DISPLAY_NAME,
description: OBSERVABILITY_EMBEDDABLE_DESCRIPTION,
icon: OBSERVABILITY_EMBEDDABLE_ICON,
aliasApp: observabilityLogsID,
aliasPath: `#/explorer/?${CREATE_TAB_PARAM_KEY}=${CREATE_TAB_PARAM[TAB_CHART_ID]}`,
stage: 'production',
appExtensions: {
visualizations: {
docTypes: [VISUALIZATION_SAVED_OBJECT],
toListItem: ({ id, attributes, updated_at: updatedAt }) => ({
description: attributes?.description,
editApp: observabilityLogsID,
editUrl: `#/explorer/${VISUALIZATION_SAVED_OBJECT}:${id}`,
icon: OBSERVABILITY_EMBEDDABLE_ICON,
id,
savedObjectType: VISUALIZATION_SAVED_OBJECT,
title: attributes?.title,
typeTitle: OBSERVABILITY_EMBEDDABLE_DISPLAY_NAME,
stage: 'production',
updated_at: updatedAt,
}),
},
},
});

registerAsssitantDependencies(setupDeps.assistantDashboards);

// Return methods that should be available to other plugins
Expand Down
13 changes: 7 additions & 6 deletions server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ import {
} from '../../../src/core/server';
import { DataSourcePluginSetup } from '../../../src/plugins/data_source/server/types';
import { DataSourceManagementPlugin } from '../../../src/plugins/data_source_management/public/plugin';
import { observabilityPanelsID } from '../common/constants/shared';
import { migrateV1IntegrationToV2Integration } from './adaptors/integrations/migrations';
import { OpenSearchObservabilityPlugin } from './adaptors/opensearch_observability_plugin';
import { PPLPlugin } from './adaptors/ppl_plugin';
import { PPLParsers } from './parsers/ppl_parser';
import { registerObservabilityUISettings } from './plugin_helper/register_settings';
import { setupRoutes } from './routes/index';
import {
getSearchSavedObject,
getVisualizationSavedObject,
notebookSavedObject,
searchSavedObject,
visualizationSavedObject,
} from './saved_objects/observability_saved_object';
import { AssistantPluginSetup, ObservabilityPluginSetup, ObservabilityPluginStart } from './types';

Expand Down Expand Up @@ -89,9 +90,9 @@ export class ObservabilityPlugin
},
management: {
importableAndExportable: true,
getInAppUrl() {
getInAppUrl(obj) {
return {
path: `/app/management/observability/settings`,
path: dataSourceEnabled ? '' : `/app/${observabilityPanelsID}#/${obj.id}`,
uiCapabilitiesPath: 'advancedSettings.show',
};
},
Expand Down Expand Up @@ -219,8 +220,8 @@ export class ObservabilityPlugin
// Register server side APIs
setupRoutes({ router, client: openSearchObservabilityClient, dataSourceEnabled });

core.savedObjects.registerType(visualizationSavedObject);
core.savedObjects.registerType(searchSavedObject);
core.savedObjects.registerType(getVisualizationSavedObject(dataSourceEnabled));
core.savedObjects.registerType(getSearchSavedObject(dataSourceEnabled));
core.savedObjects.registerType(notebookSavedObject);
core.capabilities.registerProvider(() => ({
observability: {
Expand Down
12 changes: 6 additions & 6 deletions server/saved_objects/observability_saved_object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
VISUALIZATION_SAVED_OBJECT,
} from '../../common/types/observability_saved_object_attributes';

export const visualizationSavedObject: SavedObjectsType = {
export const getVisualizationSavedObject = (dataSourceEnabled: boolean): SavedObjectsType => ({
name: VISUALIZATION_SAVED_OBJECT,
hidden: false,
namespaceType: 'single',
Expand All @@ -26,7 +26,7 @@ export const visualizationSavedObject: SavedObjectsType = {
const editPath = `#/explorer/${VISUALIZATION_SAVED_OBJECT}:${obj.id}`;
const editUrl = `/app/${observabilityLogsID}${editPath}`;
return {
path: editUrl,
path: dataSourceEnabled ? '' : editUrl,
uiCapabilitiesPath: 'observability.show',
};
},
Expand All @@ -44,9 +44,9 @@ export const visualizationSavedObject: SavedObjectsType = {
},
},
migrations: {},
};
});

export const searchSavedObject: SavedObjectsType = {
export const getSearchSavedObject = (dataSourceEnabled: boolean): SavedObjectsType => ({
name: SEARCH_SAVED_OBJECT,
icon: 'editorCodeBlock',
hidden: false,
Expand All @@ -61,7 +61,7 @@ export const searchSavedObject: SavedObjectsType = {
const editPath = `#/explorer/${SEARCH_SAVED_OBJECT}:${obj.id}`;
const editUrl = `/app/${observabilityLogsID}${editPath}`;
return {
path: editUrl,
path: dataSourceEnabled ? '' : editUrl,
uiCapabilitiesPath: 'observability.show',
};
},
Expand All @@ -79,7 +79,7 @@ export const searchSavedObject: SavedObjectsType = {
},
},
migrations: {},
};
});

export const notebookSavedObject: SavedObjectsType = {
name: NOTEBOOK_SAVED_OBJECT,
Expand Down

0 comments on commit 0c9a3ca

Please sign in to comment.