Skip to content

Commit

Permalink
Merge branch 'main' into notebooks-sample-fix
Browse files Browse the repository at this point in the history
Signed-off-by: Sumukh Swamy <[email protected]>
  • Loading branch information
sumukhswamy authored Sep 4, 2024
2 parents 3817694 + 1c6ff11 commit fba0d8a
Show file tree
Hide file tree
Showing 39 changed files with 2,742 additions and 261 deletions.
8 changes: 8 additions & 0 deletions common/constants/overview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export const alertsPluginID = 'alerting';
export const anomalyPluginID = 'anomalyDetection';
export const observabilityDashboardsKey = 'observability:defaultDashboard';
8 changes: 8 additions & 0 deletions common/constants/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@ export const observabilityMetricsID = 'observability-metrics';
export const observabilityMetricsTitle = 'Metrics';
export const observabilityMetricsPluginOrder = 5092;

export const observabilityTracesNewNavID = 'observability-traces-nav';
export const observabilityTracesNewNavURL = observabilityTracesNewNavID + '#/traces';
export const observabilityTracesID = 'observability-traces';
export const observabilityTracesTitle = 'Traces';
export const observabilityTracesPluginOrder = 5093;

export const observabilityServicesNewNavID = 'observability-services-nav';
export const observabilityServicesNewNavURL = observabilityServicesNewNavID + '#/services';
export const observabilityServicesID = 'observability-services';
export const observabilityServicesTitle = 'Services';
export const observabilityServicesPluginOrder = 5092;
Expand All @@ -84,6 +88,10 @@ export const observabilityDataConnectionsPluginOrder = 9030;
export const queryWorkbenchPluginID = 'opensearch-query-workbench';
export const queryWorkbenchPluginCheck = 'plugin:queryWorkbenchDashboards';

export const alertingPluginID = 'alerting';
export const anomalyDetectionPluginID = 'anomaly-detection-dashboards';
export const discoverPluginID = 'data-explorer/discover';

// Shared Constants
export const SQL_DOCUMENTATION_URL = 'https://opensearch.org/docs/latest/search-plugins/sql/index/';
export const PPL_DOCUMENTATION_URL =
Expand Down
20 changes: 20 additions & 0 deletions common/types/overview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export interface DashboardState {
startDate: string;
endDate: string;
dashboardTitle: string;
dashboardId: string;
}

export interface DashboardSavedObjectsType {
[key: string]: {
value: string;
label: string;
startDate: string;
endDate: string;
};
}
13 changes: 10 additions & 3 deletions common/utils/set_nav_bread_crumbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@ import { coreRefs } from '../../public/framework/core_refs';

export const setNavBreadCrumbs = (
parentBreadCrumb: EuiBreadcrumb[],
pageBreadCrumb: EuiBreadcrumb[]
pageBreadCrumb: EuiBreadcrumb[],
counter?: number
) => {
const isNavGroupEnabled = coreRefs?.chrome?.navGroup.getNavGroupEnabled();

const updatedPageBreadCrumb = pageBreadCrumb.map((crumb) => ({
...crumb,
text: isNavGroupEnabled && counter !== undefined ? `${crumb.text} (${counter})` : crumb.text,
}));

if (isNavGroupEnabled) {
coreRefs?.chrome?.setBreadcrumbs([...pageBreadCrumb]);
coreRefs?.chrome?.setBreadcrumbs([...updatedPageBreadCrumb]);
} else {
coreRefs?.chrome?.setBreadcrumbs([...parentBreadCrumb, ...pageBreadCrumb]);
coreRefs?.chrome?.setBreadcrumbs([...parentBreadCrumb, ...updatedPageBreadCrumb]);
}
};
3 changes: 2 additions & 1 deletion opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"savedObjects",
"uiActions",
"urlForwarding",
"visualizations"
"visualizations",
"contentManagement"
],
"optionalPlugins": [
"managementOverview",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { ApplicationType, AvailabilityType } from '../../../../common/types/appl
import { UI_DATE_FORMAT } from '../../../../common/constants/shared';
import { setNavBreadCrumbs } from '../../../../common/utils/set_nav_bread_crumbs';
import { DeleteModal } from '../../common/helpers/delete_modal';
import { HeaderControlledComponentsWrapper } from '../../../../public/plugin_headerControl';
import { HeaderControlledComponentsWrapper } from '../../../../public/plugin_helpers/plugin_headerControl';
import { coreRefs } from '../../../framework/core_refs';

const newNavigation = coreRefs.chrome?.navGroup.getNavGroupEnabled();
Expand Down Expand Up @@ -81,11 +81,12 @@ export function AppTable(props: AppTableProps) {
text: 'Applications',
href: '#/',
},
]
],
applications.length
);
clear();
fetchApplications();
}, []);
}, [applications.length]);

