diff --git a/cypress/integration/composite_level_monitor_spec.js b/cypress/integration/composite_level_monitor_spec.js index dc2c72cf4..d09a8f65a 100644 --- a/cypress/integration/composite_level_monitor_spec.js +++ b/cypress/integration/composite_level_monitor_spec.js @@ -75,7 +75,7 @@ describe('CompositeLevelMonitor', () => { .type('{backspace}') .type('Composite trigger'); - cy.intercept('api/alerting/workflows').as('createMonitorRequest'); + cy.intercept('api/alerting/workflows?*').as('createMonitorRequest'); cy.intercept(`api/alerting/monitors?*`).as('getMonitorsRequest'); cy.get('button').contains('Create').click({ force: true }); @@ -116,7 +116,7 @@ describe('CompositeLevelMonitor', () => { cy.visit( `${Cypress.env('opensearch_dashboards')}/app/${PLUGIN_NAME}#/monitors/${ createdMonitor._id - }?action=update-monitor&type=workflow` + }?action=update-monitor&type=workflow&dataSourceId=` ); } else { cy.log('Failed to get created monitor ', SAMPLE_VISUAL_EDITOR_MONITOR); diff --git a/public/pages/Dashboard/containers/Dashboard.js b/public/pages/Dashboard/containers/Dashboard.js index 5f703240e..0838fe007 100644 --- a/public/pages/Dashboard/containers/Dashboard.js +++ b/public/pages/Dashboard/containers/Dashboard.js @@ -131,6 +131,7 @@ export default class Dashboard extends Component { getAlerts = _.debounce( (from, size, search, sortField, sortDirection, severityLevel, alertState, monitorIds) => { + const dataSourceId = getDataSourceId(); const params = { from, size, @@ -141,13 +142,12 @@ export default class Dashboard extends Component { alertState, monitorIds, monitorType: this.props.monitorType, + dataSourceId, }; const queryParamsString = queryString.stringify(params); - location.search; const { httpClient, history, notifications, perAlertView } = this.props; history.replace({ ...this.props.location, search: queryParamsString }); - const dataSourceId = getDataSourceId(); const extendedParams = { ...(dataSourceId !== undefined && { dataSourceId }), // Only include dataSourceId if it exists ...params, // Other parameters diff --git a/public/pages/Main/Main.js b/public/pages/Main/Main.js index 1746ea610..7751f43dc 100644 --- a/public/pages/Main/Main.js +++ b/public/pages/Main/Main.js @@ -22,8 +22,8 @@ import { } from '../../../public/services'; import { MultiDataSourceContext } from '../../../public/utils/MultiDataSourceContext'; import { parseQueryStringAndGetDataSource } from '../utils/helpers'; -import * as pluginManifest from "../../../opensearch_dashboards.json"; -import semver from "semver"; +import * as pluginManifest from '../../../opensearch_dashboards.json'; +import semver from 'semver'; class Main extends Component { static contextType = CoreContext; @@ -53,8 +53,10 @@ class Main extends Component { async updateBreadcrumbs() { if (this.props.dataSourceEnabled && this.props.location) { const search = this.props.location?.search; - const dataSourceId = search ? parseQueryStringAndGetDataSource(search) : parseQueryStringAndGetDataSource(this.props.location?.pathname); - if (dataSourceId) { + const dataSourceId = parseQueryStringAndGetDataSource( + search || this.props.location?.pathname + ); + if (dataSourceId !== undefined) { setDataSource({ dataSourceId }); this.setState({ selectedDataSourceId: dataSourceId, @@ -103,11 +105,13 @@ class Main extends Component { }; dataSourceFilterFn = (dataSource) => { - const dataSourceVersion = dataSource?.attributes?.dataSourceVersion || ""; + const dataSourceVersion = dataSource?.attributes?.dataSourceVersion || ''; const installedPlugins = dataSource?.attributes?.installedPlugins || []; return ( semver.satisfies(dataSourceVersion, pluginManifest.supportedOSDataSourceVersions) && - pluginManifest.requiredOSDataSourcePlugins.every((plugin) => installedPlugins.includes(plugin)) + pluginManifest.requiredOSDataSourcePlugins.every((plugin) => + installedPlugins.includes(plugin) + ) ); }; @@ -236,7 +240,11 @@ class Main extends Component { setFlyout={this.setFlyout} notifications={core.notifications} landingDataSourceId={this.state.selectedDataSourceId} - defaultRoute={core.chrome?.navGroup?.getNavGroupEnabled() ? this.props.defaultRoute : undefined} + defaultRoute={ + core.chrome?.navGroup?.getNavGroupEnabled() + ? this.props.defaultRoute + : undefined + } /> )} /> diff --git a/public/pages/MonitorDetails/containers/MonitorDetails.js b/public/pages/MonitorDetails/containers/MonitorDetails.js index 03e0aba8c..57e51a5fe 100644 --- a/public/pages/MonitorDetails/containers/MonitorDetails.js +++ b/public/pages/MonitorDetails/containers/MonitorDetails.js @@ -50,7 +50,7 @@ import FindingsDashboard from '../../Dashboard/containers/FindingsDashboard'; import { TABLE_TAB_IDS } from '../../Dashboard/components/FindingsDashboard/findingsUtils'; import { DeleteMonitorModal } from '../../../components/DeleteModal/DeleteMonitorModal'; import { getLocalClusterName } from '../../CreateMonitor/components/CrossClusterConfigurations/utils/helpers'; -import { getDataSourceQueryObj } from '../../utils/helpers'; +import { getDataSourceQueryObj, parseQueryStringAndGetDataSource } from '../../utils/helpers'; import { MultiDataSourceContext } from '../../../../public/utils/MultiDataSourceContext'; import { getUseUpdatedUx, setDataSource } from '../../../services'; import { PageHeader } from '../../../components/PageHeader/PageHeader'; @@ -72,9 +72,13 @@ export default class MonitorDetails extends Component { triggerToEdit: null, delegateMonitors: [], editMonitor: () => { + const dataSourceId = parseQueryStringAndGetDataSource(this.props.location?.search); + const monitorType = this.state.monitor.monitor_type; this.props.history.push({ ...this.props.location, - search: `?action=${MONITOR_ACTIONS.UPDATE_MONITOR}`, + search: `?action=${MONITOR_ACTIONS.UPDATE_MONITOR}&monitorType=${monitorType}${ + dataSourceId !== undefined ? `&dataSourceId=${dataSourceId}` : '' + }`, }); }, isJsonModalOpen: false, @@ -275,26 +279,6 @@ export default class MonitorDetails extends Component { }); }; - onCreateTrigger = () => { - this.props.history.push({ - ...this.props.location, - search: `?action=${TRIGGER_ACTIONS.CREATE_TRIGGER}`, - }); - }; - - onCloseTrigger = () => { - this.props.history.push({ ...this.props.location, search: '' }); - this.setState({ triggerToEdit: null }); - }; - - onEditTrigger = (trigger) => { - this.setState({ triggerToEdit: trigger }); - this.props.history.push({ - ...this.props.location, - search: `?action=${TRIGGER_ACTIONS.UPDATE_TRIGGER}`, - }); - }; - renderNoTriggersCallOut = () => { const { monitor, editMonitor } = this.state; const callout = ( @@ -577,8 +561,6 @@ export default class MonitorDetails extends Component { httpClient={httpClient} delegateMonitors={delegateMonitors} updateMonitor={this.updateMonitor} - onEditTrigger={this.onEditTrigger} - onCreateTrigger={this.onCreateTrigger} />