const clear = () => {
setFilters([]);
Expand Down Expand Up @@ -256,7 +257,6 @@ export function AppTable(props: AppTableProps) {
{createButtonText}
</EuiSmallButton>,
]}
badgeContent={applications.length}
/>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import { Configuration } from './configuration';
import { ServiceDetailFlyout } from './flyout_components/service_detail_flyout';
import { TraceDetailFlyout } from './flyout_components/trace_detail_flyout';
import { coreRefs } from '../../../framework/core_refs';
import { HeaderControlledComponentsWrapper } from '../../../../public/plugin_headerControl';
import { HeaderControlledComponentsWrapper } from '../../../../public/plugin_helpers/plugin_headerControl';

const newNavigation = coreRefs.chrome?.navGroup.getNavGroupEnabled();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import { EuiPage, EuiPageBody, EuiSpacer } from '@elastic/eui';
import React, { useEffect, useState } from 'react';
import { HomeProps } from 'public/components/getting_started/home';
import { GettingStartedConnectionsHeader } from './getting_started_header';
import { CollectAndShipData } from './getting_started_collectData';
import { QueryAndAnalyze } from './getting_started_queryAndAnalyze';

Expand Down Expand Up @@ -58,8 +57,6 @@ export const NewGettingStarted = (props: ExtendedHomeProps) => {
return (
<EuiPage>
<EuiPageBody component="div">
<GettingStartedConnectionsHeader />
<EuiSpacer size="l" />
<CollectAndShipData
isOpen={isPickYourSourceOpen}
onToggle={togglePickYourSource}
Expand All @@ -70,7 +67,7 @@ export const NewGettingStarted = (props: ExtendedHomeProps) => {
selectedDataSourceId={selectedDataSourceId}
selectedDataSourceLabel={selectedDataSourceLabel}
/>
<EuiSpacer size="l" />
<EuiSpacer size="m" />
{!isSampleDataset && (
<QueryAndAnalyze
isOpen={isQueryDataOpen}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
EuiTitle,
} from '@elastic/eui';
import { coreRefs } from '../../../../public/framework/core_refs';
import { fetchDashboardIds, fetchIndexPatternIds } from './utils';
import { fetchDashboardIds, fetchIndexPatternIds, redirectToDashboards } from './utils';

interface Pattern {
id: string;
Expand Down Expand Up @@ -80,7 +80,7 @@ export const QueryAndAnalyze: React.FC<QueryAndAnalyzeProps> = ({
});
};

const redirectToDashboards = (dashboardId: string) => {
const redirectToDashboardsMDS = (dashboardId: string) => {
const finalDashboardId = selectedDataSourceId
? `mds-${selectedDataSourceId}-objectId-${dashboardId}`
: dashboardId;
Expand Down Expand Up @@ -137,7 +137,7 @@ export const QueryAndAnalyze: React.FC<QueryAndAnalyzeProps> = ({
title={dashboard.title}
description={`Explore the ${dashboard.title} dashboard`}
onClick={() => {
redirectToDashboards(dashboard.id);
redirectToDashboardsMDS(dashboard.id);
}}
/>
</EuiFlexItem>
Expand Down
6 changes: 6 additions & 0 deletions public/components/getting_started/components/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,9 @@ export const fetchIndexPatternIds = async (tutorialId: string) => {
console.error(err.message);
}
};

export const redirectToDashboards = (path: string) => {
coreRefs?.application!.navigateToApp('dashboards', {
path: `#/${path}`,
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { useToast } from '../../../../public/components/common/toast';
import { DeleteModal } from '../../common/helpers/delete_modal';
import { PanelTitle } from '../../trace_analytics/components/common/helper_functions';
import { AddedIntegrationProps } from './integration_types';
import { HeaderControlledComponentsWrapper } from '../../../../public/plugin_headerControl';
import { HeaderControlledComponentsWrapper } from '../../../../public/plugin_helpers/plugin_headerControl';
import { coreRefs } from '../../../framework/core_refs';

const newNavigation = coreRefs.chrome?.navGroup.getNavGroupEnabled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
OPENSEARCH_DOCUMENTATION_URL,
} from '../../../../common/constants/integrations';
import { IntegrationUploadFlyout } from './upload_flyout';
import { HeaderControlledComponentsWrapper } from '../../../../public/plugin_headerControl';
import { HeaderControlledComponentsWrapper } from '../../../../public/plugin_helpers/plugin_headerControl';
import { coreRefs } from '../../../framework/core_refs';

const newNavigation = coreRefs.chrome?.navGroup.getNavGroupEnabled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
EuiSmallButton,
} from '@elastic/eui';
import React from 'react';
import { HeaderControlledComponentsWrapper } from '../../../../public/plugin_headerControl';
import { HeaderControlledComponentsWrapper } from '../../../../public/plugin_helpers/plugin_headerControl';
import { coreRefs } from '../../../framework/core_refs';

const newNavigation = coreRefs.chrome?.navGroup.getNavGroupEnabled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ exports[`<NoteTable /> spec renders the component 1`] = `
<div
class="euiFlexGroup euiFlexGroup--gutterSmall euiFlexGroup--alignItemsCenter euiFlexGroup--directionRow euiFlexGroup--responsive"
>
<div
class="euiFlexItem euiFlexItem--flexGrowZero"
/>
<div
class="euiFlexItem"
>
Expand Down Expand Up @@ -186,47 +189,6 @@ exports[`<NoteTable /> spec renders the component 1`] = `
</div>
</div>
</div>
<div
class="euiFlexItem euiFlexItem--flexGrowZero"
>
<div
class="euiPopover euiPopover--anchorDownCenter"
>
<div
class="euiPopover__anchor"
>
<button
class="euiButton euiButton--primary euiButton--small"
data-test-subj="notebookTableActionBtn"
type="button"
>
<span
class="euiButtonContent euiButtonContent--iconRight euiButton__content"
>
<svg
aria-hidden="true"
class="euiIcon euiIcon--medium euiIcon--inherit euiIcon-isLoading euiButtonContent__icon"
focusable="false"
height="16"
role="img"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M5.277 10.088c.02.014.04.03.057.047.582.55 1.134.812 1.666.812.586 0 1.84-.293 3.713-.88L9 6.212V2H7v4.212l-1.723 3.876Zm-.438.987L3.539 14h8.922l-1.32-2.969C9.096 11.677 7.733 12 7 12c-.74 0-1.463-.315-2.161-.925ZM6 2H5V1h6v1h-1v4l3.375 7.594A1 1 0 0 1 12.461 15H3.54a1 1 0 0 1-.914-1.406L6 6V2Z"
/>
</svg>
<span
class="euiButton__text"
>
Actions
</span>
</span>
</button>
</div>
</div>
</div>
</div>
<hr
class="euiHorizontalRule euiHorizontalRule--full euiHorizontalRule--marginMedium"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,14 @@ describe('<NoteTable /> spec', () => {
dateCreated: '2023-01-01 12:00:00',
dateModified: '2023-01-02 12:00:00',
}));
const utils = renderNoteTable({ notebooks });
const { getByTestId, getAllByText, ...utils } = renderNoteTable({ notebooks });
expect(utils.container.firstChild).toMatchSnapshot();

fireEvent.click(utils.getByText('Add sample notebooks'));
fireEvent.click(utils.getAllByLabelText('Select this row')[0]);
fireEvent.click(utils.getByText('Actions'));
fireEvent.click(utils.getByText('Delete'));
fireEvent.click(getByTestId('deleteSelectedNotebooks'));
expect(getAllByText('Delete 1 notebook')).toHaveLength(2);
fireEvent.click(utils.getByText('Cancel'));
fireEvent.click(utils.getAllByLabelText('Select this row')[0]);
fireEvent.click(utils.getByText('Actions'));
});

it('create notebook modal', async () => {
Expand Down Expand Up @@ -130,17 +128,16 @@ describe('<NoteTable /> spec', () => {
dateModified: 'date-modified',
},
];
const { getByText, getByLabelText, getAllByText, getByTestId } = renderNoteTable({ notebooks });
const { getByLabelText, getAllByText, getByTestId } = renderNoteTable({ notebooks });

// Select a notebook
fireEvent.click(getByLabelText('Select this row'));

// Open Actions dropdown and click Delete
fireEvent.click(getByText('Actions'));
fireEvent.click(getByText('Delete'));
// Click the delete button
fireEvent.click(getByTestId('deleteSelectedNotebooks'));

// Ensure the modal is open (you may need to adjust based on your modal implementation)
expect(getAllByText('Delete 1 notebook')).toHaveLength(1);
expect(getAllByText('Delete 1 notebook')).toHaveLength(2);

// Mock user confirmation and submit
fireEvent.input(getByTestId('delete-notebook-modal-input'), {
Expand Down Expand Up @@ -178,22 +175,21 @@ describe('<NoteTable /> spec', () => {
dateModified: 'date-modified',
},
];
const { getByText, getByLabelText, queryByText } = renderNoteTable({ notebooks });
const { getByText, getByLabelText, getAllByText, getByTestId } = renderNoteTable({ notebooks });

// Select a notebook
fireEvent.click(getByLabelText('Select this row'));

// Open Actions dropdown and click Delete
fireEvent.click(getByText('Actions'));
fireEvent.click(getByText('Delete'));
// Click the delete button
fireEvent.click(getByTestId('deleteSelectedNotebooks'));

// Ensure the modal is open
expect(getByText('Delete 1 notebook')).toBeInTheDocument();
expect(getAllByText('Delete 1 notebook')).toHaveLength(2);

// Close the delete modal
fireEvent.click(getByText('Cancel'));

// Ensure the delete modal is closed
expect(queryByText('Delete 1 notebook')).toBeNull();
expect(getAllByText('Delete 1 notebook')).toHaveLength(1);
});
});
Loading

0 comments on commit fba0d8a

Please sign in to comment.